Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion planning/workflow/records.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<!-- workflow:note -->`, 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/.<id>.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/.<id>.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/<trunk>`. 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.
Expand Down
15 changes: 14 additions & 1 deletion scripts/research_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <event>' trigger in its reason"
)
target = contained(package, urlsplit(entry["target"]).path)
if not target.exists():
fail(f"{path}: resolution target missing")
Expand Down
5 changes: 5 additions & 0 deletions scripts/research_workflow_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ def check_receipt(package, root, entry):
):
fail(f"Receipt note must be notes/<note-id>.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: <event>' trigger"
)
if not isinstance(entry["scanned"], list) or not all(
isinstance(x, dict)
and set(x) == {"ref", "sha"}
Expand Down
106 changes: 106 additions & 0 deletions scripts/tests/test_research_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<!-- workflow:resolution -->\n"
+ json.dumps(entry)
+ "\n<!-- /workflow:resolution -->\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<!-- workflow:resolution -->\n"
+ json.dumps(entry)
+ "\n<!-- /workflow:resolution -->\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)
Expand Down