From 2e8055e62e431d8876970d12cbfc29c40fbb2a10 Mon Sep 17 00:00:00 2001 From: Zander Date: Thu, 12 Nov 2026 17:20:01 +0800 Subject: [PATCH] feat(resume)!: tie the Master resume to Strategy rules and follow-up questions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Master resume follows the information homes in #26: the Strategy decides order, emphasis and what to leave out, and follow-up questions live only in Import reports. - `left_out` is a list of Fact ids. `master save` refuses a Fact that no line of strategy.md outside its Roles section names. The Left out appendix points to those strategy.md lines instead of repeating a reason. - `gap` is the id of a follow-up question in the Candidate's Import reports. The marker shows it as 【待補:q-004】 / [To fill: q-004], the Gaps appendix lists the id without the question text, and `master save` and `validate` refuse a marker that names no known question. - `master plan` marks each Fact with the strategy.md lines that name it and lists the open follow-up questions. - Highlights are optional and appear only when the Strategy asks for them. Each achievement is one story about one event. The Master resume is written only through `master save`; a hand-written draft is replaced by writing it with `master save`, its rules moved into strategy.md and its open questions into Import reports. Breaking: the `gap: {zh, en}` and `left_out: [{facts, zh, en}]` input forms are gone. A Master resume written with them fails `validate`; write it again with `master save --replace` in the new form. Co-Authored-By: Claude Opus 5.5 --- CONTEXT.md | 8 ++- README.md | 2 +- README.zh-TW.md | 2 +- skills/headhunter/SKILL.md | 31 ++++++----- skills/headhunter/scripts/hh.py | 99 +++++++++++++++++++++++---------- 5 files changed, 94 insertions(+), 48 deletions(-) diff --git a/CONTEXT.md b/CONTEXT.md index cf2848a..6d2b562 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -122,9 +122,11 @@ _Avoid_: success probability, chance, odds **Master resume**: The Candidate's complete resume, one in Chinese and one in English: every -active, sourced Fact written out in full and grouped as a resume, or listed as -left out with a reason, with the gaps still to fill marked in place. It is -internal and never sent; extracts for specific contexts start from it. +active, sourced Fact written out in full and grouped as a resume, or left out +by a Strategy rule that names it, with the gaps still to fill marked in place, +each naming the follow-up question that asks for it. The Strategy decides its +order and emphasis. It is internal and never sent; extracts for specific +contexts start from it. _Avoid_: base resume, full CV, career document **Tailored resume**: diff --git a/README.md b/README.md index 4aa98b7..413ed04 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ A job search piles up more than anyone can keep straight: old resumes, notes, wo - **Role profiles** — One candidate can pursue several roles at once, such as backend engineer and tech lead. For each role it lists the requirements, links the facts that support each one with a reason, and names the gaps: no evidence, only unconfirmed inferences, or only self-reported evidence, each with a way to close it. When facts change, it tells you which profiles are out of date. Search candidates by role, by required skill, or by roles with no must-have gaps. - **Job reading** — Give it jobs in any form: a listing or job link from 104, CakeResume, Yourator, a company careers page or LinkedIn, a PDF or HTML file, a screenshot, or copied text, one job or many. It reads the listing, screens the titles, then reads each job in full and saves a snapshot: must-haves, nice-to-haves, duties, salary and location, with requirements tagged from the same taxonomy as candidate facts. Yourator and careers pages are read directly, following each site's robots.txt. 104 and CakeResume block automated requests, so the skill guides you instead: scroll the search results until every job has loaded, copy the page and paste it, and job pages are read in your browser or from text you copy. LinkedIn is read only from your signed-in browser or pasted text. - **Job evaluation** — For one candidate, or across your whole database: it finds the candidates whose roles fit a job and evaluates each against the role that fits, or against all of the candidate's facts when none does, then offers to create a role from the job. Each evaluation gives a fit score from a fixed rubric (skill overlap, seniority, industry and domain, achievements, salary, location and work mode), reasons tied to specific facts and job requirements, gaps and risks with how to close them, and a high / medium / low success rating with its reasons. Failing a hard requirement, such as minimum years or a required degree, lowers the rating by one level. Requirements that keep appearing in the jobs evaluated under a role are proposed as changes to that role, applied only when you accept them. -- **Master resume** — One complete Chinese and English resume per candidate, kept for your own review rather than sent. It writes out every fact with a source in full: a summary, grouped skills and highlights, then each job with what the organization is, the candidate's scope, achievements grouped by project with the problem, the decision, the action and the measured result, and the tools used, followed by projects, education, certificates and training, awards and publications, and languages. Every fact is either written or listed as left out with a reason, so the file doubles as a readable overview of the candidate's facts. Whatever is missing, such as a result or a team size, is marked in place and collected as a list to ask about, and you are told when new or changed facts, or a changed strategy, leave it out of date. +- **Master resume** — One complete Chinese and English resume per candidate, kept for your own review rather than sent. It writes out every fact with a source in full: a summary, grouped skills, highlights when the strategy asks for them, then each job with what the organization is, the candidate's scope, achievements grouped by project, each one event told as the problem, the decision, the action and the measured result, and the tools used, followed by projects, education, certificates and training, awards and publications, and languages. The candidate's strategy decides what it leads with. Every fact is either written or left out by a strategy rule that names it, so the file doubles as a readable overview of the candidate's facts. Whatever is missing, such as a result or a team size, is marked in place with the follow-up question that asks for it, and you are told when new or changed facts, or a changed strategy, leave it out of date. - **Tailored resumes** — A Chinese and an English resume for each evaluated application, in Markdown and PDF. Each starts from the profile of the role the job was evaluated under, follows the resume decisions recorded in the candidate's strategy, such as which title to use or which experience to leave out, puts the most relevant facts first, and uses only facts with a source: every line names the facts it comes from, numbers must match them, skills the candidate lacks stay out, and companies, titles and schools always get the same English names from the candidate's glossary. The PDFs are printed with Chrome, Chromium or Edge, and their text copies cleanly into applicant tracking systems. - **Application tracking** — Every candidate × job pair moves through stages (found → evaluated → preparing → applied → interview rounds → offer → closed), with a dated timeline, each interview round recorded separately, and a next step with a due date while it is open. It lists overdue follow-ups across all candidates, shows progress by candidate, role, job and company, and records how each closed application ended: hired, declined, rejected or withdrawn. - **Feedback loop** — Log feedback from HR, interviewers, the candidate and yourself, with a cause and a concrete fix, and track each fix until it is done; a fix that produces new material, such as a portfolio piece, ends with importing it as a source. Causes that recur across a candidate's applications or under one role turn into proposed changes to the strategy, role profiles and resumes, applied only when you agree. What feedback says about a company builds up into company notes across candidates. Closed applications are compared with their success ratings to show where the scoring over- or under-estimates, and any rubric change stays your decision. diff --git a/README.zh-TW.md b/README.zh-TW.md index 39e1836..bb186f3 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -16,7 +16,7 @@ - **角色檔案**:一位候選人可以同時鎖定好幾個角色,例如後端工程師和技術主管。每個角色會列出條件,把支持每條條件的事實連結起來並說明理由,同時指出缺口:沒有證據、只有未確認的推論,或只有自述的證據,每個缺口都附上補強方式。事實有變動時,會告訴你哪些角色檔案需要更新。可以依角色、要求的技能,或必備條件沒有缺口的角色來查詢候選人。 - **讀取職缺**:職缺可以用任何形式交給它:104、CakeResume、Yourator、企業官網或 LinkedIn 的列表或職缺網址、PDF 或 HTML 檔、截圖,或複製的文字,一個或一批都可以。它會先讀標題粗篩,再逐一讀取完整職缺內容並存成快照:必備條件、加分條件、工作內容、薪資與地點,條件會用和候選人事實相同的標籤分類。Yourator 和企業官網直接讀取,並遵守各網站的 robots.txt。104 和 CakeResume 會擋自動化請求,所以改由 skill 引導你:把搜尋結果捲到所有職缺都載入、複製整頁貼上,職缺頁則從你的瀏覽器讀取或用你複製的文字。LinkedIn 只讀你已登入瀏覽器中開啟的頁面或你貼上的文字。 - **職缺評估**:可針對一位候選人,或從整個資料庫找出角色符合職缺的候選人,並依符合的角色評估;沒有符合的角色時,改用候選人的全部事實評估,並提議從這個職缺建立新角色。每份評估依固定評分標準(技能重疊、職級、產業與領域、成就、薪資地點與工作模式)給出適合度分數,推薦原因會對應到具體的事實和職缺條件,列出缺口與風險及補強方式,並給出高/中/低的成功率等級與理由。不符合硬性條件(例如最低年資或指定學歷)時,等級降一級。同一角色下評估過的職缺若反覆出現同樣的條件,會提議加進該角色,經你同意才套用。 -- **完整版履歷**:每位候選人一份中文與英文的完整履歷,留給你自己查閱,不拿去投遞。它把每一條有出處的事實完整寫出:摘要、分組的技能與核心亮點,接著每段經歷寫出這個組織在做什麼、候選人負責的範疇、依專案分組的成就(寫出問題、判斷、做法與附量測條件的結果),以及用到的技術,最後是專案、學歷、證照與訓練、獎項與發表,以及語言。每一條事實不是寫進履歷,就是列為不寫並說明原因,所以這份檔案也是候選人事實的完整總覽。缺少的內容,例如成果或團隊人數,會在原處標示並整理成待追問的清單;有新增或變動的事實、或求職策略改變時,會告訴你它需要更新。 +- **完整版履歷**:每位候選人一份中文與英文的完整履歷,留給你自己查閱,不拿去投遞。它把每一條有出處的事實完整寫出:摘要、分組的技能、求職策略要求時才有的核心亮點,接著每段經歷寫出這個組織在做什麼、候選人負責的範疇、依專案分組的成就(每則只講一件事,寫出問題、判斷、做法與附量測條件的結果),以及用到的技術,最後是專案、學歷、證照與訓練、獎項與發表,以及語言。開頭放什麼由候選人的求職策略決定。每一條事實不是寫進履歷,就是依求職策略中點名它的規則不寫,所以這份檔案也是候選人事實的完整總覽。缺少的內容,例如成果或團隊人數,會在原處標示對應的追問問題;有新增或變動的事實、或求職策略改變時,會告訴你它需要更新。 - **客製履歷**:每個評估過的投遞都產出中文與英文兩版,Markdown 與 PDF 格式。履歷從該職缺評估時所用角色的角色檔案出發,遵守候選人求職策略裡記下的履歷寫法決定,例如要用哪個職稱、哪段經歷不放,把最相關的事實放前面,只使用有出處的事實:每一行都註明出自哪些事實,數字必須和事實一致,候選人缺少的技能不會寫進去,公司、職稱和學校的英文名稱一律依照候選人的對照表。PDF 用 Chrome、Chromium 或 Edge 產生,文字可以正確複製,求職系統(ATS)也能正確讀取。 - **投遞進度追蹤**:每組「候選人 × 職缺」依階段推進(發現 → 已評估 → 準備中 → 已投遞 → 面試 → Offer → 結案),保留有日期的歷程,每輪面試分開記錄,進行中的投遞都有下一步與期限。可以列出所有候選人逾期的待辦,依候選人、角色、職缺或公司查看進度,結案時記錄結果:錄取、婉拒、未錄取或撤回。 - **回饋與修正**:記錄來自 HR、面試官、候選人與你自己的回饋、原因分類與具體修正方向,並追蹤每項修正直到完成;會產出新資料的修正(例如作品集)要匯入成資料來源才算完成。同一位候選人的多次投遞或同一角色下重複出現的原因,會變成對求職策略、角色檔案與履歷的修改提議,經你同意才套用。回饋中關於公司的內容會跨候選人累積成公司情報。結案的投遞會和成功率等級比對,指出評分高估或低估之處,要不要調整評分標準由你決定。 diff --git a/skills/headhunter/SKILL.md b/skills/headhunter/SKILL.md index 13f8737..995f28d 100644 --- a/skills/headhunter/SKILL.md +++ b/skills/headhunter/SKILL.md @@ -64,7 +64,7 @@ python3 /scripts/hh.py | `resume plan ` | Show what an Application's resumes start from: the Candidate's Strategy, the Role profile, the Evaluation's evidence, what to leave out, the usable Facts and the Glossary | | `resume save [--replace]` | Write `resume.zh.md` and `resume.en.md` from JSON or YAML on stdin and print both to PDF; nothing is written if any check fails | | `resume pdf ` | Check both resumes and print them to PDF again, after editing them by hand | -| `master plan ` | Show what the Master resume is written from: the Candidate's Strategy, every usable Fact by organization and kind with its missing fields, the Glossary and the header, and whether the Master resume is current | +| `master plan ` | Show what the Master resume is written from: the Candidate's Strategy, every usable Fact by organization and kind with its missing fields and the lines of `strategy.md` that name it, the open follow-up questions, the Glossary and the header, and whether the Master resume is current | | `master save [--replace]` | Write `master-resume.zh.md` and `master-resume.en.md` from JSON or YAML on stdin; nothing is written if any check fails | | `validate []` | Check `taxonomy.yml`, Candidate folders (with their Roles, Evaluations, resumes, Applications and Feedback) and Job snapshots | | `index` | Delete and rebuild `index.sqlite` | @@ -265,7 +265,7 @@ summary: # one or more sentences, not tied to a Role - {zh: ..., en: ..., facts: [f-004, f-001]} skills: # grouped; where each was used, with years only from Fact periods - {label: {zh: 程式語言, en: Languages}, zh: Python、SQL(2020 起), en: "Python, SQL (since 2020)", facts: [f-011]} -highlights: # the 3–5 strongest results; their Facts are cited in experience or projects too +highlights: # optional, only when the Strategy asks for it; Facts also cited in experience or projects - {zh: ..., en: ..., facts: [f-002, f-003]} experience: # reverse chronological - org: 智慧水表專案 # a company in glossary.yml, cited by one of its Facts; or name: {zh, en} @@ -275,7 +275,7 @@ experience: # reverse chronological roles: # optional: one line per title, such as titles at several companies - {org: 乙科技, title: 資料工程師, period: 2021-07..2022-02, facts: [f-005]} context: {zh: ..., en: ..., facts: [f-006]} # what the organization or project is - scope: {gap: {zh: 團隊人數, en: team size}, facts: [f-004]} # team size, ownership, reporting line + scope: {gap: q-004, facts: [f-004]} # team size, ownership, reporting line groups: # achievements by project or theme, most impactful first - heading: {zh: 資料匯入, en: Data import} # optional bullets: [{zh: ..., en: ..., facts: [f-007]}] @@ -285,12 +285,12 @@ education: [{school: 範例大學, zh: 資訊管理學士, en: B.S. in Informati certificates: [{zh: ..., en: ..., facts: [f-015]}] # certificates and training awards: [] # awards, publications, talks, patents languages: [{zh: 英文:TOEIC 850(2019), en: "English: TOEIC 850 (2019)", facts: [f-013]}] -left_out: [{facts: [f-010], zh: 依 Strategy 不放這段經歷, en: The Strategy leaves this role out}] +left_out: [f-010] # Facts that a rule in strategy.md names and leaves out ``` - `org` is a company in `glossary.yml`; a self-directed stretch, such as independent development or study, takes `name` instead. `school` and `period` are optional in `education`. -- Any item may add `gap: {zh, en}`: what is missing there, such as a result or a team size. The line shows it as `【待補:…】` or `[To fill: …]`. An item with only a gap, and optionally its Facts, stands for a line no Fact can fill yet. -- Sections appear in the order above, after the header the script writes from `profile.yml`; a section with no items is left out. Two appendices follow, not part of the resume: Gaps (待補) lists every gap with its Facts' `missing` fields, and Left out (未寫入) lists `left_out` with its reasons. +- Any item may add `gap: q-`: the follow-up question, in an Import report, that asks for what is missing there, such as a result or a team size. The line shows it as `【待補:q-004】` or `[To fill: q-004]`. An item with only a gap, and optionally its Facts, stands for a line no Fact can fill yet. +- Sections appear in the order above, after the header the script writes from `profile.yml`; a section with no items is left out. Two appendices follow, not part of the resume: Gaps (待補) lists every gap with its question id and its Facts' `missing` fields, without repeating the question, and Left out (未寫入) lists each `left_out` Fact with the lines of `strategy.md` that name it. - Every line other than headings and gap-only lines ends with the Facts it comes from, as in Tailored resumes. `master save` refuses a Master resume when: @@ -299,11 +299,12 @@ left_out: [{facts: [f-010], zh: 依 Strategy 不放這段經歷, en: The Strateg - a number in a line is not in the statements or periods of the Facts it cites - a company, title, school or location is not in `glossary.yml`, an `org` is not the organization of one of its Facts, a title or school is not in its Facts, or a period is not one of its Facts' - the Chinese and English lines name a Glossary entry differently, or the English has Chinese in it -- an active, sourced Fact is neither cited nor listed under `left_out`, or `left_out` lists a cited or unusable Fact +- an active, sourced Fact is neither cited nor listed under `left_out`, or `left_out` lists a cited or unusable Fact, or a Fact that no line of `strategy.md` outside its Roles section names +- a `gap` is not the id of a follow-up question in the Candidate's Import reports - a highlight cites a Fact that no `experience` or `projects` line cites - the headline or summary is missing -The Master resume is stale when a Fact it covers changed or was removed, an active, sourced Fact is not covered, or the Strategy's guidance changed; `candidate show` and `master plan` say which. `validate` checks the Markdown after hand edits as it checks Tailored resumes; lines that hold only a gap need no Facts, and the appendices only need to name known Facts. The Master resume has no PDF. +The Master resume is stale when a Fact it covers changed or was removed, an active, sourced Fact is not covered, or the Strategy's guidance changed; `candidate show` and `master plan` say which. `validate` checks the Markdown after hand edits as it checks Tailored resumes; lines that hold only a gap need no Facts, every gap marker must name a follow-up question in the Import reports, and the appendices only need to name known Facts. The Master resume has no PDF. **resume.zh.md / resume.en.md**: a YAML block between `---` lines (`candidate`, `job`, `role`, `lang`, `written`, and `role_profile`, the build date of the Role profile it started from), then the resume, written by `resume save` from what you give it: @@ -462,19 +463,19 @@ Each Evaluation compares one Job snapshot with one Candidate under the Role that ### Write the Master resume -The Master resume writes out every usable Fact of a Candidate as one complete resume, in Chinese and English. It is internal: the user reads it to review and confirm the Facts, and extracts for specific contexts start from it. It is never sent. Write it when the user asks, and again when it is stale. +The Master resume writes out every usable Fact of a Candidate as one complete resume, in Chinese and English. It is internal: the user reads it to review and confirm the Facts, and extracts for specific contexts start from it. It is never sent. Write it when the user asks, and again when it is stale. It is written only through `master save`; a resume-like file written any other way, such as a hand-written draft, is not a Master resume and no command reads it. To replace such a draft, write the Master resume with `master save`, move the rules in the draft into `strategy.md` and its open questions into Import reports as follow-up questions, and remove the draft only when the user agrees. -1. **Plan**: `master plan ` shows the Candidate's Strategy without its Roles section, every usable Fact grouped by organization, newest first, and by kind, with its period, evidence and missing fields, the Facts never to use, the Glossary and the header. Add any company, title, school or location still missing from `glossary.yml`. -2. **Write** every usable Fact into a section, or list it under `left_out` with the reason, such as the Strategy leaving that experience out. +1. **Plan**: `master plan ` shows the Candidate's Strategy without its Roles section, every usable Fact grouped by organization, newest first, and by kind, with its period, evidence, missing fields and the lines of `strategy.md` that name it, the Facts never to use, the open follow-up questions, the Glossary and the header. Add any company, title, school or location still missing from `glossary.yml`. +2. **Write** every usable Fact into a section, or list it under `left_out` when a rule in `strategy.md` leaves it out. The rule names the Fact, so the decision lives only in the Strategy. To leave out a Fact that no rule names, propose a rule to the user and add it to `strategy.md` once they agree. The Strategy decides order and emphasis: what the summary leads with, which achievements come first, and whether Highlights appear. - **Summary**: a headline and a few sentences, not tied to a Role: years and fields, signature strengths, representative results, background. Viewpoints in the Strategy may shape its wording, but every sentence cites Facts. - - **Skills** in groups, each naming where it was used. **Highlights**: the 3–5 strongest results across organizations. + - **Skills** in groups, each naming where it was used. **Highlights** only when the Strategy asks for them: the strongest results across organizations, each also written in full under its experience or project. - **Experience**, newest first: one block per organization, a self-directed stretch such as independent development or study (`name`), or one project with titles at several companies (`roles`, one line per title, as a promotion within one company is shown). Each block has a context line (what the organization or project is), a scope line (team size, ownership, reporting line), achievements grouped under headings by project or theme with the most impactful first, and a tech line. - - Write each achievement in long form: the problem, the judgment or trade-off, the action, and the result with its measurement conditions. One line may combine the Facts that make up one achievement. + - Write each achievement in long form as one story about one event: the problem, the judgment or trade-off, the action, and the result with its measurement conditions. A line combines only the Facts of that event, never Facts from different events to cover more ground. - Then projects, education, certificates and training, awards and publications, and languages. - Wording may add context, the judgment behind an action and the impact a Fact states, but never raises a role ("took part in" never becomes "led") and never adds a number, title, date or skill. Follow the Strategy's resume guidance. -3. **Mark gaps**: add `gap` where a line lacks something, such as a result, a team size, a company's context or a date. Where no Fact can fill a line yet, give the item only a `gap`. +3. **Mark gaps**: where a line lacks something, such as a result, a team size, a company's context or a date, find the open follow-up question that asks for it, or add one to the Import report of the Source the Fact cites, with an id from `next-id question`. Set `gap` to that question's id. Where no Fact can fill a line yet, give the item only a `gap`. 4. **Save**: pipe it to `master save `; `--replace` writes it again. -5. **Follow up**: ask the user about the Gaps appendix and save the answers as in Follow-up questions. The new Facts make the Master resume stale, so offer to write it again. +5. **Follow up**: ask the questions the gaps name and save the answers as in Follow-up questions. The new Facts make the Master resume stale, so offer to write it again. 6. **Report** the two files, how many Facts it cites and leaves out, and its gaps. ### Write resumes diff --git a/skills/headhunter/scripts/hh.py b/skills/headhunter/scripts/hh.py index 4223208..c7376aa 100644 --- a/skills/headhunter/scripts/hh.py +++ b/skills/headhunter/scripts/hh.py @@ -668,9 +668,10 @@ def err(message): errors.extend(f"{name}: {e}" for e in check_resume(path, lang, by_id)) masters = master_paths(folder) if any(path.exists() for path in masters.values()): + question_ids = {q["id"] for q in report_questions(folder)} for lang, path in masters.items(): if path.exists(): - errors.extend(f"{name}: {e}" for e in check_master(path, lang, by_id)) + errors.extend(f"{name}: {e}" for e in check_master(path, lang, by_id, question_ids)) else: err(f"master resume: {path.name} is missing; write both with master save --replace") for jid, path in application_dirs(folder): @@ -1733,9 +1734,32 @@ def master_paths(folder: Path) -> dict: return {lang: folder / f"master-resume.{lang}.md" for lang in RESUME_LANGS} -def check_master(path: Path, lang: str, by_id: dict) -> list: +def strategy_fact_lines(folder: Path) -> dict: + """The line numbers of strategy.md, outside the Roles section the script keeps, that name each Fact id.""" + path = folder / "strategy.md" + named, in_roles = {}, False + if not path.exists(): + return named + for n, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1): + if line.startswith("## "): + in_roles = line.strip() == "## Roles" + continue + if not in_roles: + for fid in dict.fromkeys(re.findall(r"\bf-\d+\b", line)): + named.setdefault(fid, []).append(n) + return named + + +def render_strategy_lines(numbers: list, lang: str) -> str: + if lang == "zh": + return f"strategy.md 第 {'、'.join(map(str, numbers))} 行" + return f"strategy.md line{'s' if len(numbers) > 1 else ''} {', '.join(map(str, numbers))}" + + +def check_master(path: Path, lang: str, by_id: dict, question_ids: set) -> list: """Problems in the Master resume's Markdown, checked like a Tailored resume's. A line that holds only a gap marker - cites nothing, and the Gaps and Left out appendices need only name known Facts.""" + cites nothing, every gap marker names a follow-up question, and the Gaps and Left out appendices need only name + known Facts.""" where = f"master resume {lang}" try: front, body = read_job(path) @@ -1759,6 +1783,11 @@ def check_master(path: Path, lang: str, by_id: dict) -> list: if lang == "en" and HAN.search(text): errors.append(f"{where}: line {n} has Chinese text: {text[:60]}") continue + for marker in GAP_MARK.findall(text): + qid = re.sub(r"^\s*(?:【待補:|\[To fill: )|(?:】|\])$", "", marker) + if qid not in question_ids: + errors.append(f"{where}: line {n} has the gap marker {marker.strip()}, which names no follow-up " + "question in the Import reports") cite = CITATION.search(text) claim = GAP_MARK.sub("", text[:cite.start()] if cite else text) if cite: @@ -3491,7 +3520,8 @@ def latest(org: str) -> int: ends = [period_months(f.get("period")) for f in groups[org]] return max((10 ** 6 if end is None and start is not None else end or -1 for start, end in ends), default=-1) - print(f"Write every one of these {len(usable)} Facts, or list it under left_out with a reason" + named = strategy_fact_lines(folder) + print(f"Write every one of these {len(usable)} Facts, or list it under left_out when a rule in strategy.md names it" + (" (+ not in the current Master resume)" if written else "") + ":") for org in sorted(groups, key=lambda o: (not o, -latest(o))): print(f" {org or '(no organization)'}") @@ -3499,9 +3529,16 @@ def latest(org: str) -> int: for fact in (f for f in groups[org] if f.get("kind") == kind): mark = "+" if written and fact["id"] not in covered else " " missing = f" (missing: {', '.join(fact['missing'])})" if fact.get("missing") else "" + rule = f" ({render_strategy_lines(named[fact['id']], 'en')})" if fact["id"] in named else "" print(f" {mark} {fact['id']} [{kind}, {fact.get('evidence')}] {fact.get('period') or '-'} " - f"{fact.get('statement')}{missing}") + f"{fact.get('statement')}{missing}{rule}") print_unusable(facts, by_id) + open_questions = [q for q in report_questions(folder) if q["open"]] + print("\nOpen follow-up questions; a gap names the one that asks for what is missing:") + for q in open_questions: + print(f" {q['id']}: {q['text']}") + if not open_questions: + print(" none; add one to the Import report of the Source the Fact cites before marking a gap") print_glossary_and_header(profile, glossary) @@ -3520,6 +3557,7 @@ def cmd_master_save(args): by_id, errors = writer.by_id, writer.errors errors += [f"unknown field {key!r}; fields are {', '.join(MASTER_FIELDS)}" for key in data if key not in MASTER_FIELDS] companies, titles, schools = (glossary_pairs(glossary, (k,)) for k in ("company", "title", "school")) + question_ids = {q["id"] for q in report_questions(folder)} cited, body_ids, highlight_ids, gaps = set(), set(), {}, [] def items(key) -> list: @@ -3543,7 +3581,10 @@ def line(item, where, place, fmt=lambda lang, text: text) -> list: return [] gap = item.get("gap") if gap is not None: - gap = writer.label(gap, f"{where} gap") + gap = str(gap).strip() + if gap not in question_ids: + errors.append(f"{where}: gap must be the id of a follow-up question in the Import reports, such as " + f"q-012, not {gap!r}; add the question to the report of the Source the Fact cites") if gap is None or any(item.get(lang) for lang in RESUME_LANGS): ids = writer.cited(item, where) text = writer.bilingual(item, where, ids) @@ -3551,7 +3592,7 @@ def line(item, where, place, fmt=lambda lang, text: text) -> list: ids = writer.cited(item, where) if item.get("facts") else [] text = {lang: "" for lang in RESUME_LANGS} if gap is not None: - text = {lang: f"{text[lang]}{'' if lang == 'zh' else ' '}{GAP_MARKS[lang][0]}{gap[lang]}{GAP_MARKS[lang][1]}" + text = {lang: f"{text[lang]}{'' if lang == 'zh' else ' '}{GAP_MARKS[lang][0]}{gap}{GAP_MARKS[lang][1]}" .strip() for lang in RESUME_LANGS} gaps.append((place, gap, ids)) cited.update(ids) @@ -3702,26 +3743,28 @@ def titled(item, where, ids, parts) -> None: if key == "projects": body_ids.update(found) + named = strategy_fact_lines(folder) left = {} - for n, entry in enumerate(items("left_out"), 1): + for n, fid in enumerate(items("left_out"), 1): where = f"left_out {n}" - ids = entry.get("facts") if isinstance(entry, dict) else None - if not isinstance(ids, list) or not ids: - errors.append(f"{where}: list the Facts it leaves out") + if not isinstance(fid, str): + errors.append(f"{where}: give the id of a Fact a rule in strategy.md leaves out, such as f-010") continue - reason = writer.label(entry, where) - for fid in ids: - problem = fact_problem(by_id, fid) - if problem: - errors.append(f"{where}: {problem}; only active, sourced Facts need listing") - elif fid in cited: - errors.append(f"{where}: {fid} is cited by a line; leave it out of left_out") - else: - left[fid] = reason + problem = fact_problem(by_id, fid) + if problem: + errors.append(f"{where}: {problem}; only active, sourced Facts need listing") + elif fid in cited: + errors.append(f"{where}: {fid} is cited by a line; leave it out of left_out") + elif fid not in named: + errors.append(f"{where}: no rule in strategy.md names {fid}; cite it in a line, or add a rule that names it " + "once the user agrees") + else: + left[fid] = named[fid] uncovered = [f["id"] for f in facts if isinstance(f, dict) and not fact_problem(by_id, f.get("id")) and f["id"] not in cited and f["id"] not in left] if uncovered: - errors.append(f"cite {', '.join(uncovered)} in a line, or list them under left_out with a reason") + errors.append(f"cite {', '.join(uncovered)} in a line, or list them under left_out when a rule in " + "strategy.md names them") for where, ids in highlight_ids.items(): for fid in ids: if fid not in body_ids: @@ -3739,15 +3782,15 @@ def titled(item, where, ids, parts) -> None: for lang, colon, open_, sep, close in (("zh", ":", "(", ";", ")"), ("en", ": ", " (", "; ", ")")): where = f"{place[lang]}{colon}" if place[lang] else "" note = f"{open_}{sep.join(notes[lang])}{close}" if ids else "" - writer.lines[lang].append(f"- {where}{gap[lang]}{note}") + writer.lines[lang].append(f"- {where}{gap}{note}") if left: writer.heading({lang: MASTER_HEADINGS[lang]["left_out"] for lang in RESUME_LANGS}) - reasons = {} - for fid, reason in left.items(): - reasons.setdefault(tuple(reason.values()), []).append(fid) - for (zh, en), ids in reasons.items(): - writer.lines["zh"].append(f"- {', '.join(ids)}:{zh}") - writer.lines["en"].append(f"- {', '.join(ids)}: {en}") + rules = {} + for fid, numbers in left.items(): + rules.setdefault(tuple(numbers), []).append(fid) + for numbers, ids in rules.items(): + writer.lines["zh"].append(f"- {', '.join(ids)}:{render_strategy_lines(list(numbers), 'zh')}") + writer.lines["en"].append(f"- {', '.join(ids)}: {render_strategy_lines(list(numbers), 'en')}") covered = sorted(cited | set(left), key=lambda f: id_number(f, "f") or 0) built_from = {"strategy": digest(strategy_guidance(folder)), "facts": {fid: digest(by_id[fid]) for fid in covered}}