From ebd8e59c4e90e9b24571550e4bc2d6d20139a314 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 30 Aug 2026 08:33:38 +0000 Subject: [PATCH] fix: exclude excellence proposals from compiled briefs Close the remaining WOR-62 downstream gap: EXC-* proposal IDs are not authoritative source scope. Planning and the brief compiler now fail closed instead of compiling deferred or rejected excellence text. Co-authored-by: Ldsystem --- .../assets/orchestration/contract/task-v1.md | 2 +- references/evals/orchestration/evals.json | 6 +++++ scripts/orchestration/doctor.py | 8 +++++- scripts/orchestration/execution_context.py | 12 ++++++++- .../orch-create-implementation-plan/SKILL.md | 3 ++- tests/test_orchestration_execution_context.py | 27 +++++++++++++++++++ .../test_orchestration_skill_rule_boundary.py | 3 +++ .../test_orchestration_workflow_contracts.py | 6 +++++ 8 files changed, 63 insertions(+), 4 deletions(-) diff --git a/references/assets/orchestration/contract/task-v1.md b/references/assets/orchestration/contract/task-v1.md index f252518..abb9e18 100644 --- a/references/assets/orchestration/contract/task-v1.md +++ b/references/assets/orchestration/contract/task-v1.md @@ -80,7 +80,7 @@ The front-matter `truth_basis` is mandatory and uses the same five fields as the ## Source references -List stable source IDs and their task-local effect. Do not duplicate full specification prose. +List stable source IDs and their task-local effect. Do not duplicate full specification prose. Source IDs are authoritative specification IDs only. Do not cite `EXC-*` excellence proposal IDs; rejected, deferred, and not-material proposals stay out of executor briefs. | ID | Source path | Task-local effect | | --- | --- | --- | diff --git a/references/evals/orchestration/evals.json b/references/evals/orchestration/evals.json index 2f79311..882d40a 100644 --- a/references/evals/orchestration/evals.json +++ b/references/evals/orchestration/evals.json @@ -492,6 +492,12 @@ "prompt": "An excellence scan finds one adjacent idea that cannot change an accepted contract surface and another option whose acceptance could change a user-observable outcome and validation target.", "expected_output": "Omits the related-but-non-material adjacent idea or records it not_material, surfaces the outcome-changing option as a proposal because accepting or rejecting it could change a requirement, constraint, acceptance criterion, user-observable or contractual outcome, architectural boundary, measurable quality target, validation target, or declared boundary, and stops when further exploration can change none of those surfaces with the reason recorded.", "files": [] + }, + { + "id": 89, + "prompt": "A planner allocates source_ids: [EXC-001] for a deferred excellence proposal while compiling an implementation plan.", + "expected_output": "Rejects EXC-* proposal IDs as non-authoritative; planning and the compiled brief use only the stable requirement, constraint, interface, acceptance-criterion, or validation-target IDs that an accepted proposal projected to.", + "files": [] } ], "v4_evals": [ diff --git a/scripts/orchestration/doctor.py b/scripts/orchestration/doctor.py index 7e2e669..55d0004 100644 --- a/scripts/orchestration/doctor.py +++ b/scripts/orchestration/doctor.py @@ -297,7 +297,13 @@ def cmd_doctor(args: argparse.Namespace) -> None: ( skill_root / "orch-create-implementation-plan" / "SKILL.md", "orch-create-implementation-plan skill", - ["source-ID coverage", "dev-semantic-convergence", "context_mode: compiled-brief"], + [ + "source-ID coverage", + "dev-semantic-convergence", + "context_mode: compiled-brief", + "EXC-*", + "executor briefs", + ], ), ( skill_root / "orch-execute-plan" / "SKILL.md", diff --git a/scripts/orchestration/execution_context.py b/scripts/orchestration/execution_context.py index 81b478e..fde1a7e 100644 --- a/scripts/orchestration/execution_context.py +++ b/scripts/orchestration/execution_context.py @@ -19,6 +19,7 @@ SOURCE_ID_RE = re.compile(r"^[A-Z][A-Z0-9_-]*-\d+$") AUTH_ALIAS_RE = re.compile(r"^AUTH-\d{3}$") +EXCELLENCE_PROPOSAL_RE = re.compile(r"^EXC-\d+$") SAFE_ID_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]*$") SENSITIVE_KEY_RE = re.compile( r"(?:^|[_-])(credential_values?|password|passwd|secret|api[_-]?key|access[_-]?token|private[_-]?key)(?:$|[_-])", @@ -416,7 +417,7 @@ def _source_records(path: Path, body: str) -> dict[str, str]: records: dict[str, str] = {} def add(identifier: str, value: str) -> None: - if AUTH_ALIAS_RE.fullmatch(identifier): + if AUTH_ALIAS_RE.fullmatch(identifier) or EXCELLENCE_PROPOSAL_RE.fullmatch(identifier): return value = _strip_markup(value) if not value: @@ -459,8 +460,16 @@ def _assert_no_credential_values(value: Any, context: str = "packet") -> None: raise SystemExit(f"Blocked credential-like value in {context}") +def _assert_not_excellence_proposal_id(identifier: str, context: str) -> None: + if EXCELLENCE_PROPOSAL_RE.fullmatch(identifier): + raise SystemExit( + f"Non-authoritative source ID {identifier}: excellence proposal IDs are excluded from {context}" + ) + + def _resolve_reference(value: Any, records: dict[str, str], source_paths: list[Path]) -> Any: if isinstance(value, str) and SOURCE_ID_RE.fullmatch(value): + _assert_not_excellence_proposal_id(value, "compiled briefs") if value not in records: sources = ", ".join(path.as_posix() for path in source_paths) raise SystemExit(f"Unresolved source ID {value}; searched: {sources}") @@ -1625,6 +1634,7 @@ def _compile_task_brief(args: argparse.Namespace) -> tuple[Path, dict[str, Any]] if not source_ids: raise SystemExit(f"Task has no source_ids: {task_path}") for identifier in source_ids: + _assert_not_excellence_proposal_id(identifier, "compiled briefs") if not SOURCE_ID_RE.fullmatch(identifier) or identifier not in records: sources = ", ".join(path.as_posix() for path in source_paths) raise SystemExit(f"Unresolved source ID {identifier}; searched: {sources}") diff --git a/skills/orch-create-implementation-plan/SKILL.md b/skills/orch-create-implementation-plan/SKILL.md index 34c84b2..39bd8be 100644 --- a/skills/orch-create-implementation-plan/SKILL.md +++ b/skills/orch-create-implementation-plan/SKILL.md @@ -7,7 +7,7 @@ description: 'Create executable WorkBundle plans, phases, and tasks from a verif ## Entry gate -Plan only from a verified active specification with converged semantics, resolved blockers, stable source IDs, explicit knowledge disposition, and coherent repository evidence. Repair missing authority. +Plan only from a verified active specification with converged semantics, resolved blockers, stable source IDs, explicit knowledge disposition, and coherent repository evidence. Repair missing authority. Compile only verified authoritative scope. Do not allocate `EXC-*` proposal IDs or rejected, deferred, or not-material excellence proposals as `source_ids`, task scope, or executor briefs. Accepted excellence work enters planning only through the stable requirement, constraint, interface, acceptance-criterion, or validation-target IDs it projected to. ## Planning workflow @@ -73,6 +73,7 @@ The compiler resolves each allocated `AUTH-NNN` alias to `AUTH-NNN: None: + root, spec, task = workspace(tmp_path) + spec.write_text( + spec.read_text(encoding="utf-8") + "- **EXC-001**: Deferred visual hierarchy improvement.\n", + encoding="utf-8", + ) + task.write_text(task.read_text(encoding="utf-8").replace("TEST-004]", "TEST-004, EXC-001]"), encoding="utf-8") + + with pytest.raises(SystemExit, match=r"EXC-001.*excellence proposal"): + build_task_brief(args(root, task)) + + assert not (root / ".work-bundle/runtime/execution/plan-001/task-004/task-brief.yaml").exists() + + +def test_build_task_brief_omits_unallocated_excellence_proposal_text(tmp_path: Path) -> None: + root, spec, task = workspace(tmp_path) + spec.write_text( + spec.read_text(encoding="utf-8") + "- **EXC-001**: Deferred visual hierarchy improvement.\n", + encoding="utf-8", + ) + + packet = build_task_brief(args(root, task)).read_text(encoding="utf-8") + + assert "EXC-001" not in packet + assert "Deferred visual hierarchy" not in packet + + def test_build_task_brief_reads_current_task_contract_sections(tmp_path: Path) -> None: root, _, task = workspace(tmp_path) content = task.read_text(encoding="utf-8") diff --git a/tests/test_orchestration_skill_rule_boundary.py b/tests/test_orchestration_skill_rule_boundary.py index 9d93c72..eedaba6 100644 --- a/tests/test_orchestration_skill_rule_boundary.py +++ b/tests/test_orchestration_skill_rule_boundary.py @@ -104,6 +104,9 @@ def test_planner_allocates_methodology_capability_and_bounded_context() -> None: "earliest ordinary task", "cheaply falsify", "Do not add a risk score", + "EXC-", + "deferred", + "executor briefs", ]: assert token in text diff --git a/tests/test_orchestration_workflow_contracts.py b/tests/test_orchestration_workflow_contracts.py index 3171434..1e6e4a3 100644 --- a/tests/test_orchestration_workflow_contracts.py +++ b/tests/test_orchestration_workflow_contracts.py @@ -390,11 +390,15 @@ def test_specification_contract_requires_bounded_excellence_applicability() -> N assert "measurable quality target" in text assert "further exploration could change none of those surfaces" in text assert "excellence-applicability view" in skill + plan_skill = read("skills/orch-create-implementation-plan/SKILL.md") + assert "EXC-*" in plan_skill or "EXC-" in plan_skill + assert "deferred" in plan_skill and "executor briefs" in plan_skill assert "user-visible request with no evidenced adjacent improvement" in evals assert "silently implements a deferred proposal" in evals assert "accepted proposal" in evals and "stable authoritative" in evals assert "universal product-quality checklist" in evals assert "related-but-non-material adjacent idea" in evals + assert "source_ids: [EXC-001]" in evals def test_archive_plan_uses_accepted_execution_dispositions_as_knowledge_gate(tmp_path: Path) -> None: @@ -777,6 +781,8 @@ def test_task_contract_compiles_methodology_capability_and_review() -> None: "verdict: pending", "Fresh task validation evidence exists", "acceptance_review.verdict", + "EXC-*", + "executor briefs", ]: assert token in contract