From e9bf4ae0f4d37fd150ad2454b1c4d6332d5ac08d Mon Sep 17 00:00:00 2001 From: repo-worker-code Date: Sat, 31 Oct 2026 20:56:45 -0500 Subject: [PATCH] fix(research-workflow): accept the deferred note disposition end to end (#492) check_package validated concept-file resolution blocks against four dispositions, so a deferred receipt (the fifth disposition the notes-reconcile skill prescribes) always failed check --require-resolved. Add deferred to the set and require the skill's mandatory Revisit when: trigger in a deferred entry's reason; enforce the same trigger in the live receipt path (check_receipt, used by both resolve-note and the receipts reader). Update the stale records.md tool-status note, and add tests: all five dispositions pass --require-resolved via resolve-note, deferred without a trigger is refused at resolve-note and fails check on the resolution-block path, deferred with a trigger passes there. Audit: research_workflow_live DISPOSITIONS, vocabulary.md and templates/receipt.md already list all five; research_workflow_items STATUSES is the item-status enumeration, not note dispositions. --- planning/workflow/records.md | 2 +- scripts/research_workflow.py | 15 +++- scripts/research_workflow_live.py | 5 ++ scripts/tests/test_research_workflow.py | 106 ++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 2 deletions(-) diff --git a/planning/workflow/records.md b/planning/workflow/records.md index e00b1d583e..dff1927c7a 100644 --- a/planning/workflow/records.md +++ b/planning/workflow/records.md @@ -298,7 +298,7 @@ What `scripts/research_workflow.py` and `scripts/research_workflow_items.py` on - Coverage: by non-blank line, not by segment. There is no `G` bucket, no `G.1` items and no `hint` type; every concept needs source lines. - Single concept: the concept is written into `main.md` with an inline change log, instead of a concept file and `changes.md`. - Notes: the marker is ``, the body is hashed without a formatter pass, and `note` runs a full package check first. -- Receipts: `resolve-note` appends a `## Note disposition` section to the receiver's concept file (a second writer) and guards with an `O_EXCL` lock file `notes/..resolved`. `deferred` is not accepted and nothing records `scanned`. +- Receipts: `resolve-note` appends a `## Note disposition` section to the receiver's concept file (a second writer) and guards with an `O_EXCL` lock file `notes/..resolved`. `deferred` is accepted with a mandatory `Revisit when:` trigger in the reason (#492), and nothing records `scanned` in a concept-file resolution block. - Vocabulary: item statuses and stages are validated. Concept `status`, `priority`, `criticality` and `horizon` are free text, and completion uses a synonym set (`done`, `completed`, `researched`, ...). The relation kinds `supersedes`, `contradicts` and `part-of` are rejected. - Scheduling: `ready` and `status` read the working tree, not `origin/`. The `waves` view honours `requires` and `shares-files-with`; there are no leases and no live join. - IDs: `ids` lists concept, item, segment, note and decision IDs but does not allocate decision IDs. diff --git a/scripts/research_workflow.py b/scripts/research_workflow.py index 58d0526e38..ee7b82bc54 100644 --- a/scripts/research_workflow.py +++ b/scripts/research_workflow.py @@ -853,11 +853,24 @@ def check_package(package, root, require_resolved=False): if ( receiver != note["to"] or entry.get("disposition") - not in {"incorporated", "acknowledged", "declined", "superseded"} + not in { + "incorporated", + "acknowledged", + "declined", + "deferred", + "superseded", + } or not entry.get("target") or not entry.get("reason") ): fail(f"{path}: invalid receiver disposition/target/reason") + if entry.get("disposition") == "deferred" and "Revisit when:" not in ( + entry.get("reason") or "" + ): + fail( + f"{path}: deferred disposition requires a " + "'Revisit when: ' trigger in its reason" + ) target = contained(package, urlsplit(entry["target"]).path) if not target.exists(): fail(f"{path}: resolution target missing") diff --git a/scripts/research_workflow_live.py b/scripts/research_workflow_live.py index 538d99143d..f91b09cc7b 100644 --- a/scripts/research_workflow_live.py +++ b/scripts/research_workflow_live.py @@ -392,6 +392,11 @@ def check_receipt(package, root, entry): ): fail(f"Receipt note must be notes/.md: {entry['note']}") single_line(entry["reason"], "Receipt reason") + if entry["disposition"] == "deferred" and "Revisit when:" not in entry["reason"]: + fail( + "A deferred receipt's reason must carry a " + "'Revisit when: ' trigger" + ) if not isinstance(entry["scanned"], list) or not all( isinstance(x, dict) and set(x) == {"ref", "sha"} diff --git a/scripts/tests/test_research_workflow.py b/scripts/tests/test_research_workflow.py index cab2884e7b..62f33d4a7f 100644 --- a/scripts/tests/test_research_workflow.py +++ b/scripts/tests/test_research_workflow.py @@ -462,6 +462,112 @@ def test_unresolved_note_blocks_reconciliation_until_receiver_records_dispositio self.assertTrue((package / "receipts" / note.name).is_file()) self.check(package, True, "--require-resolved") + def add_note(self, package, body_text): + content = self.scratch / f"note-input-{len(body_text)}-{abs(hash(body_text))}.txt" + content.write_text(body_text, encoding="utf-8") + before = set(package.rglob("*.md")) + self.cli( + "note", + "--repo-root", + self.root, + "--package", + package, + "--from", + "C001", + "--to", + "C002", + "--input", + content, + ) + created = set(package.rglob("*.md")) - before + self.assertEqual(len(created), 1) + return created.pop() + + def resolve_note(self, package, note, disposition, reason, ok=True): + return self.cli( + "resolve-note", + "--package", + package, + "--note", + note.relative_to(package), + "--disposition", + disposition, + "--target", + self.state(package)["concepts"][1]["path"], + "--reason", + reason, + ok=ok, + ) + + def test_every_disposition_passes_require_resolved_via_resolve_note(self): + # The skill names five dispositions (#492): each one, recorded + # through resolve-note, must satisfy check --require-resolved. + package = self.init() + reasons = { + "incorporated": "Brought into the concept text.", + "acknowledged": "Recorded as an explicit constraint.", + "declined": "Out of scope for this package, with reasons.", + "deferred": "Valid but premature. Revisit when: the storage decision lands.", + "superseded": "Replaced by the newer note on the same question.", + } + for disposition, reason in reasons.items(): + note = self.add_note(package, f"Please consider {disposition}.\n") + self.resolve_note(package, note, disposition, reason) + self.check(package, True, "--require-resolved") + + def test_deferred_resolve_note_without_trigger_is_refused(self): + package = self.init() + note = self.add_note(package, "Please hold this for later.\n") + self.resolve_note( + package, + note, + "deferred", + "Valid, but not for now.", + ok=False, + ) + self.assertFalse((package / "receipts" / note.name).is_file()) + self.check(package, False, "--require-resolved") + + def test_deferred_resolution_block_with_trigger_passes_require_resolved(self): + # The concept-file resolution path (check_package) rejected every + # deferred entry before #492, whatever its reason said. + package = self.init() + note = self.add_note(package, "Please account for the ownership constraint.\n") + target = self.state(package)["concepts"][1]["path"] + entry = { + "note": note.relative_to(package).as_posix(), + "at": TIMESTAMP, + "disposition": "deferred", + "target": target, + "reason": "Waits on the ownership decision. Revisit when: C001 is confirmed.", + } + with (package / target).open("a", encoding="utf-8") as handle: + handle.write( + "\n\n" + + json.dumps(entry) + + "\n\n" + ) + self.check(package, True, "--require-resolved") + + def test_deferred_resolution_block_without_trigger_fails_check(self): + package = self.init() + note = self.add_note(package, "Please account for the ownership constraint.\n") + target = self.state(package)["concepts"][1]["path"] + entry = { + "note": note.relative_to(package).as_posix(), + "at": TIMESTAMP, + "disposition": "deferred", + "target": target, + "reason": "Waits on the ownership decision.", + } + with (package / target).open("a", encoding="utf-8") as handle: + handle.write( + "\n\n" + + json.dumps(entry) + + "\n\n" + ) + self.check(package, False, "--require-resolved") + def test_completed_concept_cannot_still_be_an_unfilled_generated_stub(self): package = self.init() state = self.state(package)