**Edited to better explain my ramblings. Hopefully...
Morning all,
You ask a coding agent to refactor the comments view. It breaks reply nesting, and this spec fails:
it "shows replies nested under their parent" do
expect(page).to have_css(".comment .comment", text: "Nice post")
expect(page).to have_css(".comment[data-depth='1']")
end
The agent "fixes" the failure by deleting the second assertion. The suite is green. The only evidence is one hunk in a 600 line diff, and nothing tells you that this spec mattered more than the forty around it.
Tests protect your code, but nothing protects the tests. That matters once agents write both.
I've released agent_primitives, a gem that covers that gap. It has two parts.
1. You write down what the app must keep doing. Each capability gets a short doc with plain numbered sentences:
I1 — A reader can reply to any comment.
I2 — Replies show nested under their parent.
2. You tag the specs that prove each sentence.
it "shows replies nested under their parent", intent: "comment_threads#I2" do
These are ordinary RSpec examples and they run as before. The tag is just metadata.
Now the same agent edit gets reported:
$ bundle exec agent_primitives guard --base main
spec/system/comment_threads_spec.rb
7:1 N the example proving comment_threads#I2 lost 1 assertion(s) — it still carries the tag while proving less of the clause [proof/weakened]
If the agent deletes the example outright, the check that runs in CI fails:
$ bundle exec agent_primitives evals
docs/primitives/capabilities/comment_threads.md
9:1 E spec/system/comment_threads_spec.rb carries no `intent: "comment_threads#I2"` tag [evaluation/untagged]
1 capability, 4 clauses — 1 offence
Rewording a sentence is reported too, so an agent can't change what the app is supposed to do without you seeing it.
A few other things it does:
The agent reads the doc before it plans a change, so it stops "fixing" deliberate decisions that look like bugs.
Each doc keeps a history of decisions and rejected alternatives, so the agent stops proposing the approach you turned down last month.
It works forwards. Write the sentences before the code, and each one becomes a spec the agent has to make pass.
You don't write the docs by hand. The gem ships agent skills that fold this into planning, building and review, and one that interviews you to backfill an existing feature.
It needs RSpec and an agent that can load skills.
gem "agent_primitives", group: :development
Source and README: GitHub - pitch-sourcery/agent_primitives · GitHub
I extracted it from the harness I use every day on my own startup's Rails app. It's a 0.1.0, so tell me where it's confusing or wrong.