Enforce rulespec creation with plan_write for new plans

Solves the tautology problem where the LLM would write invariants after
implementation, making them match what was done rather than constrain it.

Changes:
- plan_write now accepts 'rulespec' parameter
- New plans REQUIRE rulespec (fails with helpful error if missing)
- Plan updates don't require rulespec (backward compatible)
- Rulespec is parsed, validated, and written atomically with plan
- Updated system prompt with clear examples for new vs update
- Updated tool definition schema
- Updated all affected tests

New flow: task → plan+rulespec → user reviews BOTH → approve → implement
This commit is contained in:
Dhanji R. Prasanna
2026-02-05 21:12:02 +11:00
parent 085688479b
commit 7e2d9bc22c
6 changed files with 174 additions and 56 deletions

View File

@@ -621,6 +621,15 @@ items:
boundary:
- desc: Edge cases
target: test::module"#
,
"rulespec": r#"claims:
- name: test_feature
selector: test.done
predicates:
- claim: test_feature
rule: exists
source: task_prompt
notes: Test invariant"#
}),
};
let write_result = agent.execute_tool(&write_call).await.unwrap();

View File

@@ -425,6 +425,14 @@ items:
boundary:
- desc: Edge
target: test"#
,
"rulespec": r#"claims:
- name: test_feature
selector: test.done
predicates:
- claim: test_feature
rule: exists
source: task_prompt"#
}),
);
@@ -479,6 +487,14 @@ items:
happy: {desc: Works, target: test}
negative: [{desc: Errors, target: test}]
boundary: [{desc: Edge, target: test}]"#
,
"rulespec": r#"claims:
- name: approval_test
selector: test.approved
predicates:
- claim: approval_test
rule: exists
source: task_prompt"#
}),
);
agent.execute_tool(&write_call).await.unwrap();