- Lodged By: <project lodger>
- Client Internal No.: {CLIENT_REF}
- Address: Lot 1 Fake Street Fakeville 6000 WA
Client
+- Project Company: {company}
- Project Creator: {project_creator}
diff --git a/SPEC.md b/SPEC.md index 7d278854..2b758fbf 100644 --- a/SPEC.md +++ b/SPEC.md @@ -164,7 +164,7 @@ src/po_agent/ reader_rules.py Summit's PDF patterns on both code readers' text (company line, PO, COMPACTION TEST item row) company.py a company name or alias -> its creator-table row (trimmed, case-insensitive, whole name) decision.py Summit's decision engine = seam 1; no browser code (calls the project lookup it is given) - models.py SummitProceed (the full PO, original assignee, previous task, the Documents names) + models.py SummitProceed (the full PO, original assignee, Project Creator, the Documents names) summit_variation/ Agent 3's rules (Summit variations); no browser code, as summit/ reader_rules.py Note A's PDF patterns on both code readers' text: Summit's company line and PO, the items block's case a / case b (task 10.4) decision.py Agent 3's decision engine = seam 1; no browser code (calls the project lookup it is given; task 10.7) @@ -560,12 +560,12 @@ In this order (cheap first, so a non-compaction PDF costs no project search): | Readers agree | the company line, the `Purchase Order No:` value and the compaction finding are equal on both readers' text | `READERS_DISAGREE` | | PO number | the PDF's `Purchase Order No:` value equals the title's `PO:` value exactly (Joey, 23 Nov 2026). The attachment's file name is **not** compared | `PO_MISMATCH` | | Company known | the title company and the PDF's top-left company each name a row of the creator table, directly or by an alias. A project whose Company names no row is not a match (Project row below: `PROJECT_NOT_FOUND`; Joey, 25 Nov 2026: a Summit project under a company outside the table won't happen) | `COMPANY_UNKNOWN` (new) | -| Project | Projects search by the Client Ref No. = the PO before its first `/`; a row matches when Client Ref No. (trimmed, case-insensitive) equals it **and** its Company is one of the table's companies. Exactly one → its pln; none → `PROJECT_NOT_FOUND`; more, or a second page → `PROJECT_AMBIGUOUS`. The project window's **Client Internal No.** must equal it too, else `UNEXPECTED_SCREEN` (as B1) | as listed | -| Company agrees | title, PDF and project Company map to the **same** table row (Joey, 23 Nov 2026) | `COMPANY_MISMATCH` (new) | +| Project | Projects search by the Client Ref No. = the PO before its first `/`; a row whose Status cell reads exactly `Cancelled` (trimmed) is dropped first (Joey, 4 Dec 2026: a Cancelled duplicate project with the same Client Ref No. no longer makes the match ambiguous; Agent 3 still counts it); a row matches when Client Ref No. (trimmed, case-insensitive) equals it **and** its Company is one of the table's companies. Exactly one → its pln; none → `PROJECT_NOT_FOUND`; more, or a second page → `PROJECT_AMBIGUOUS`. The project window's **Client Internal No.** must equal it too, else `UNEXPECTED_SCREEN` (as B1) | as listed | +| Company agrees | title and PDF map to the **same** table row (Joey, 23 Nov 2026), and the project Company maps to that row too, with two widenings (Joey, 4 Dec 2026): a **Summit New Homes** project also agrees when the title and the PDF each read one of its `also_agrees` names (New Gen and EasyStart, New Generation and EasyStart); a **Summit Projects** project agrees with any title and PDF row (`agrees_with_any_row`). Title and PDF on two different rows still mismatch on either (safe side, Joey to confirm; decisions, 4 Dec 2026). Agent 3 keeps the three names on one row | `COMPANY_MISMATCH` (new) | | Duplicate | any Compaction Test task on the project not Cancelled → skip, whatever its PO (Joey, 23 Nov 2026). A Cancelled one doesn't block a Summit booking (Joey, 25 Nov 2026; unlike B1 live, which counts it); its number is still recorded for W2 | `DUPLICATE_TASK` | -| Creator | the row's creator; for a "previous task" row, the previous task's Task Creator (below) | `CREATOR_UNKNOWN` (new) | +| Creator | the project row's creator; for a "Project Creator" row, the project window's Project Creator (below) | `CREATOR_UNKNOWN` (new) | -**No address check for Summit** (Joey, 23 Nov 2026; decisions, 23 Nov 2026, Client Internal No. check): `b1/address.py` and the Job Address agreement are not used. The identity link is instead: two readers agree on the PO, the PDF's PO equals the title's, exactly one project with that Client Ref No. and a Summit Company, its Client Internal No. equal again, and the company agreeing three ways. +**No address check for Summit** (Joey, 23 Nov 2026; decisions, 23 Nov 2026, Client Internal No. check): `b1/address.py` and the Job Address agreement are not used. The identity link is instead: two readers agree on the PO, the PDF's PO equals the title's, exactly one project with that Client Ref No. and a Summit Company, its Client Internal No. equal again, and the company agreeing (one row, or one of the two widenings of 4 Dec 2026). **PDF patterns** (task 9.7, `summit/reader_rules.py`; pinned on Joey's 11 real Summit PDFs in `private/summit/pdfs/`, looked at as masked shapes; decisions, 25 Nov 2026, Summit PDF patterns), read the same way on both readers' text: - **Company line:** the first non-empty line, trimmed (the table lookup is the decision engine's). @@ -575,38 +575,38 @@ In this order (cheap first, so a non-compaction PDF costs no project search): ### Creator table -Company names, creators and aliases may be committed; they are in `config/clients/summit.toml` (shape below). Keyed by the table row the three company names agree on: +Company names, creators and aliases may be committed; they are in `config/clients/summit.toml` (shape below). Keyed by the project Company's row (the Company agrees check above): | Company (row) | Aliases | Creator | |---|---|---| | Summit Easystart | New Gen and EasyStart; New Generation and EasyStart (older Note titles; Joey, 26 Nov 2026) | NH Sub Floor | | Summit Homes Group | - | Compactions | -| Summit New Homes | - | NH Sub Floor | +| Summit New Homes (also agrees with New Gen and EasyStart and New Generation and EasyStart on the title and PDF; Joey, 4 Dec 2026) | - | NH Sub Floor | | Summit SouthWest | Summit South West (MySys's spelling; Joey, 25 Nov 2026) | Compactions | | Summit Granny Flats | - | Alison Wells (Joey, 26 Nov 2026) | -| Summit Projects (MySys's spelling; Joey, 26 Nov 2026) | Summit Developments (Joey, 24 Nov 2026); Summit Project (the row's old name) | previous task | -| Summit Renovations (was Summit Home Improvement) | - | previous task | -| Summit Homes Display | - | previous task | +| Summit Projects (MySys's spelling; Joey, 26 Nov 2026; its project agrees with any title and PDF row, Joey, 4 Dec 2026) | Summit Developments (Joey, 24 Nov 2026); Summit Project (the row's old name) | Project Creator | +| Summit Renovations (was Summit Home Improvement) | - | Project Creator | +| Summit Homes Display | - | Project Creator | Summit North West is an old name that won't appear again (Joey, 25 Nov 2026): no row, so a project under it is not a match (`PROJECT_NOT_FOUND`). -The previous-task rule stands (Joey, 26 Nov 2026): the creator is the Task Creator of the highest-numbered task that is not a Compaction Test and not Cancelled, not the Project Creator, although in 3 real Summit Projects bookings seen in S.0 staff picked the Project Creator. +The Project Creator rule replaces the previous-task rule (Joey, 4 Dec 2026, after a Summit Renovations PO was skipped `CREATOR_UNKNOWN` every run): the creator of a Summit Projects, Summit Renovations or Summit Homes Display project is its Project Creator, as staff picked in 3 real Summit Projects bookings seen in S.0, not the Task Creator of its latest task (23 and 26 Nov 2026). Names are compared trimmed and case-insensitive, whole name only. A name not in the table (including a company the paper list strikes out) is `COMPANY_UNKNOWN`: a missing alias costs coverage, never a wrong write. -**Previous task** (Joey, 23 Nov 2026: such a project always has an earlier task that isn't a compaction task): from the settled Tasks table, the task with the **highest task number** whose name is not `Compaction Test` and whose Status is not Cancelled; its details row's **Task Creator** is the creator. No such task, or a Task Creator empty or `---` → `CREATOR_UNKNOWN`. +**Project Creator** (Joey, 4 Dec 2026): the project window's Client block, the text after the bold label `Project Creator:` (screen-map row 07, a link), trimmed. Read only for Summit (Agent 2), at every project read: the peek, W1's reopen and the hold re-check (whatever the row; Agent 2's read also drops Cancelled rows there, so a recent booking whose project was later Cancelled re-checks as not found, a HOLD_LOST alert, nothing written). Empty or `---` → `CREATOR_UNKNOWN`. The Tasks table no longer decides the creator. -The creator travels in the `Proceed` (ADR-003 decision 3), with the full PO, the pln, the email body, the Note's original assignee and, for a previous-task row, that task's number and Task Creator (W1's recheck) and replaces B1's `Perth Scheduling` in every Creator write and read-back (W1 form, W2 new-task row and task detail). +The creator travels in the `Proceed` (ADR-003 decision 3), with the full PO, the pln, the email body, the Note's original assignee and, for a Project Creator row, the Project Creator (W1's recheck) and replaces B1's `Perth Scheduling` in every Creator write and read-back (W1 form, W2 new-task row and task detail). ### The take and the booking On PROCEED in `run`: - **Take:** the kill switch re-read (`Controls.before_take`), find the Note again; its "Assignee:" must still read the original assignee, else `"outcome": "untouched", "reason": "NOTE_TAKEN"`. Untick Send Email and read it back (the shared control, kept as is; no longer a Must-never rule since 2 Dec 2026: decisions, 2 Dec 2026, Send Email Must-never removed), user list = `Agent 2 (Summit Homes)`, pool list `--Select Pool--`, **Assign**, read back as B1 (Assignee reads the agent, a new "User Assigned" log line). The window must still show Link to Project. -- **W1-W5 as B1** ([MySys screen rules](#mysys-screen-rules)), with these values: Creator = the decided creator (if the option is not in the Creator select: close the browser context, `WRITE_NOT_STARTED`, reason `CREATOR_UNKNOWN`, Note returned); PO Number = the full PO; Documents = the PDF; Note = the email body; Hold note `ON HOLD UNTIL CALL UP`; Link to the pln; Solved. W1's recheck of the project also requires, for a previous-task row, the same previous task and Task Creator as decided, else `WRITE_NOT_STARTED`. Read-backs as B1, with Lodged By and "Solved by" = Agent 2, and Task Creator = the decided creator. +- **W1-W5 as B1** ([MySys screen rules](#mysys-screen-rules)), with these values: Creator = the decided creator (if the option is not in the Creator select: close the browser context, `WRITE_NOT_STARTED`, reason `CREATOR_UNKNOWN`, Note returned); PO Number = the full PO; Documents = the PDF; Note = the email body; Hold note `ON HOLD UNTIL CALL UP`; Link to the pln; Solved. W1's recheck of the project also requires, for a Project Creator row, the same Project Creator (trimmed) as decided, else `WRITE_NOT_STARTED`. Read-backs as B1, with Lodged By and "Solved by" = Agent 2, and Task Creator = the decided creator. - **Email body:** the Note window's email body is one `iframe` (an HTML table, a line of text and a Disclaimer; Joey copies all of it). Rule: exactly one `iframe` in the Note window whose body text is not empty, still empty after 15 s or more than one → `UNEXPECTED_SCREEN`. Its text, line breaks kept, is the task Note; read back whitespace-collapsed as B1. B1 keeps its "ends with the file name" rule. As built (task 9.12): read once the window holds an iframe and every iframe has its text, or after 15 s; a `
` is never Summit's body; table cells read tab-separated. - **Documents file name:** the Documents row's name is compared to the PDF's file name after MySys's own renaming: MySys files a `-` in the name as `_` (open question S4, answered in S.0, 26 Nov 2026, on staff uploads of Summit POs). Any other mismatch stops before Submit as `WRITE_NOT_STARTED`, which is safe. -As built (task 9.14; decisions, 26 Nov 2026, Summit booking): the shared booker runs with Summit's `Proceed`, Agent 2 and the client file's `project_document_type`. **Creator:** the Creator select's option texts are read before anything is selected; the creator must equal exactly one of them after stripping surrounding whitespace on both sides, case-sensitive, and that option is chosen as the page shows it; none or more than one is `WRITE_NOT_STARTED`, reason `CREATOR_UNKNOWN`, nothing selected (an option that repeats its label or shows a mangled apostrophe simply doesn't match; no repair). The check is shared with B1, whose `Perth Scheduling` is an option on both sites. **W1's recheck:** after the reopen, the previous-task rule is applied again to the Tasks table read now; a previous-task row proceeds only if it gives the same task number and Task Creator as the peek, else `WRITE_NOT_STARTED` before Create New Task opens. **Documents name:** the upload keeps the PDF's own name; the W1 Documents block must show exactly that name or exactly the name with every `-` as `_`, and W2's Documents tab File must start with one of the two (after Submit a mismatch is `ACCURACY_BREACH`, as B1). Which form MySys shows for the agent's own upload is seen at the first watched run (S.4). **Body:** carried as the iframe read it (several lots included), the W1 Note read back exactly, the task detail's Notes whitespace-collapsed (B1's read-backs). A Note taken and stopped at W1 goes back under 9.13's rules (a `---` one by the Assignee Unlink since 27 Nov 2026); one not returned stays with Agent 2, and its ALERT "run stopped; Note not returned" carries the stop's reason (`reason=CREATOR_UNKNOWN`). `run --client summit` books up to `max_notes_per_run` Notes per run: 15 for the hourly runs (decisions, 27 Nov 2026, Summit cap 15), 1 for the first live runs. +As built (task 9.14; decisions, 26 Nov 2026, Summit booking): the shared booker runs with Summit's `Proceed`, Agent 2 and the client file's `project_document_type`. **Creator:** the Creator select's option texts are read before anything is selected; the creator must equal exactly one of them after stripping surrounding whitespace on both sides, case-sensitive, and that option is chosen as the page shows it; none or more than one is `WRITE_NOT_STARTED`, reason `CREATOR_UNKNOWN`, nothing selected (an option that repeats its label or shows a mangled apostrophe simply doesn't match; no repair). The check is shared with B1, whose `Perth Scheduling` is an option on both sites. **W1's recheck:** after the reopen, the Project Creator is read again; a Project Creator row proceeds only if it reads the same as at the peek, trimmed, else `WRITE_NOT_STARTED` before Create New Task opens (decisions, 4 Dec 2026; it replaced the previous-task recheck). **Documents name:** the upload keeps the PDF's own name; the W1 Documents block must show exactly that name or exactly the name with every `-` as `_`, and W2's Documents tab File must start with one of the two (after Submit a mismatch is `ACCURACY_BREACH`, as B1). Which form MySys shows for the agent's own upload is seen at the first watched run (S.4). **Body:** carried as the iframe read it (several lots included), the W1 Note read back exactly, the task detail's Notes whitespace-collapsed (B1's read-backs). A Note taken and stopped at W1 goes back under 9.13's rules (a `---` one by the Assignee Unlink since 27 Nov 2026); one not returned stays with Agent 2, and its ALERT "run stopped; Note not returned" carries the stop's reason (`reason=CREATOR_UNKNOWN`). `run --client summit` books up to `max_notes_per_run` Notes per run: 15 for the hourly runs (decisions, 27 Nov 2026, Summit cap 15), 1 for the first live runs. ### Return to the original assignee @@ -669,8 +669,10 @@ creator = "NH Sub Floor" [[company]] name = "Summit Projects" aliases = ["Summit Developments", "Summit Project"] -creator_rule = "previous_task" -# ... one [[company]] per table row; exactly one of creator / creator_rule +creator_rule = "project_creator" +agrees_with_any_row = true # (Joey, 4 Dec 2026) +# ... one [[company]] per table row; exactly one of creator / creator_rule; +# Summit New Homes: also_agrees = ["New Gen and EasyStart", "New Generation and EasyStart"] ``` ### Summit real data @@ -682,17 +684,17 @@ creator_rule = "previous_task" ### Summit testing and go-live **Offline (Claude, CI):** -- Fakes: `tests/fakes/` gains Summit-shaped Notes (fake sender domain, fake companies' rows, a fake long iframe body with a table and disclaimer). Tests prove: no Assign or other write before PROCEED (the guard history holds only read-only actions for an untouched Note); decide-only writes nothing; the take refuses a changed assignee; each return target (user, pool, `---` to the fallback, unknown name stays with an ALERT); the Creator from the table and from the previous task reaches the W1 form and every read-back; W1's recheck of the previous task; B1's runs and seam-2 expectations unchanged. -- Seam 1 for Summit (`tests/seam1/summit/`): fake fixture POs as B1's (fake text for both readers in a cases file, corrupt and image-only bytes built in the test; a fake-PDF generator only if a reader case needs real bytes, decided in the readers task) and their mutations, one case per row of the decision table, each alias, each company pair that disagrees, a previous-task project with only Compaction Test or Cancelled tasks, a Note title whose PO differs from the PDF's. **Zero false PROCEED.** +- Fakes: `tests/fakes/` gains Summit-shaped Notes (fake sender domain, fake companies' rows, a fake long iframe body with a table and disclaimer). Tests prove: no Assign or other write before PROCEED (the guard history holds only read-only actions for an untouched Note); decide-only writes nothing; the take refuses a changed assignee; each return target (user, pool, `---` to the fallback, unknown name stays with an ALERT); the Creator from the table and the Project Creator reaches the W1 form and every read-back; W1's recheck of the Project Creator; B1's runs and seam-2 expectations unchanged. +- Seam 1 for Summit (`tests/seam1/summit/`): fake fixture POs as B1's (fake text for both readers in a cases file, corrupt and image-only bytes built in the test; a fake-PDF generator only if a reader case needs real bytes, decided in the readers task) and their mutations, one case per row of the decision table, each alias, each company pair that disagrees, a Project Creator project with an empty or `---` Project Creator, each widening of 4 Dec 2026 and its near misses, a Cancelled duplicate search row, a Note title whose PO differs from the PDF's. **Zero false PROCEED.** - A change under `mysys/` or the booker is proven by the offline tests and `check.py`/CI, then the first live hourly run after Joey moves the `production` tag, checked against its run output; B1's seam 2 on the test site is no longer run (Joey, decisions, 3 Dec 2026). Summit itself has no seam 2. -**Real-PO seam (Claude, laptop only, `-m real_data`):** Joey saves Summit POs in `private/summit/pdfs/` (original file names; READY and ISSUED titles, at least one non-compaction PDF, one per creator kind where he can), with `private/summit/fixtures/cases.toml`: the Note title and body, the original assignee, the MySys lookup he copies by hand (search rows, Client Internal No., the Tasks table with each task's name, status and Task Creator) and the expected result. `false PROCEED: 0`, agreement per field and coverage reported. The 10 Nov live-lookup exception is not widened: Joey copies Summit lookups himself, or logs in himself with the agent account as that exception says. A worktree session can't write the main checkout's `private/` (the worktree isolation hook; it is not loosened for this): it drafts `cases.toml` in its own worktree's git-ignored `private/summit/fixtures/`, copies `private/summit/pdfs/` there from the main checkout (reading it is allowed), runs the seam with `SEAM1_PRIVATE_DIR=\private`, and gives Joey one paste-ready PowerShell line to copy the folder over by hand on the laptop, `Copy-Item -Recurse -Force \private\summit\fixtures \private\summit`, then reruns the seam without `SEAM1_PRIVATE_DIR` once he has; `/start-task` gives a session that writes private fixtures the same steps (friction log, 26 Nov 2026; decisions, 27 Nov 2026, friction rows). +**Real-PO seam (Claude, laptop only, `-m real_data`):** Joey saves Summit POs in `private/summit/pdfs/` (original file names; READY and ISSUED titles, at least one non-compaction PDF, one per creator kind where he can), with `private/summit/fixtures/cases.toml`: the Note title and body, the original assignee, the MySys lookup he copies by hand (search rows with their Status, Client Internal No., the Project Creator for a Project Creator row, the Tasks table with each task's name, status and Task Creator) and the expected result. `false PROCEED: 0`, agreement per field and coverage reported. The 10 Nov live-lookup exception is not widened: Joey copies Summit lookups himself, or logs in himself with the agent account as that exception says. A worktree session can't write the main checkout's `private/` (the worktree isolation hook; it is not loosened for this): it drafts `cases.toml` in its own worktree's git-ignored `private/summit/fixtures/`, copies `private/summit/pdfs/` there from the main checkout (reading it is allowed), runs the seam with `SEAM1_PRIVATE_DIR= \private`, and gives Joey one paste-ready PowerShell line to copy the folder over by hand on the laptop, `Copy-Item -Recurse -Force \private\summit\fixtures \private\summit`, then reruns the seam without `SEAM1_PRIVATE_DIR` once he has; `/start-task` gives a session that writes private fixtures the same steps (friction log, 26 Nov 2026; decisions, 27 Nov 2026, friction rows). **Screens not seen yet** (gap-map section 7): Joey screenshots them **by hand on live during his own Summit work** into `private/summit/`, or the first live run below checks them safely: | Screen | By hand (Joey, on live) | Otherwise caught by | |---|---|---| -| Creator select options on Summit projects (NH Sub Floor, Compactions, Alison Wells, a previous-task name) | open Create New Task on a few Summit projects, screenshot the open list, abandon | W1 before Submit (`WRITE_NOT_STARTED`) in a watched run | +| Creator select options on Summit projects (NH Sub Floor, Compactions, Alison Wells, a Project Creator name) | open Create New Task on a few Summit projects, screenshot the open list, abandon | W1 before Submit (`WRITE_NOT_STARTED`) in a watched run | | Documents file name with a `-`; Type of the row; Sale Office default | a past Summit task's Documents row and form | W1 read-back before Submit | | Locked/Unlocked after an Assign to Agent 2; Agent 2's My Notes lists it | after he assigns one by hand (before S.1) | the first watched run's stale read | | Note Pool count at Source + Unlocked + Pending | the footer | the spike (`MORE_PAGES`) | @@ -804,8 +806,8 @@ In this order. Any failure leaves **both** Notes untouched and prints one NOTE l | Case | case a or case b above, on both readers | `NOT_RECERTIFICATION` (new) when neither reader finds one; one reader only: `READERS_DISAGREE` | | Readers agree | company line, PO and case equal on both | `READERS_DISAGREE` | | PO number | PDF PO = Note A title's PO; its part before `/` = Note B's client ref | `PO_MISMATCH` | -| Company | Summit's company table: PDF company and title company known, project Company the same row | `COMPANY_UNKNOWN`, `COMPANY_MISMATCH` | -| Project | Summit's project rule (Client Ref No., Summit company, Client Internal No.) | `PROJECT_NOT_FOUND`, `PROJECT_AMBIGUOUS`; Client Internal No. differs: `UNEXPECTED_SCREEN` | +| Company | Summit's company table: PDF company and title company known, project Company the same row (Agent 2's widenings of 4 Dec 2026 don't apply: safe side, Joey to confirm) | `COMPANY_UNKNOWN`, `COMPANY_MISMATCH` | +| Project | Summit's project rule (Client Ref No., Summit company, Client Internal No.); a Cancelled search row still counts (Agent 2 drops it since 4 Dec 2026; safe side, Joey to confirm) | `PROJECT_NOT_FOUND`, `PROJECT_AMBIGUOUS`; Client Internal No. differs: `UNEXPECTED_SCREEN` | | Target tasks | each task the case needs (`Residential Analysis`; case a also `Site Classification & Footing Details`) is exactly one top-level task of that exact name, not Cancelled | `TASK_NOT_FOUND` (new) | | Variation button | each target task's header shows a **Variation** button (Joey: a missing one "will not happen") | `NO_VARIATION_BUTTON` (new) | | Stage owner | case a: the Site Classification task's Owner is `Punit Kerai` or `Lalji Valani` (Joey: "it will only be those 2 people. 100%"); its Variation's stage goes to that Owner | `OWNER_UNKNOWN` (new) | diff --git a/config/clients/summit.toml b/config/clients/summit.toml index edf4d504..7b3ae4bc 100644 --- a/config/clients/summit.toml +++ b/config/clients/summit.toml @@ -18,7 +18,10 @@ project_document_type = "Client Documents" # W2 Type, to confirm (S4) # The creator table: one [[company]] per row; exactly one of creator / # creator_rule. Names and aliases are compared trimmed and case-insensitive, -# whole name only; a name not here is COMPANY_UNKNOWN. +# whole name only; a name not here is COMPANY_UNKNOWN. creator_rule = +# "project_creator": the project window's Project Creator. also_agrees and +# agrees_with_any_row widen which title/PDF row agrees with a project of +# the row (Joey, 4 Dec 2026; SPEC.md -> Client 2, Company agrees). [[company]] name = "Summit Easystart" @@ -31,6 +34,7 @@ creator = "Compactions" [[company]] name = "Summit New Homes" +also_agrees = ["New Gen and EasyStart", "New Generation and EasyStart"] # the brand also agrees with a New Homes project (Joey, 4 Dec 2026) creator = "NH Sub Floor" [[company]] @@ -45,12 +49,13 @@ creator = "Alison Wells" # one L, as MySys spells her (Joey, 26 Nov [[company]] name = "Summit Projects" # MySys's spelling (Joey, 26 Nov 2026) aliases = ["Summit Developments", "Summit Project"] # Summit Project: the row's old name -creator_rule = "previous_task" +creator_rule = "project_creator" # (Joey, 4 Dec 2026; was previous_task) +agrees_with_any_row = true # any title/PDF row agrees with its project (Joey, 4 Dec 2026) [[company]] name = "Summit Renovations" # the company's new name (Joey, 24 Nov 2026) -creator_rule = "previous_task" +creator_rule = "project_creator" [[company]] name = "Summit Homes Display" -creator_rule = "previous_task" +creator_rule = "project_creator" diff --git a/docs/decisions.md b/docs/decisions.md index 8c67bf0f..43b9bc16 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -66,6 +66,19 @@ Source of truth for decisions behind `docs/intent.md`, `SPEC.md` (MVP) and `docs After `tasks/plan.md` is approved (the freeze point), add a dated entry here for every change to what the agent does in MySys or prints in its run output, and for anything that loosens a safety control, in the same commit as the `SPEC.md` changes (`tasks/plan.md` only when a task's plan changes; 5 Nov 2026). Tightening a dev-tooling rule needs only a clear commit message (24 Oct 2026, below). +## 4 Dec 2026 - Summit (Agent 2) missed POs: four rule changes (Joey, 4 Dec 2026, in session summit-missed-pos; loosens Summit's project and company controls and changes the creator it writes, as Joey decided) + +- **Why:** Joey listed Summit compaction-test POs that Agent 2 never booked; he booked them by hand on 4 Dec 2026. The diagnosis (the Mac Mini `runs.log` and a read-only live look; the real identifiers stay in `private/summit/missed-2026-12-04/`, laptop only) found three reasons, each repeated on every hourly run: `PROJECT_AMBIGUOUS` (a duplicate project with the same Client Ref No., Cancelled), `COMPANY_MISMATCH` (the "New Gen and EasyStart" brand on the title and PDF of a Summit New Homes project; a Summit Granny Flats PO on a Summit Projects project) and `CREATOR_UNKNOWN` (a Summit Renovations project under the previous-task rule). Joey chose the four rules below. +- **1. A Cancelled search row is dropped:** before the Client Ref No. match, Agent 2 drops every Projects search row whose Status cell (screen-map row 06) reads exactly `Cancelled` after trimming, as the Tasks table's Cancelled. One project left is the match; the Client Internal No. and company checks still apply; two live ones, or a second results page, stay `PROJECT_AMBIGUOUS`; only Cancelled ones is `PROJECT_NOT_FOUND`. A near spelling ("cancelled", "Cancelled Completed") is kept, so it still counts. A Status column not shown reads as empty: the row is kept. +- **2. The New Gen and EasyStart brand on a Summit New Homes project:** the Summit New Homes row gains `also_agrees = ["New Gen and EasyStart", "New Generation and EasyStart"]` (`config/clients/summit.toml`): a New Homes project agrees when the title and the PDF each read one of those names. The creator is the project row's, NH Sub Floor (the same as Summit Easystart's). "Summit Easystart" itself on a New Homes project, the brand on any other row's project, and Summit New Homes on a Summit Easystart project still mismatch. +- **3. The Project Creator replaces the previous task:** for Summit Projects, Summit Renovations and Summit Homes Display (`creator_rule = "project_creator"`, was `previous_task`), the creator is the project window's Project Creator (Client block, the text after `Project Creator:`, a link; screen-map row 07), trimmed. Empty or `---` is `CREATOR_UNKNOWN`. Joey chose this over "the latest task, Variations included" and over keeping tasks only. The driver reads it only when the client's project rule asks (Summit Agent 2; `ProjectRule.reads_project_creator`), at the peek and at W1's reopen; B1 and Agent 3 read nothing new. W1's recheck now compares the Project Creator read again with the decided one (was: the previous task's number and Task Creator); the `Proceed` carries it (`SummitProceed.project_creator`, replacing `previous_task_no` and `previous_task_creator`). +- **4. A Summit Projects project agrees with any title and PDF row:** `agrees_with_any_row = true` on the Summit Projects row; the title and PDF companies must still be in the table (`COMPANY_UNKNOWN` otherwise); the creator is the Project Creator (rule 3). +- **Safe side, Joey to confirm:** (a) the title and the PDF must still name the **same** table row as each other; only the project's row may differ under rules 2 and 4. All five missed cases have title and PDF on one row, so all would book. Taking Joey's "need not be on the same row" as title, PDF and project all free would also book a Summit Homes Group title with a Summit Granny Flats PDF on a Summit Projects project, or a brand title with a "Summit New Homes" PDF. (b) Agent 3 keeps its rules: a Cancelled search row still counts and the three names must agree on one row (Joey decided these for Agent 2's missed POs only; Agent 3 shares `match_project` and the company table, so it was pinned by tests). +- **Tests changed (this `test:` commit, CLAUDE.md Must never #8):** the seam-1 previous-task cases are replaced by Project Creator cases (a Summit Projects project by its alias and Summit Homes Display whatever its Tasks table holds; the same-pln-under-Summit-Projects case expects its Project Creator); `tests/test_client_profile.py`'s creator-table pin reads `project_creator`, and `previous_task` is now refused; `tests/test_summit_booking.py` drops its previous-task W1 tests (its new Project Creator W1 tests stand in their place). Two cases added in this branch's first `test:` commit now expect `COMPANY_MISMATCH` under (a). +- **Real-PO seam:** the three real Summit Projects cases in `private/summit/fixtures/cases.toml` expect the previous-task creator and carry no Project Creator, so they skip `CREATOR_UNKNOWN` until Joey copies each project's Project Creator into its lookup (and its expected creator). They are false skips, never a false PROCEED. +- **Not changed:** the hourly peek budget (an untouched skipped Note is still peeked every run; a separate follow-up). +- **Carried in:** `SPEC.md` -> Client 2 (Decision checks: Project, Company agrees, Creator; the identity paragraph; Creator table and its rule paragraphs; the Proceed; The take and the booking: W1's recheck; client file shape; Summit testing) and Agent 3 (Decision checks: Company, Project); the Project Creator paragraph also says where it is read (the hold re-check too, whose Agent 2 read drops Cancelled rows as well: a recent booking whose project was later Cancelled re-checks as not found, a HOLD_LOST alert, nothing written). `docs/screen-map.md` rows 06 and 07. `docs/ops-runbook.md` 3.5a (Summit's Task Creator by hand) and the W1 "project changed" alert line. + ## 4 Dec 2026 - SPEC tidy-ups: V2's PARTIAL_WRITE cases, no "As built" label left in Agent 3's separate run (PR 252 review, Nit 2, and an open review Nit against 2 Dec 2026, leaner process; changes no behaviour, loosens nothing) - **V2's alert kinds (PR 252 review, Nit 2):** SPEC's V2 said every failed read-back is `ACCURACY_BREACH`, but `mysys/variation.py` stops as `PARTIAL_WRITE` when the New Variation form doesn't close, the new Variation's details row isn't found once, or its detail window isn't as mapped or never readable. SPEC now says so. Both kinds stop with an ALERT and leave both Notes with Agent 3; only the alert's name differs. A wrong or missing value read back is still `ACCURACY_BREACH`. diff --git a/docs/ops-runbook.md b/docs/ops-runbook.md index c804954d..a2b3ad38 100644 --- a/docs/ops-runbook.md +++ b/docs/ops-runbook.md @@ -269,7 +269,7 @@ For a Note the agent left after the **Submit** click (step W2 to W5). The goal i 5. **Solved** (if the Note isn't Solved): untick **Send Email Notification**, then Status → **Solved**. 6. Leave the Note assigned to the agent. Once it is Solved, runs no longer stop on it. -**Summit:** the same steps, except: "None" in step 1 means give the Note back (3.4a); in step 2 the PO Number is the full PO number from the Note's title, the Task Creator is the creator table's for the project's company (`config/clients/summit.toml`; for a "previous task" company, the Task Creator of the project's highest-numbered task that is not a Compaction Test and not Cancelled), and the PDF's name may show a `-` as `_`; the Note stays with Agent 2 once Solved. +**Summit:** the same steps, except: "None" in step 1 means give the Note back (3.4a); in step 2 the PO Number is the full PO number from the Note's title, the Task Creator is the creator table's for the project's company (`config/clients/summit.toml`; for a Summit Projects, Summit Renovations or Summit Homes Display project, the project window's Project Creator; decisions, 4 Dec 2026), and the PDF's name may show a `-` as `_`; the Note stays with Agent 2 once Solved. ### 3.5b Finish an Agent 3 job by hand @@ -367,7 +367,7 @@ The username works the same way with `mysys_live_username`. For the test site, u - **Summit: "run stopped; Note not returned"** (often with a `reason=`, for example `reason=CREATOR_UNKNOWN`): Agent 2 took the Note, stopped before Submit and couldn't give it back. For a Note whose assignee was `---`, the agent's own Unlink (decisions, 27 Nov 2026) was refused or didn't read back: **first open the Note and read "Assignee:"**. If it already reads `---`, the Unlink worked and only its log check failed: the Note is back, nothing more to do in MySys, tell Joey. Nothing was submitted. Otherwise give it back by hand (3.4a); until then every Summit run stops at the start with the next detail. - **Summit: "a Note is still assigned to the agent from an earlier run"**: a Pending Note sits in Agent 2's My Notes. Either an earlier Summit run left it (above) or a person assigned a Note to Agent 2 by hand (nobody should, from go-live step S.1). Find it (3.3) and give it back (3.4a), or finish it (3.5) if a task was made. Then runs go on by themselves. - **Summit, step W1, `reason=CREATOR_UNKNOWN`** ("creator not an option"): the creator the table gives for the project's company isn't in that project's Creator list, so nothing was selected or submitted. Give the Note back if it is still with Agent 2 (3.4a), book the PO by hand if it is due, and tell Joey: the creator table (`config/clients/summit.toml`) or the project's Creator list has changed. The same Note will stop at W1 again on the next runs until it is fixed. - - **Summit, step W1, "project changed since the decision"**: for a "previous task" company, the project's tasks changed between the agent's read and W1. Nothing was submitted; the Note was given back (or, if `---`, see "Note not returned" above). The next run decides again. + - **Summit, step W1, "project changed since the decision"**: for a Summit Projects, Summit Renovations or Summit Homes Display project, its Project Creator changed between the agent's read and W1. Nothing was submitted; the Note was given back (or, if `---`, see "Note not returned" above). The next run decides again. - **Agent 3: "run stopped; Note not returned"**: Agent 3 took the job's two Notes, stopped before its first Submit and couldn't give one back (the `note_id` names it; both: Note A). Nothing was submitted. Open each Note and read "Assignee:": `---` is back. Otherwise give it back (3.4b); until then every Agent 3 run stops at the start with the next detail. - **Agent 3: "a Note is still assigned to the agent from an earlier run"**: a Pending Note sits in Agent 3's My Notes. Either an earlier Agent 3 run left the job (a partial write, or Notes not returned) or a person assigned a Note to Agent 3 by hand (nobody should, from go-live step V.1). Find the Notes (3.3, Agent 3): no Variation made, give them back (3.4b); one made, finish the job (3.5b). A Note assigned by hand goes back to whoever should have it. Then runs go on by themselves. - **Anything else** (for example "unexpected error (type=...)", "Note not found once"): nothing was submitted and the Note was handed back. Nothing to undo. If the alert has step W2 to W5, treat it as `PARTIAL_WRITE` (3.5). diff --git a/docs/screen-map.md b/docs/screen-map.md index a54f7501..50094a32 100644 --- a/docs/screen-map.md +++ b/docs/screen-map.md @@ -138,6 +138,7 @@ Projects (sub-tab, not Tasks) → type the internal number in **Search**. | link | "pln_10001" | `getByRole('link', { name: 'pln_10001' })` | Opens the project | **Read:** exactly one row; **Client Ref No.** = `2600001B`; **Company** = **B1 Homes**; **Address** = `Lot 123 (#45) Sample Lane Sampleville 6000 WA`. Footer "Page 1 of 1(1 Items)". +**Status** cell: Summit (Agent 2) drops a row reading exactly `Cancelled` (trimmed) before its Client Ref No. match (decisions, 4 Dec 2026; live showed a Cancelled duplicate project with the same Client Ref No.). B1 and Agent 3 don't read it. **No match:** see row 16. ### Row 07 · Project window @@ -148,7 +149,7 @@ Heading **"pln_10001 B1 Homes Sample Lane, Sampleville WA 6000"** (with a `Clien |---|---|---| | combobox | "-- Select Task --" | Only the placeholder until the project has tasks | | text | Title, Office, Created, Lodged By, **Client Internal No.**, Site Owner, **Address**, Estate, Shire, Latitude, Longitude; Soil block | Client Internal No. = `2600001B`; Address as in row 06 | -| link | "B1 Homes" (Project Company), ` ` (Project Creator) | | +| link | "B1 Homes" (Project Company), ` ` (Project Creator) | Client block: `strong` "Project Creator:" (its text in an inner element), the link beside it in the same list item. Summit (Agent 2) reads the text after the label as the creator of a Project Creator row (decisions, 4 Dec 2026); seen on the test site and on live Summit projects | | button | "Tasks", "Stages", "Log", "Communication", "Documents", "Notes" | Tasks is shown by default | | button | "Create New Task" | `getByRole('button', { name: 'Create New Task' })`: **the first write** | | table | columns Lodged By, Task Creator, Create, Office, Stage, Owner, Turn Around Time, Days to Complete, Due Date, Price, Status | Each task takes two rows (below) | diff --git a/src/po_agent/b1/decision.py b/src/po_agent/b1/decision.py index 2855d9e6..1ad52c5d 100644 --- a/src/po_agent/b1/decision.py +++ b/src/po_agent/b1/decision.py @@ -203,6 +203,7 @@ class B1ProjectRule: profile's site.""" site: Site + reads_project_creator: bool = False # B1 takes no creator from the project def match( self, rows: Sequence[SearchRow], more_pages: bool, internal_no: str diff --git a/src/po_agent/core/config.py b/src/po_agent/core/config.py index 614b3da8..15fd1829 100644 --- a/src/po_agent/core/config.py +++ b/src/po_agent/core/config.py @@ -155,13 +155,18 @@ def _not_blank(value: str) -> str: class Company(_Section): """One creator-table row (SPEC.md -> Client 2, Creator table): the row's - creator, or `previous_task` (the previous task's Task Creator), never - both.""" + creator, or `project_creator` (the project window's Project Creator), + never both. `also_agrees`: other rows' names that, on both the title and + the PDF, agree with a project of this row; `agrees_with_any_row`: a + project of this row agrees with any title and PDF row (Agent 2 only; + decisions, 4 Dec 2026).""" name: str aliases: tuple[str, ...] = () creator: str | None = Field(None, min_length=1) - creator_rule: Literal["previous_task"] | None = None + creator_rule: Literal["project_creator"] | None = None + also_agrees: tuple[str, ...] = () + agrees_with_any_row: StrictBool = False @field_validator("name", mode="after") @classmethod @@ -173,7 +178,7 @@ def _name_not_blank(cls, name: str) -> str: def _creator_not_blank(cls, creator: str | None) -> str | None: return None if creator is None else _not_blank(creator) - @field_validator("aliases", mode="after") + @field_validator("aliases", "also_agrees", mode="after") @classmethod def _aliases_not_blank(cls, aliases: tuple[str, ...]) -> tuple[str, ...]: return tuple(_not_blank(alias) for alias in aliases) @@ -224,6 +229,15 @@ def _names_unique(cls, companies: tuple[Company, ...]) -> tuple[Company, ...]: if _fold(name) in seen: raise ValueError("a company name or alias appears twice") seen.add(_fold(name)) + # Each also_agrees name names another row, once: a typo would only + # cost coverage, but is refused at load instead. + for company in companies: + own = {_fold(n) for n in (company.name, *company.aliases)} + also = [_fold(name) for name in company.also_agrees] + if len(set(also)) != len(also): + raise ValueError("an also_agrees name appears twice") + if any(name not in seen or name in own for name in also): + raise ValueError("an also_agrees name names no other row") return companies diff --git a/src/po_agent/core/models.py b/src/po_agent/core/models.py index 9f258dcc..96dba0fe 100644 --- a/src/po_agent/core/models.py +++ b/src/po_agent/core/models.py @@ -93,11 +93,14 @@ class OneIframeBody(Frozen): class SearchRow(Frozen): - """One Projects search row, cells as shown.""" + """One Projects search row, cells as shown. `status`: its Status cell + ("" when the column isn't shown); Summit's Agent 2 drops a Cancelled + row (decisions, 4 Dec 2026).""" pln: str client_ref_no: str company: str + status: str = "" COMPACTION_TEST = "Compaction Test" # MySys's task name (row 07) @@ -154,6 +157,9 @@ class MySysLookup(Frozen): more_pages: bool # a second results page exists project_internal_no: str = "" # the project's Client Internal No. address: str = "" # the project's one Address string, unparsed + # The Client block's Project Creator, read only for a rule that asks + # (ProjectRule.reads_project_creator: Summit's Agent 2, 4 Dec 2026). + project_creator: str = "" # Every task in table order (task 9.8); `tasks` are its Compaction Test # ones (B1's duplicate check), derived when left out. project_tasks: tuple[ProjectTask, ...] = () @@ -239,6 +245,11 @@ class ProjectRule(Protocol): """A client's project match rule (ADR-003 decision 3): `mysys/` reads the Projects search and the project, the client judges them.""" + @property + def reads_project_creator(self) -> bool: + """The project reads also fill `MySysLookup.project_creator`.""" + ... + def match( self, rows: Sequence[SearchRow], more_pages: bool, internal_no: str ) -> Skip | str: @@ -253,5 +264,5 @@ def judge(self, lookup: MySysLookup, internal_no: str) -> Skip | str: def recheck(self, lookup: MySysLookup, proceed: Proceed) -> bool: """W1's reopen: the opened project still gives what the decision took from it beyond its pln and Compaction Test tasks (Summit: a - previous-task row's task and Task Creator; B1: nothing more).""" + Project Creator row's Project Creator; B1: nothing more).""" ... diff --git a/src/po_agent/mysys/driver.py b/src/po_agent/mysys/driver.py index 8901728d..35c35541 100644 --- a/src/po_agent/mysys/driver.py +++ b/src/po_agent/mysys/driver.py @@ -1516,8 +1516,8 @@ def reopen_project( one decided: the client's `rule` matches the Proceed's pln, its judge of the opened project (Client Internal No. for B1) passes, the settled Compaction Test tasks are the Proceed's (none created meanwhile) and - the rule's recheck passes (Summit: a previous-task row's task and Task - Creator unchanged, task 9.14). Any mismatch -> WriteNotStarted.""" + the rule's recheck passes (Summit: a Project Creator row's Project + Creator unchanged, decisions 4 Dec 2026). Any mismatch -> WriteNotStarted.""" lookup, window = _lookup_and_window( guard, page, @@ -1630,6 +1630,8 @@ def _lookup_and_window( pln=row["Project No."], client_ref_no=row["Client Ref No."], company=row["Company"], + # Not shown: "", so the row is kept (Summit drops Cancelled). + status=row.get("Status", ""), ) for row in rows ) @@ -1654,6 +1656,11 @@ def _lookup_and_window( more_pages=more_pages, project_internal_no=booking.client_internal_no(project), address=_labelled(project, "Address:"), + # Row 07's Client block, only for a rule that takes its creator + # from it (Summit's Agent 2; decisions, 4 Dec 2026). + project_creator=( + _labelled(project, "Project Creator:") if rule.reads_project_creator else "" + ), project_tasks=project_tasks, variation_tasks=variation_tasks, ) diff --git a/src/po_agent/summit/client.py b/src/po_agent/summit/client.py index 20115c0c..ad7a39e1 100644 --- a/src/po_agent/summit/client.py +++ b/src/po_agent/summit/client.py @@ -73,7 +73,7 @@ def body_rule(self, file_name: str) -> OneIframeBody: return OneIframeBody() def project_rule(self) -> ProjectRule: - return decision.SummitProjectRule(self.profile.company) + return decision.SummitProjectRule.agent_2(self.profile.company) def decide( self, diff --git a/src/po_agent/summit/company.py b/src/po_agent/summit/company.py index dba3a11e..be6b5114 100644 --- a/src/po_agent/summit/company.py +++ b/src/po_agent/summit/company.py @@ -28,3 +28,19 @@ def row_for(name: str, table: Sequence[Company]) -> Company | None: if wanted in {fold(n) for n in (company.name, *company.aliases)}: return company return None + + +def agrees(title: str, pdf: str, project: Company, table: Sequence[Company]) -> bool: + """Agent 2's Company agrees check (SPEC.md -> Client 2, Decision checks; + decisions, 4 Dec 2026): the title's and the PDF's names name one table + row (safe side, Joey to confirm), and the project's row is that row, or + agrees with any row (Summit Projects), or lists both names in its + `also_agrees` (Summit New Homes and the New Gen and EasyStart brand).""" + title_row = row_for(title, table) + pdf_row = row_for(pdf, table) + if title_row is None or pdf_row is None or title_row.name != pdf_row.name: + return False + if project.name == title_row.name or project.agrees_with_any_row: + return True + also = {fold(name) for name in project.also_agrees} + return fold(title) in also and fold(pdf) in also diff --git a/src/po_agent/summit/decision.py b/src/po_agent/summit/decision.py index ed38aaca..7785e54f 100644 --- a/src/po_agent/summit/decision.py +++ b/src/po_agent/summit/decision.py @@ -7,14 +7,14 @@ (`reader_rules.check_pdf`, task 9.7); the PDF's PO against the Note title's; the title's and the PDF's company in the creator table; then the one project lookup: the project match and its Client Internal No., the -three companies on one table row, the duplicate check and the creator. +companies agreeing (`company.agrees`), the duplicate check and the creator. The first failing check decides; anything uncertain is a skip. No address check for Summit (decisions, 23 Nov 2026): the identity link is the PO. """ import re from collections.abc import Callable, Sequence -from dataclasses import dataclass +from dataclasses import dataclass, field from po_agent.b1.readers import PdfTexts from po_agent.core.config import Company @@ -23,20 +23,19 @@ MySysLookup, NoteSnapshot, Proceed, - ProjectTask, SearchRow, Skip, SkipReason, ) from po_agent.mysys.tasks import CANCELLED from po_agent.summit import reader_rules as rules -from po_agent.summit.company import fold, row_for +from po_agent.summit.company import agrees, fold, row_for from po_agent.summit.models import PO_PATTERN, SummitProceed # The title shape - - PO: - . _TITLE_COMPANY_END = " - " _TITLE_PO = re.compile(r"(? Skip | tuple[str, Company]: """The one project whose Client Ref No. (trimmed, any case) is `client_ref` and whose Company names a table row: its pln and that row. None -> PROJECT_NOT_FOUND; more than one, or a second page -> - PROJECT_AMBIGUOUS. The same row shown twice is one project.""" + PROJECT_AMBIGUOUS. The same row shown twice is one project. With + `drop_cancelled` (Agent 2; decisions, 4 Dec 2026) a row whose Status + reads exactly Cancelled, trimmed, is dropped first.""" wanted = fold(client_ref) found: dict[tuple[str, str], Company] = {} for row in rows: + if drop_cancelled and row.status.strip() == CANCELLED: + continue company = row_for(row.company, companies) if wanted and fold(row.client_ref_no) == wanted and company is not None: found[(row.pln, company.name)] = company @@ -83,14 +88,30 @@ class SummitProjectRule: """Summit's project match rule for the driver's project reads (the peek's lookup, the hold re-check, W1's reopen; core.models.ProjectRule): `match_project` on the creator table, then the opened project's Client - Internal No. equal to the Client Ref No. again.""" + Internal No. equal to the Client Ref No. again. Agent 2's rule + (`agent_2`) also drops Cancelled search rows and reads the Project + Creator (decisions, 4 Dec 2026); Agent 3's keeps both off (safe side, + Joey to confirm).""" companies: tuple[Company, ...] + drop_cancelled: bool = field(default=False, kw_only=True) + reads_project_creator: bool = field(default=False, kw_only=True) + + @classmethod + def agent_2(cls, companies: Sequence[Company]) -> "SummitProjectRule": + """Summit Agent 2's rule (SPEC.md -> Client 2, Decision checks).""" + return cls(tuple(companies), drop_cancelled=True, reads_project_creator=True) def match( self, rows: Sequence[SearchRow], more_pages: bool, internal_no: str ) -> Skip | str: - matched = match_project(rows, more_pages, internal_no, self.companies) + matched = match_project( + rows, + more_pages, + internal_no, + self.companies, + drop_cancelled=self.drop_cancelled, + ) return matched if isinstance(matched, Skip) else matched[0] def judge(self, lookup: MySysLookup, internal_no: str) -> Skip | str: @@ -103,39 +124,14 @@ def judge(self, lookup: MySysLookup, internal_no: str) -> Skip | str: def recheck(self, lookup: MySysLookup, proceed: Proceed) -> bool: """W1's reopen (task 9.14; SPEC: The take and the booking): for a - previous-task row, the same rule on the Tasks table read now must - give the same task number and Task Creator as at the peek. A fixed - creator's row takes nothing more from the project.""" + Project Creator row, the Project Creator read now, trimmed, must be + the one decided (decisions, 4 Dec 2026). A fixed creator's row takes + nothing more from the project.""" if not isinstance(proceed, SummitProceed): return False - if proceed.previous_task_no is None: + if proceed.project_creator is None: return True - found = previous_task(lookup.project_tasks) - return ( - not isinstance(found, Skip) - and found.task_no == proceed.previous_task_no - and found.task_creator.strip() == proceed.previous_task_creator - ) - - -def previous_task(tasks: Sequence[ProjectTask]) -> Skip | ProjectTask: - """The task with the highest task number whose name is not Compaction - Test and whose Status is not Cancelled, with a Task Creator. None, a - Task Creator empty or `---`, or that number shown twice with different - Task Creators -> CREATOR_UNKNOWN.""" - candidates = [ - task - for task in tasks - if task.name.strip() != COMPACTION_TEST and task.status.strip() != CANCELLED - ] - if not candidates: - return _skip(SkipReason.CREATOR_UNKNOWN) - top = max(int(task.task_no.removeprefix("tsk_")) for task in candidates) - at_top = [t for t in candidates if int(t.task_no.removeprefix("tsk_")) == top] - creators = {task.task_creator.strip() for task in at_top} - if len(creators) != 1 or creators & set(_NO_CREATOR): - return _skip(SkipReason.CREATOR_UNKNOWN) - return at_top[0] + return lookup.project_creator.strip() == proceed.project_creator def is_duplicate(found: MySysLookup) -> bool: @@ -185,25 +181,30 @@ def decide( client_ref = reading.po_number.split("/")[0] found = lookup() - matched = match_project(found.search_rows, found.more_pages, client_ref, companies) + matched = match_project( + found.search_rows, + found.more_pages, + client_ref, + companies, + drop_cancelled=True, # Agent 2 (decisions, 4 Dec 2026) + ) if isinstance(matched, Skip): return matched pln, project_row = matched if fold(found.project_internal_no) != fold(client_ref): return _skip(SkipReason.UNEXPECTED_SCREEN) - if not title_row.name == pdf_row.name == project_row.name: + if not agrees(title_company, reading.company, project_row, companies): return _skip(SkipReason.COMPANY_MISMATCH) if is_duplicate(found): return _skip(SkipReason.DUPLICATE_TASK) - previous: ProjectTask | None = None + project_creator: str | None = None creator = project_row.creator - if project_row.creator_rule == "previous_task": - found_previous = previous_task(found.project_tasks) - if isinstance(found_previous, Skip): - return found_previous - previous = found_previous - creator = previous.task_creator.strip() + if project_row.creator_rule == "project_creator": + project_creator = found.project_creator.strip() + if project_creator in _NO_CREATOR: + return _skip(SkipReason.CREATOR_UNKNOWN) + creator = project_creator if creator is None: # the client file holds exactly one of the two return _skip(SkipReason.CREATOR_UNKNOWN) return SummitProceed( @@ -217,6 +218,5 @@ def decide( existing_task_nos=tuple(task.task_no for task in found.tasks), creator=creator, original_assignee=original_assignee, - previous_task_no=None if previous is None else previous.task_no, - previous_task_creator=None if previous is None else creator, + project_creator=project_creator, ) diff --git a/src/po_agent/summit/models.py b/src/po_agent/summit/models.py index cb045159..a507d73b 100644 --- a/src/po_agent/summit/models.py +++ b/src/po_agent/summit/models.py @@ -24,16 +24,14 @@ def filed_names(file_name: str) -> tuple[str, ...]: class SummitProceed(Proceed): """Summit's step 11: the shared `Proceed` with Summit's PO checked again, the Note's original assignee (the take's recheck and the return, 9.13) - and, for a previous-task row, the previous task's number and Task - Creator (W1's recheck, 9.14), so a malformed decision can't reach a - write.""" + and, for a Project Creator row, the Project Creator (W1's recheck; + decisions, 4 Dec 2026), so a malformed decision can't reach a write.""" internal_no: str = Field(pattern=r"^[0-9]+$") # the Client Ref No. po_number: str = Field(pattern=PO_PATTERN) pdf_file_name: str = Field(pattern=r"^.+\.(?i:pdf)$") original_assignee: str = Field(min_length=1) - previous_task_no: str | None = Field(None, pattern=r"^tsk_[0-9]+$") - previous_task_creator: str | None = None + project_creator: str | None = None @property def document_names(self) -> tuple[str, ...]: @@ -48,8 +46,6 @@ def _consistent(self) -> Self: raise ValueError("blank original assignee") if self.creator.strip() in ("", "---"): raise ValueError("creator names nobody") - if (self.previous_task_no is None) != (self.previous_task_creator is None): - raise ValueError("previous task number and creator go together") - if self.previous_task_creator not in (None, self.creator): - raise ValueError("creator is not the previous task's Task Creator") + if self.project_creator not in (None, self.creator): + raise ValueError("creator is not the Project Creator") return self diff --git a/tests/seam1/summit/decide_cases.toml b/tests/seam1/summit/decide_cases.toml index 856b9ba9..e26d1e6e 100644 --- a/tests/seam1/summit/decide_cases.toml +++ b/tests/seam1/summit/decide_cases.toml @@ -12,11 +12,14 @@ # - title, attachments, linked replace the Note's; # - pdf_replace / plumber_replace / pypdf_replace / empty change the PDF # text as in reader_cases.toml; -# - search_rows, more_pages, internal_no, project_tasks replace the lookup's. +# - search_rows, more_pages, internal_no, project_tasks replace the lookup's +# (a search row's status: its Status cell, "" when left out); +# - project_creator is the project window's Project Creator (left out: not +# read, the lookup's empty default). # # expect_skip is decide()'s skip reason. Without it, the case PROCEEDs with -# expect_pln, expect_po, expect_creator, expect_previous_task (only on a -# previous-task row) and expect_task_nos (the Compaction Test task numbers +# expect_pln, expect_po, expect_creator, expect_project_creator (true on a Project Creator row: +# the Proceed carries it for W1's recheck) and expect_task_nos (the Compaction Test task numbers # W2 needs; [] when left out). All written out from SPEC, never computed. [note] @@ -127,13 +130,15 @@ expect_pln = "pln_20001" expect_po = "123456/020/01" expect_creator = "Alison Wells" -# --- Creator: previous task (highest number, not Compaction Test, not Cancelled) --- +# --- Creator: the Project Creator, not the previous task (Joey, 4 Dec 2026; +# replaces the previous-task rule of 23 and 26 Nov 2026) --- [[case]] -id = "previous-task-project-by-its-alias" +id = "project-creator-project-by-its-alias" title = "Summit Developments - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" pdf_replace = [["Summit Homes Group\nPurchase", "Summit Developments\nPurchase"]] search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = "Fake Project Creator" project_tasks = [ { task_no = "tsk_300001", name = "Site Start", status = "Complete", task_creator = "Fake Staff One" }, { task_no = "tsk_300005", name = "Frame Inspection", status = "New Project", task_creator = "Fake Staff Five" }, @@ -141,91 +146,26 @@ project_tasks = [ ] expect_pln = "pln_20001" expect_po = "123456/020/01" -expect_creator = "Fake Staff Five" -expect_previous_task = "tsk_300005" +expect_creator = "Fake Project Creator" +expect_project_creator = true [[case]] -id = "previous-task-by-number-not-text" -title = "Summit Renovations - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" -pdf_replace = [["Summit Homes Group\nPurchase", "Summit Renovations\nPurchase"]] -search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Renovations" }] -project_tasks = [ - { task_no = "tsk_100000", name = "Site Start", status = "Complete", task_creator = "Fake Staff Ten" }, - { task_no = "tsk_99999", name = "Slab Inspection", status = "Complete", task_creator = "Fake Staff Nine" }, -] -expect_pln = "pln_20001" -expect_po = "123456/020/01" -expect_creator = "Fake Staff Ten" -expect_previous_task = "tsk_100000" - -[[case]] -id = "previous-task-skips-cancelled-and-compaction" +id = "project-creator-whatever-the-tasks-hold" title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] +project_creator = "Fake Project Creator" project_tasks = [ - { task_no = "tsk_300004", name = "Site Start", status = "Complete", task_creator = "Fake Staff Four" }, - { task_no = "tsk_300009", name = "Frame Inspection", status = "Cancelled", task_creator = "Fake Staff Nine" }, + { task_no = "tsk_300004", name = "Site Start", status = "Cancelled", task_creator = "Fake Staff Four" }, + { task_no = "tsk_300009", name = "Frame Inspection", status = "Complete", task_creator = " --- " }, { task_no = "tsk_300010", name = "Compaction Test", status = "Cancelled", task_creator = "Compactions" }, ] expect_pln = "pln_20001" expect_po = "123456/020/01" -expect_creator = "Fake Staff Four" -expect_previous_task = "tsk_300004" +expect_creator = "Fake Project Creator" +expect_project_creator = true expect_task_nos = ["tsk_300010"] -[[case]] -id = "previous-task-none" -title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" -pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] -search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] -project_tasks = [] -expect_skip = "CREATOR_UNKNOWN" - -[[case]] -id = "previous-task-only-compaction-or-cancelled" -title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" -pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] -search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] -project_tasks = [ - { task_no = "tsk_300004", name = "Site Start", status = "Cancelled", task_creator = "Fake Staff Four" }, - { task_no = "tsk_300010", name = "Compaction Test", status = "Cancelled", task_creator = "Compactions" }, -] -expect_skip = "CREATOR_UNKNOWN" - -[[case]] -id = "previous-task-creator-empty" -title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" -pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] -search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] -project_tasks = [ - { task_no = "tsk_300004", name = "Site Start", status = "Complete", task_creator = "Fake Staff Four" }, - { task_no = "tsk_300009", name = "Frame Inspection", status = "", task_creator = "" }, -] -expect_skip = "CREATOR_UNKNOWN" - -[[case]] -id = "previous-task-creator-dashes" -title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" -pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] -search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] -project_tasks = [ - { task_no = "tsk_300004", name = "Site Start", status = "Complete", task_creator = "Fake Staff Four" }, - { task_no = "tsk_300009", name = "Frame Inspection", status = "Complete", task_creator = " --- " }, -] -expect_skip = "CREATOR_UNKNOWN" - -[[case]] -id = "previous-task-number-twice-two-creators" -title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" -pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] -search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] -project_tasks = [ - { task_no = "tsk_300009", name = "Frame Inspection", status = "Complete", task_creator = "Fake Staff Nine" }, - { task_no = "tsk_300009", name = "Frame Inspection", status = "Complete", task_creator = "Fake Staff Eight" }, -] -expect_skip = "CREATOR_UNKNOWN" - # --- Note checks, before the PDF is read --- [[case]] @@ -448,10 +388,11 @@ id = "project-company-summit-projects" title = "Summit Developments - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" pdf_replace = [["Summit Homes Group\nPurchase", "Summit Developments\nPurchase"]] search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = "Fake Project Creator" expect_pln = "pln_20001" expect_po = "123456/020/01" -expect_creator = "Fake Staff One" -expect_previous_task = "tsk_300001" +expect_creator = "Fake Project Creator" +expect_project_creator = true [[case]] id = "project-company-summit-south-west" @@ -468,3 +409,253 @@ title = "Summit SouthWest - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - RE pdf_replace = [["Summit Homes Group\nPurchase", "Summit SouthWest\nPurchase"]] search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit North West" }] expect_skip = "PROJECT_NOT_FOUND" + +# --- Project: a Cancelled search row is dropped before the Client Ref No. +# match (Joey, 4 Dec 2026; the search row's Status cell, screen-map row 06, +# exactly "Cancelled" after trimming, as the Tasks table's) --- + +[[case]] +id = "project-cancelled-twin-dropped" +search_rows = [ + { pln = "pln_20009", client_ref_no = "123456", company = "Summit Homes Group", status = "Cancelled" }, + { pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, +] +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Compactions" + +[[case]] +id = "project-cancelled-twin-under-another-row-dropped" +search_rows = [ + { pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group", status = "" }, + { pln = "pln_20009", client_ref_no = "123456", company = "Summit New Homes", status = " Cancelled " }, +] +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Compactions" + +[[case]] +id = "project-only-a-cancelled-one" +search_rows = [{ pln = "pln_20009", client_ref_no = "123456", company = "Summit Homes Group", status = "Cancelled" }] +expect_skip = "PROJECT_NOT_FOUND" + +[[case]] +id = "project-two-live-and-a-cancelled-one" +search_rows = [ + { pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, + { pln = "pln_20002", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, + { pln = "pln_20009", client_ref_no = "123456", company = "Summit Homes Group", status = "Cancelled" }, +] +expect_skip = "PROJECT_AMBIGUOUS" + +[[case]] +id = "project-status-only-near-cancelled-is-kept" +search_rows = [ + { pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, + { pln = "pln_20009", client_ref_no = "123456", company = "Summit Homes Group", status = "cancelled" }, +] +expect_skip = "PROJECT_AMBIGUOUS" + +[[case]] +id = "project-status-cancelled-with-more-text-is-kept" +search_rows = [ + { pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, + { pln = "pln_20009", client_ref_no = "123456", company = "Summit Homes Group", status = "Cancelled Completed" }, +] +expect_skip = "PROJECT_AMBIGUOUS" + +[[case]] +id = "project-cancelled-row-and-a-second-page" +more_pages = true +search_rows = [ + { pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, + { pln = "pln_20009", client_ref_no = "123456", company = "Summit Homes Group", status = "Cancelled" }, +] +expect_skip = "PROJECT_AMBIGUOUS" + +# --- Company agrees: the New Gen and EasyStart brand also agrees with a +# Summit New Homes project (Joey, 4 Dec 2026); the creator is the project +# row's --- + +[[case]] +id = "brand-on-a-new-homes-project" +title = "New Gen and EasyStart - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "New Gen and EasyStart\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit New Homes" }] +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "NH Sub Floor" + +[[case]] +id = "older-brand-title-on-a-new-homes-project" +title = "new generation and easystart - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "New Gen and EasyStart\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "SUMMIT NEW HOMES" }] +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "NH Sub Floor" + +[[case]] +id = "brand-title-new-homes-pdf-on-a-new-homes-project" +title = "New Gen and EasyStart - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit New Homes\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit New Homes" }] +# Safe side, Joey to confirm (decisions, 4 Dec 2026): title and PDF still +# name one row (here Summit Easystart and Summit New Homes). +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "easystart-row-name-on-a-new-homes-project" +title = "Summit Easystart - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Easystart\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit New Homes" }] +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "brand-title-easystart-pdf-on-a-new-homes-project" +title = "New Gen and EasyStart - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Easystart\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit New Homes" }] +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "brand-on-a-homes-group-project" +title = "New Gen and EasyStart - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "New Gen and EasyStart\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Group" }] +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "new-homes-on-an-easystart-project" +title = "Summit New Homes - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit New Homes\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Easystart" }] +expect_skip = "COMPANY_MISMATCH" + +# --- Company agrees: a Summit Projects project agrees with any title and +# PDF company in the table (Joey, 4 Dec 2026); creator = its Project +# Creator --- + +[[case]] +id = "granny-flats-on-a-summit-projects-project" +title = "Summit Granny Flats - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Granny Flats\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = "Fake Project Creator" +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Fake Project Creator" +expect_project_creator = true + +[[case]] +id = "summit-projects-title-and-pdf-on-two-other-rows" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Granny Flats\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = "Fake Project Creator" +# Safe side, Joey to confirm (decisions, 4 Dec 2026): title and PDF still +# name one row (here Summit Homes Group and Summit Granny Flats). +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "summit-projects-title-and-pdf-on-one-other-row" +title = "Summit Homes Group - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = "Fake Project Creator" +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Fake Project Creator" +expect_project_creator = true + +[[case]] +id = "summit-projects-title-not-in-table" +title = "Fake Builders - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = "Fake Project Creator" +expect_skip = "COMPANY_UNKNOWN" + +[[case]] +id = "summit-projects-names-on-a-granny-flats-project" +title = "Summit Developments - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Projects\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Granny Flats" }] +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "granny-flats-on-a-renovations-project" +title = "Summit Granny Flats - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Granny Flats\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Renovations" }] +project_creator = "Fake Project Creator" +expect_skip = "COMPANY_MISMATCH" + +# --- Creator: the Project Creator (project window, Client block) for +# Summit Projects, Summit Renovations and Summit Homes Display (Joey, 4 Dec +# 2026), whatever the Tasks table holds --- + +[[case]] +id = "project-creator-renovations-not-the-latest-task" +title = "Summit Renovations - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Renovations\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Renovations" }] +project_creator = "Fake Project Creator" +project_tasks = [ + { task_no = "tsk_300001", name = "Site Start", status = "Complete", task_creator = "Fake Staff One" }, + { task_no = "tsk_300005", name = "Frame Inspection", status = "New Project", task_creator = "Fake Staff Five" }, +] +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Fake Project Creator" +expect_project_creator = true + +[[case]] +id = "project-creator-display-without-other-tasks" +title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] +project_creator = "Fake Project Creator" +project_tasks = [] +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Fake Project Creator" +expect_project_creator = true + +[[case]] +id = "project-creator-trimmed" +title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] +project_creator = " Fake Project Creator " +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Fake Project Creator" +expect_project_creator = true + +[[case]] +id = "project-creator-empty" +title = "Summit Homes Display - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Homes Display\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Homes Display" }] +project_creator = " " +expect_skip = "CREATOR_UNKNOWN" + +[[case]] +id = "project-creator-dashes" +title = "Summit Projects - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Projects\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Projects" }] +project_creator = " --- " +expect_skip = "CREATOR_UNKNOWN" + +[[case]] +id = "project-creator-not-read" +title = "Summit Renovations - Lot 1 Fake Street Fakeville - PO: 123456/020/01 - READY" +pdf_replace = [["Summit Homes Group\nPurchase", "Summit Renovations\nPurchase"]] +search_rows = [{ pln = "pln_20001", client_ref_no = "123456", company = "Summit Renovations" }] +expect_skip = "CREATOR_UNKNOWN" + +[[case]] +id = "fixed-creator-row-ignores-the-project-creator" +project_creator = "Fake Project Creator" +expect_pln = "pln_20001" +expect_po = "123456/020/01" +expect_creator = "Compactions" diff --git a/tests/seam1/summit/test_summit_decide.py b/tests/seam1/summit/test_summit_decide.py index 7bbdd8ce..9daa4f12 100644 --- a/tests/seam1/summit/test_summit_decide.py +++ b/tests/seam1/summit/test_summit_decide.py @@ -84,7 +84,14 @@ def note_of(case: dict[str, Any]) -> NoteSnapshot: def lookup_of(case: dict[str, Any]) -> MySysLookup: base = _RAW["lookup"] + # The Project Creator only where a case reads it (else the default ""). + read = ( + {"project_creator": case["project_creator"]} + if "project_creator" in case + else {} + ) return MySysLookup( + **read, search_rows=tuple( SearchRow(**row) for row in case.get("search_rows", base["search_rows"]) ), @@ -133,10 +140,8 @@ def test_summit_decide_case(case: dict[str, Any]) -> None: assert result.internal_no == case["expect_po"].split("/")[0] assert result.creator == case["expect_creator"] assert result.existing_task_nos == tuple(case.get("expect_task_nos", [])) - previous = case.get("expect_previous_task") - assert result.previous_task_no == previous - assert result.previous_task_creator == ( - case["expect_creator"] if previous else None + assert result.project_creator == ( + case["expect_creator"] if case.get("expect_project_creator") else None ) diff --git a/tests/seam1/summit_variation/decide_cases.toml b/tests/seam1/summit_variation/decide_cases.toml index 1af13eb8..557b868a 100644 --- a/tests/seam1/summit_variation/decide_cases.toml +++ b/tests/seam1/summit_variation/decide_cases.toml @@ -336,8 +336,33 @@ id = "project-company-another-row" search_rows = [{ pln = "pln_30001", client_ref_no = "123456", company = "Summit New Homes" }] expect_skip = "COMPANY_MISMATCH" +# Summit's 4 Dec 2026 widenings are Agent 2's only (safe side, Joey to +# confirm): for Agent 3 the three names still agree on one row. + +[[case]] +id = "brand-on-a-new-homes-project-still-mismatches" +title = "New Gen and EasyStart - Lot 1 Fake Street Fakeville - PO: 123456/020/03 - READY" +pdf_replace = [["Summit Homes Group\n", "New Gen and EasyStart\n"]] +search_rows = [{ pln = "pln_30001", client_ref_no = "123456", company = "Summit New Homes" }] +expect_skip = "COMPANY_MISMATCH" + +[[case]] +id = "granny-flats-on-a-summit-projects-project-still-mismatches" +title = "Summit Granny Flats - Lot 1 Fake Street Fakeville - PO: 123456/020/03 - READY" +pdf_replace = [["Summit Homes Group\n", "Summit Granny Flats\n"]] +search_rows = [{ pln = "pln_30001", client_ref_no = "123456", company = "Summit Projects" }] +expect_skip = "COMPANY_MISMATCH" + # --- Project: Summit's rule (Client Ref No., Summit company, Client Internal No.) --- +[[case]] +id = "a-cancelled-twin-still-counts" +search_rows = [ + { pln = "pln_30009", client_ref_no = "123456", company = "Summit Homes Group", status = "Cancelled" }, + { pln = "pln_30001", client_ref_no = "123456", company = "Summit Homes Group", status = "Active" }, +] +expect_skip = "PROJECT_AMBIGUOUS" + [[case]] id = "no-project" search_rows = [] diff --git a/tests/test_client_profile.py b/tests/test_client_profile.py index 3f414fe5..dabcb809 100644 --- a/tests/test_client_profile.py +++ b/tests/test_client_profile.py @@ -19,7 +19,8 @@ ROOT = Path(__file__).resolve().parent.parent SUMMIT_TOML = ROOT / "config" / "clients" / "summit.toml" -# SPEC.md -> Creator table, with Joey's corrections of 24, 25 and 26 Nov 2026: +# SPEC.md -> Creator table, with Joey's corrections of 24, 25 and 26 Nov 2026 +# and 4 Dec 2026 (the Project Creator replaces the previous task): # (name, aliases, creator, creator_rule), in the table's order. SPEC_CREATOR_TABLE = [ ( @@ -36,10 +37,10 @@ "Summit Projects", ("Summit Developments", "Summit Project"), None, - "previous_task", + "project_creator", ), - ("Summit Renovations", (), None, "previous_task"), - ("Summit Homes Display", (), None, "previous_task"), + ("Summit Renovations", (), None, "project_creator"), + ("Summit Homes Display", (), None, "project_creator"), ] @@ -125,7 +126,7 @@ def test_the_profile_is_frozen(): def test_a_company_with_both_creator_and_creator_rule_is_refused(): - error = refused(with_company(0, creator_rule="previous_task")) + error = refused(with_company(0, creator_rule="project_creator")) assert "company" in str(error) @@ -136,11 +137,13 @@ def test_a_company_with_neither_creator_nor_creator_rule_is_refused(): assert "company" in str(error) -def test_a_creator_rule_other_than_previous_task_is_refused(): - error = refused(with_company(5, creator_rule="first_task")) +@pytest.mark.parametrize("rule", ["first_task", "previous_task"]) +def test_a_creator_rule_other_than_project_creator_is_refused(rule): + # previous_task was replaced by project_creator (decisions, 4 Dec 2026). + error = refused(with_company(5, creator_rule=rule)) assert "company" in str(error) - assert "first_task" not in str(error) + assert rule not in str(error) @pytest.mark.parametrize( @@ -220,6 +223,51 @@ def test_bad_values_are_refused(changes): refused(with_changes(**changes)) +# --- Joey's company widenings, 4 Dec 2026 ---------------------------------------- + + +def test_the_committed_file_widens_only_new_homes_and_summit_projects(): + profile = load_client("summit", "live") + + widened = { + company.name: (company.also_agrees, company.agrees_with_any_row) + for company in profile.company + if company.also_agrees or company.agrees_with_any_row + } + assert widened == { + "Summit New Homes": ( + ("New Gen and EasyStart", "New Generation and EasyStart"), + False, + ), + "Summit Projects": ((), True), + } + + +@pytest.mark.parametrize( + "also", + [ + ["Fake Builders"], # names no row + ["summit new homes"], # its own row's name + ["New Gen and EasyStart", "new gen and easystart "], # twice + ], + ids=["no-row", "own-row", "twice"], +) +def test_also_agrees_must_name_another_row_once(also): + error = refused(with_company(2, also_agrees=also)) + + assert "company" in str(error) + + +@pytest.mark.parametrize("value", ["", " "]) +def test_a_blank_also_agrees_name_is_refused(value): + refused(with_company(2, also_agrees=[value])) + + +@pytest.mark.parametrize("value", ["true", 1]) +def test_agrees_with_any_row_must_be_a_bool(value): + refused(with_company(5, agrees_with_any_row=value)) + + # --- loading ----------------------------------------------------------------- diff --git a/tests/test_summit_booking.py b/tests/test_summit_booking.py index 4a4d653e..1c07c1d7 100644 --- a/tests/test_summit_booking.py +++ b/tests/test_summit_booking.py @@ -9,12 +9,12 @@ local HTML file that is base_url, as tests/test_booker_offline.py): W1's reopen and Create New Task, W2's Submit and read-backs, with a Summit Proceed from Summit's own decision engine (never built by hand). The - decided creator, from the table or from the previous task, reaches the + decided creator, from the table or the Project Creator, reaches the form and every read-back; the Creator options are read before anything is selected and the creator must be exactly one of them, surrounding whitespace stripped, case-sensitive, else WRITE_NOT_STARTED / - CREATOR_UNKNOWN with nothing selected; W1's reopen re-applies the - previous-task rule and needs the same task and Task Creator; the + CREATOR_UNKNOWN with nothing selected; W1's reopen reads the Project + Creator again and needs the same value (decisions, 4 Dec 2026); the Documents name is the PDF's or that name with every "-" filed as "_", nothing else; the long body is read back whitespace-collapsed on the task detail. Only `driver.search_note` (W1's assignee check) is faked. @@ -77,18 +77,14 @@ # A fake PDF name holding "-": S.0 saw MySys file a staff upload's "-" as "_". FILE = "PO-123456-020-01-READY.pdf" FILED = "PO_123456_020_01_READY.pdf" # every "-" as "_" -# SPEC -> Creator table: Summit Homes Group's creator is Compactions; -# Summit Renovations' is the previous task's Task Creator. +# SPEC -> Creator table: Summit Homes Group's creator is Compactions. TABLE_COMPANY, TABLE_CREATOR = "Summit Homes Group", "Compactions" -PREVIOUS_COMPANY = "Summit Renovations" # The project's tasks: a Cancelled Compaction Test (it doesn't block a -# Summit booking, decisions 25 Nov 2026) and two other tasks. The previous -# task is the highest-numbered one not Compaction Test and not Cancelled. +# Summit booking, decisions 25 Nov 2026) and two other tasks. CANCELLED = ("tsk_200001", "Compaction Test", "Fake Staff One", "Cancelled") SITE_START = ("tsk_300001", "Site Start", "Fake Staff One", "Complete") ENGINEERING = ("tsk_300002", "Engineering", "Fake Staff Two", "Active") TASKS = [CANCELLED, SITE_START, ENGINEERING] -PREVIOUS_CREATOR = "Fake Staff Two" # The Creator options a Summit project offers (fake staff, the two # creators); the select opens at the Project Creator (S.0). CREATORS = ("Compactions", "NH Sub Floor", "Fake Staff One", "Fake Staff Two") @@ -153,6 +149,8 @@ def summit_mysys( doc_file: str | None = None, doc_late: str | None = None, toggle_heading: bool = False, + project_creator: str = "Fake Project Creator", + cancelled_twin: bool = False, ) -> str: """base_url after login: the Project menu, the Projects panel, the project window (rows 06-07, 26) and Create New Task (rows 08-09), laid @@ -171,7 +169,10 @@ def summit_mysys( shows its heading first with nothing under it, "header" its table's header row first (live 3 Dec 2026: W2 read the tab before the row showed). `toggle_heading` marks each section's Document Actions as a - heading too (not mapped; PR 259 review).""" + heading too (not mapped; PR 259 review). The project window's Client + block shows `project_creator` as its Project Creator (row 07). With + `cancelled_twin` the search also lists a Cancelled project with the same + Client Ref No. and company before it (decisions, 4 Dec 2026).""" compaction = [t for t in tasks if t[1] == "Compaction Test"] options = "".join( f"" for task_no, *_ in compaction @@ -186,6 +187,7 @@ def summit_mysys( "docLate": doc_late, "toggleHeading": toggle_heading, "company": company, + "cancelledTwin": cancelled_twin, } ) return f""" @@ -210,6 +212,9 @@ def summit_mysys( +
- Lodged By: <project lodger>
- Client Internal No.: {CLIENT_REF}
- Address: Lot 1 Fake Street Fakeville 6000 WA
Client
++
- Project Company: {company}
- Project Creator: {project_creator}
@@ -251,7 +256,10 @@ def summit_mysys( if (text !== '{CLIENT_REF}') return; setTimeout(() => {{ byId('none').hidden = true; - byId('rows').innerHTML = + const twin = FAKE.cancelledTwin + ? '' + : ''; + byId('rows').innerHTML = twin + ' pln_20009 {CLIENT_REF} Cancelled ' + FAKE.company + ' '; byId('footer').textContent = 'Page 1 of 1(1 Items)'; @@ -394,8 +402,10 @@ def fake(guard, page, base_url, username, password, note_id): monkeypatch.setattr(driver, "search_note", fake) -def lookup_of(company: str, tasks) -> MySysLookup: +def lookup_of(company: str, tasks, project_creator: str | None = None) -> MySysLookup: + read = {} if project_creator is None else {"project_creator": project_creator} return MySysLookup( + **read, search_rows=(SearchRow(pln=PLN, client_ref_no=CLIENT_REF, company=company),), more_pages=False, project_internal_no=CLIENT_REF, @@ -406,7 +416,9 @@ def lookup_of(company: str, tasks) -> MySysLookup: ) -def proceed_for(company: str, tasks=TASKS) -> SummitProceed: +def proceed_for( + company: str, tasks=TASKS, project_creator: str | None = None +) -> SummitProceed: """Summit's decision engine on a fake Note, PDF and project lookup (the peek's reads), with the committed creator table.""" snapshot = NoteSnapshot( @@ -421,7 +433,7 @@ def proceed_for(company: str, tasks=TASKS) -> SummitProceed: snapshot, "---", readers.read(summit_pdf(PO, company)), - lambda: lookup_of(company, tasks), + lambda: lookup_of(company, tasks, project_creator), companies=load_client("summit", "live", CONFIG_DIR).company, ) assert isinstance(decision, SummitProceed) @@ -444,7 +456,7 @@ def run_book(served, guard, proceed, folder, stop_after="W2") -> str | None: login=login, controls=gate, agent=AGENT, - project_rule=SummitProjectRule( + project_rule=SummitProjectRule.agent_2( load_client("summit", "live", CONFIG_DIR).company ), document_type="Client Documents", @@ -465,14 +477,11 @@ def booked(page: Page) -> dict: # --- the decided creator reaches the form and every read-back ----------------- -@pytest.mark.parametrize( - ("company", "creator"), - [(TABLE_COMPANY, TABLE_CREATOR), (PREVIOUS_COMPANY, PREVIOUS_CREATOR)], - ids=["table-creator", "previous-task-creator"], -) def test_the_decided_creator_reaches_the_w1_form_and_every_read_back( - company, creator, serve, guard, folder + serve, guard, folder ): + # The Project Creator's row: test_the_project_creator_reaches_the_w1_form_and_every_read_back. + company, creator = TABLE_COMPANY, TABLE_CREATOR served = serve(company=company, tasks=TASKS) page = served[0] proceed = proceed_for(company) @@ -548,45 +557,69 @@ def test_a_creator_not_exactly_one_option_is_write_not_started_with_nothing_sele assert page.is_closed() -# --- W1's recheck of the previous task ------------------------------------------ +# --- Joey's rules of 4 Dec 2026: the Project Creator, a Cancelled twin ---------- + +# Summit Projects: its creator is the project window's Project Creator. +PROJECT_COMPANY, PROJECT_CREATOR = "Summit Projects", "Fake Project Creator" + + +def test_the_project_creator_reaches_the_w1_form_and_every_read_back( + serve, guard, folder +): + served = serve(company=PROJECT_COMPANY, tasks=TASKS) + page = served[0] + proceed = proceed_for(PROJECT_COMPANY, project_creator=PROJECT_CREATOR) + assert (proceed.creator, proceed.project_creator) == (PROJECT_CREATOR,) * 2 + + task_no = run_book(served, guard, proceed, folder) + + assert task_no == NEW_TASK + assert actions(guard) == REOPEN + FILL + W2 + assert booked(page)["creator"] == PROJECT_CREATOR @pytest.mark.parametrize( - "tasks", - [ - # A later task by another person, created between the peek and W1. - [*TASKS, ("tsk_300003", "Retaining Wall", "Fake Staff Three", "Active")], - # The previous task's Task Creator changed. - [CANCELLED, SITE_START, (*ENGINEERING[:2], "Fake Staff Three", "Active")], - # The previous task was cancelled: another task is now the previous one. - [CANCELLED, SITE_START, (*ENGINEERING[:3], "Cancelled")], - ], - ids=["later-task", "creator-changed", "previous-cancelled"], + "now", ["Fake Other Creator", "", "---"], ids=["changed", "empty", "dashes"] ) -def test_a_previous_task_changed_since_the_peek_is_write_not_started_before_the_form( - tasks, serve, guard, folder +def test_a_project_creator_changed_since_the_peek_is_write_not_started_before_the_form( + now, serve, guard, folder ): - served = serve(company=PREVIOUS_COMPANY, tasks=tasks) + served = serve(company=PROJECT_COMPANY, tasks=TASKS, project_creator=now) + proceed = proceed_for(PROJECT_COMPANY, project_creator=PROJECT_CREATOR) with pytest.raises(WriteNotStarted) as stopped: - run_book(served, guard, proceed_for(PREVIOUS_COMPANY), folder) + run_book(served, guard, proceed, folder) assert stopped.value.step == "W1" assert stopped.value.detail == "project changed since the decision" assert actions(guard) == REOPEN # Create New Task never opened -def test_a_later_task_that_does_not_change_the_previous_task_still_books( +def test_a_later_task_does_not_matter_to_a_project_creator_row(serve, guard, folder): + later = ("tsk_300003", "Retaining Wall", "Fake Staff Three", "Active") + served = serve(company=PROJECT_COMPANY, tasks=[*TASKS, later]) + page = served[0] + + run_book( + served, + guard, + proceed_for(PROJECT_COMPANY, project_creator=PROJECT_CREATOR), + folder, + ) + + assert booked(page)["creator"] == PROJECT_CREATOR + + +def test_w1_s_reopen_drops_a_cancelled_twin_project_from_the_search( serve, guard, folder ): - # A later Compaction-free task, Cancelled: not a previous-task candidate. - later = ("tsk_300003", "Retaining Wall", "Fake Staff Three", "Cancelled") - served = serve(company=PREVIOUS_COMPANY, tasks=[*TASKS, later]) - page = served[0] + # The search row's Status cell is read: the Cancelled project with the + # same Client Ref No. doesn't make the match ambiguous at W1. + served = serve(company=TABLE_COMPANY, tasks=TASKS, cancelled_twin=True) - run_book(served, guard, proceed_for(PREVIOUS_COMPANY), folder) + task_no = run_book(served, guard, proceed_for(TABLE_COMPANY), folder) - assert booked(page)["creator"] == PREVIOUS_CREATOR + assert task_no == NEW_TASK # --- the Documents file name: the PDF's, or with every "-" filed as "_" -------- diff --git a/tests/test_summit_client.py b/tests/test_summit_client.py index b9db1374..7e0d3dda 100644 --- a/tests/test_summit_client.py +++ b/tests/test_summit_client.py @@ -126,3 +126,97 @@ def test_the_project_rule_s_judge_needs_the_client_internal_no_again(): assert rule.judge(summit_lookup("123456", internal_no="123457"), "123456") == ( Skip(reason=SkipReason.UNEXPECTED_SCREEN) ) + + +# --- Joey's rules of 4 Dec 2026 (SPEC.md -> Client 2, Decision checks) --- + + +def test_the_project_rule_drops_a_cancelled_search_row_before_the_match(): + # PO-1's shape: the same Client Ref No. on a live and a Cancelled project. + rows = ( + SearchRow( + pln="pln_20009", + client_ref_no="123456", + company="Summit Homes Group", + status="Cancelled", + ), + SearchRow( + pln="pln_20001", + client_ref_no="123456", + company="Summit Homes Group", + status="Active", + ), + ) + + assert summit().project_rule().match(rows, False, "123456") == "pln_20001" + + +def test_the_project_rule_reads_the_project_creator(): + # The driver reads the Project Creator only for a rule that asks for it + # (Summit's Project Creator rows; W1's reopen compares it again). + assert summit().project_rule().reads_project_creator is True + + +def project_creator_proceed(creator: str = "Fake Project Creator") -> SummitProceed: + title = summit_titled(company="Summit Renovations") + decision = summit().decide( + NoteSnapshot( + note_id="462001", + title=title, + body=SUMMIT_BODY, + attachment_names=(summit_file(),), + project_linked=False, + assignee="---", + ), + listed(), + summit_pdf(company="Summit Renovations"), + lambda: summit_lookup(company="Summit Renovations").model_copy( + update={"project_creator": creator} + ), + ) + assert isinstance(decision, SummitProceed) + return decision + + +def test_a_project_creator_row_carries_the_project_creator_for_w1(): + proceed = project_creator_proceed() + + assert proceed.creator == "Fake Project Creator" + assert proceed.project_creator == "Fake Project Creator" + + +@pytest.mark.parametrize( + ("now", "same"), + [ + ("Fake Project Creator", True), + (" Fake Project Creator ", True), + ("Fake Other Creator", False), + ("", False), + ("---", False), + ], + ids=["same", "same-trimmed", "changed", "empty", "dashes"], +) +def test_w1_s_recheck_needs_the_same_project_creator(now, same): + rule = summit().project_rule() + lookup = summit_lookup(company="Summit Renovations").model_copy( + update={"project_creator": now} + ) + + assert rule.recheck(lookup, project_creator_proceed()) is same + + +def test_w1_s_recheck_takes_nothing_more_for_a_fixed_creator_row(): + proceed = summit().decide(snapshot("---"), listed(), summit_pdf(), summit_lookup) + assert isinstance(proceed, SummitProceed) + assert proceed.project_creator is None + lookup = summit_lookup().model_copy(update={"project_creator": "Anyone"}) + + assert summit().project_rule().recheck(lookup, proceed) is True + + +@pytest.mark.parametrize("other", ["Fake Other Creator", "", "---"]) +def test_a_proceed_whose_project_creator_is_not_its_creator_is_refused(other): + proceed = project_creator_proceed() + + with pytest.raises(ValueError): + SummitProceed(**{**proceed.model_dump(), "project_creator": other}) diff --git a/tests/test_summit_variation_client.py b/tests/test_summit_variation_client.py index b3c3e56d..6351e076 100644 --- a/tests/test_summit_variation_client.py +++ b/tests/test_summit_variation_client.py @@ -16,8 +16,14 @@ from po_agent.core import output, run from po_agent.core.client import EligibleNote, Job -from po_agent.core.config import CONFIG_DIR, load_config, parse_client -from po_agent.core.models import NotePoolFilters, NotePoolRow +from po_agent.core.config import CONFIG_DIR, load_client, load_config, parse_client +from po_agent.core.models import ( + NotePoolFilters, + NotePoolRow, + SearchRow, + Skip, + SkipReason, +) from po_agent.summit_variation.client import VariationClient VARIATION_TOML = CONFIG_DIR / "clients" / "summit_variation.toml" @@ -124,3 +130,34 @@ def test_the_spike_counts_a_pair_as_one_eligible_job(monkeypatch, tmp_path, caps assert "read with source" in fake.calls assert (report.seen, report.eligible) == (6, 2) assert "INFO note pool read: 6 rows, 2 eligible" in capsys.readouterr().out + + +# --- Summit's rules of 4 Dec 2026 stay Agent 2's (safe side, Joey to confirm) + + +def test_agent_3_s_project_rule_still_counts_a_cancelled_search_row(): + rows = ( + SearchRow( + pln="pln_30009", + client_ref_no="123456", + company="Summit Homes Group", + status="Cancelled", + ), + SearchRow( + pln="pln_30001", + client_ref_no="123456", + company="Summit Homes Group", + status="Active", + ), + ) + + # Summit's company table, as the command builds Agent 3's client. + agent_3 = VariationClient(client().profile, load_client("summit", "live").company) + + assert agent_3.project_rule().match(rows, False, "123456") == Skip( + reason=SkipReason.PROJECT_AMBIGUOUS + ) + + +def test_agent_3_s_project_rule_does_not_read_the_project_creator(): + assert client().project_rule().reads_project_creator is False {PLN} ' + '{CLIENT_REF} Active ' + FAKE.company + '