agent_primitives 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,169 @@
1
+ # Primitives tree starters
2
+
3
+ Copy these when scaffolding `docs/primitives/` (normally via
4
+ `bootstrapping-primitives`) or creating a new capability doc.
5
+
6
+ ## `SCHEMA.md` starter
7
+
8
+ ```markdown
9
+ # Primitives — contract
10
+
11
+ This tree holds the four durable primitives: intent, compilation, evaluations,
12
+ provenance. Structure and ownership rules: the `primitives-format` skill
13
+ (canonical — this file only records app-specific deviations agreed between
14
+ agent and human).
15
+
16
+ ## Layout
17
+
18
+ docs/primitives/
19
+ SCHEMA.md # This contract
20
+ index.md # One line per capability + status
21
+ compilation.md # App-wide constraints. Human-owned.
22
+ capabilities/ # One doc per capability
23
+
24
+ ## App-specific deviations
25
+
26
+ (None yet.)
27
+ ```
28
+
29
+ ## `index.md` starter
30
+
31
+ ```markdown
32
+ # Capabilities
33
+
34
+ One line per capability, as `name — status — outcome. Owns: models.`
35
+ Status: shaping → planned → built → deprecated; an amendment runs built → amending → built.
36
+
37
+ - `comment_threads` — built — readers reply to comments and see them nested. Owns: Comment.
38
+ - `billing_plan_changes` — planned — owners switch plan mid-cycle with proration. Owns: Subscription, Invoice.
39
+
40
+ ## Deprecated
41
+
42
+ (None yet.)
43
+ ```
44
+
45
+ The outcome has to **discriminate** and `Owns:` is the grep bridge — this file
46
+ is the tree's entire discovery surface
47
+ (`primitives-format` § Finding the right capability).
48
+
49
+ ## `compilation.md` skeleton
50
+
51
+ Human-owned. Every line must pass the filter: **not derivable from the code or
52
+ the app's own conventions, and it would change what an agent proposes.** Target under 50 lines.
53
+
54
+ ```markdown
55
+ # Compilation — app-specific architecture
56
+
57
+ App-wide constraints agents read before planning. Human-owned: agents propose
58
+ amendments via review findings, never edit directly. Generic Rails shape lives
59
+ in the app's own conventions — only what is true of THIS app
60
+ and not derivable from the code belongs here.
61
+
62
+ ## Runtime & operations
63
+ - [Binding choices with teeth, e.g.: No Redis — ops will not run a second
64
+ datastore. Anything proposing Redis-backed state needs an amendment here
65
+ first.]
66
+
67
+ ## Boundaries & ownership
68
+ - [e.g.: `Post` is the aggregate root for reader-facing content; comments and
69
+ reactions hang off it and are authorized through it.]
70
+
71
+ ## Constraints with teeth
72
+ - [External commitments and red lines, e.g.: all reader-facing pages must
73
+ render without JavaScript — sales commitment, not preference.]
74
+ ```
75
+
76
+ ## Capability doc skeleton
77
+
78
+ Intent and evaluations are frontmatter — one record per clause, so a clause list
79
+ and an evaluation table cannot disagree. Shape and provenance stay prose.
80
+
81
+ ```markdown
82
+ ---
83
+ status: shaping
84
+ intent:
85
+ - id: I1
86
+ clause: [One sentence, outcome terms — what must be true for the user or system.]
87
+ evaluations: []
88
+ ---
89
+ # [Capability name]
90
+
91
+ ## Shape
92
+
93
+ - [Deltas only: constraints specific to this capability, not derivable from
94
+ the app's own conventions, not stated in compilation.md. Link, don't repeat.]
95
+
96
+ ## Provenance
97
+
98
+ - YYYY-MM-DD — [one line per event: shaped / planned / built / amended /
99
+ revised / backfilled / confirmed / deprecated; link plan or PR; rejected
100
+ alternatives; accepted debt. Nothing a future reader would not act on —
101
+ no review counts, agent names, or commands run.]
102
+ ```
103
+
104
+ `evaluations:` is filled from specs that **exist** — at execution close-out
105
+ or a `backfilling-primitives` pass — never from what a plan promises. A
106
+ `shaping` or `planned` doc for new work leaves it empty. Tagging mechanics —
107
+ the `intent:` metadata tag lives on the example, never the group:
108
+ `primitives-format` § Tagging the proof.
109
+
110
+ ## Built doc, fully wired
111
+
112
+ ```markdown
113
+ ---
114
+ status: built
115
+ intent:
116
+ - id: I1
117
+ clause: A reader can reply to any comment.
118
+ evaluations:
119
+ - spec/system/comment_threads_spec.rb
120
+ - id: I2
121
+ clause: Replies show nested under their parent.
122
+ evaluations:
123
+ - spec/system/comment_threads_spec.rb
124
+ - spec/requests/comments_spec.rb
125
+ - id: I3
126
+ clause: A reader sees who replied and when.
127
+ ---
128
+ ```
129
+
130
+ I3 has no `evaluations:` — shipped behaviour nothing proves yet. On a `built`
131
+ doc that is a **failing** run (`clause/unproven`), and deliberately so: there
132
+ is no key that annotates the gap into passing. Record the clause anyway, report
133
+ the red as blocking spec work, and close it by writing the spec.
134
+
135
+ ## Worked lifecycle lines (for reference)
136
+
137
+ ```markdown
138
+ - 2026-08-04 — shaped via brainstorming session; reactions explicitly out of scope.
139
+ - 2026-08-05 — planned: docs/plans/2026-08-05-comment-threads.md. Rejected
140
+ separate Thread model (threading is comment shape, not an addressable resource).
141
+ - 2026-08-07 — built: docs/plans/2026-08-05-comment-threads.md. Accepted:
142
+ depth cap is validation-only, no DB constraint.
143
+ - 2026-09-18 — planned: docs/plans/2026-09-18-deep-comment-threads.md.
144
+ Rejected raising the cap (same cliff, deferred).
145
+ - 2026-09-19 — amended: I4 superseded by I5/I6 — depth cap removed;
146
+ readability moved to view-layer disclosure. Moots the 2026-08-07
147
+ depth-constraint note.
148
+ - 2026-10-02 — backfilled from existing behaviour; intent confirmed by human;
149
+ prior history in git.
150
+ ```
151
+
152
+ Supersession in place — only the new clause carries evaluations
153
+ (mechanics, including the `superseded_on:`-not-`on:` YAML trap:
154
+ `primitives-format` § Capability doc format / § Lifecycle):
155
+
156
+ ```yaml
157
+ intent:
158
+ - id: I4
159
+ clause: Threads never nest deeper than 3 levels.
160
+ superseded_by: [ I5, I6 ]
161
+ superseded_on: 2026-09-18
162
+ - id: I5
163
+ clause: A reader can reply at any depth.
164
+ evaluations:
165
+ - spec/system/comment_threads_spec.rb
166
+ ```
167
+
168
+ Retagging is part of the amendment: examples tagged `#I4` must move to `#I5`, or
169
+ `agent_primitives evals` reports them as pointing at a superseded clause.
@@ -0,0 +1,261 @@
1
+ ---
2
+ name: planning-with-primitives
3
+ description: >-
4
+ The primitives steps of specifying and planning a feature: seed or amend the
5
+ capability doc, write intent clauses before tasks, declare the Intent impact
6
+ block naming each clause's proof cases, and sync status and provenance at plan
7
+ approval. Use when writing a requirements spec or an implementation plan in an
8
+ app with a docs/primitives/ tree.
9
+ ---
10
+
11
+ # Planning with primitives
12
+
13
+ **Announce:** "I'm using the planning-with-primitives skill."
14
+
15
+ This skill applies only when the app has a `docs/primitives/` tree; the
16
+ workflow skill that sent you here owns everything else about the spec or plan.
17
+
18
+ ## In a requirements spec
19
+
20
+ - **Ground** — When the app has a `docs/primitives/` tree, the spec's
21
+ grounding includes `docs/primitives/index.md` (an existing capability makes
22
+ this brainstorm an **amendment** to it, not a new doc) and `compilation.md`
23
+ (human-owned constraints that bound every approach you propose) — read both
24
+ **before proposing approaches**, not after the design is agreed.
25
+ - **Write spec** — **When the app has a `docs/primitives/` tree**, also create
26
+ or update the capability doc (`docs/primitives/capabilities/<name>.md`): the
27
+ spec's agreed outcomes become one-sentence Intent clauses (`I1`, `I2`, …),
28
+ **one behaviour each** — split umbrella outcomes ("users can manage X") per
29
+ action, and keep architecture and technology choices out of `intent:` (they
30
+ are `## Shape`) — and the chosen direction a rough `## Shape`. The spec
31
+ carries a **`## Intent`** block naming new and impacted clauses and the layer
32
+ that will prove each (see **Intent (in the spec)**) — per the
33
+ `primitives-format` skill. `status: shaping` applies only to docs this
34
+ brainstorm **creates**; when updating an existing doc (a `planned` or `built`
35
+ capability), leave its status untouched — a brainstorm never downgrades
36
+ status. What's explicitly out of scope is worth a provenance line.
37
+ The planner's primitives gate (§ Primitives gate below) confirms and extends
38
+ this doc instead of re-deriving intent.
39
+ - **After the design** — When the app has a `docs/primitives/` tree, seed the
40
+ capability doc per **Write spec** above (`status: shaping`; Intent clauses
41
+ from the spec's outcomes; one `shaped` provenance line noting explicit scope
42
+ exclusions) and add its `index.md` line.
43
+
44
+ ### Intent (in the spec)
45
+
46
+ When the app has a `docs/primitives/` tree, the spec states the intent it settles
47
+ **before** the sequence that ships it, separating new promises from clauses
48
+ merely relied on:
49
+
50
+ ```markdown
51
+ ## Intent
52
+
53
+ **New** — seeded into `docs/primitives/capabilities/team_invitations.md`
54
+
55
+ - I1 An admin can invite a person by email address. — proven at: request spec
56
+ - I2 An invitation expires 14 days after it is sent. — proven at: model spec
57
+
58
+ **Impacted** — existing clauses this work touches
59
+
60
+ - `accounts#I3` A member sees only their own account. — unchanged; must not break
61
+
62
+ **Out of scope** — bulk invites, invite links. [One line each. These become
63
+ provenance, not clauses.]
64
+ ```
65
+
66
+ Name the **layer** that will prove each new clause, coarsely — one word, no file
67
+ paths or task numbers (the planner's job). **If the only honest answer is
68
+ "a journey spec", the clause is too broad and wants splitting** before a plan is
69
+ written around it. What is and is not a clause:
70
+ `primitives-format` § Intent clauses — run the **durable**
71
+ test on every line, since a brainstorm is where architecture and technology
72
+ choices are most likely to be mistaken for intent.
73
+
74
+ ## Primitives gate
75
+
76
+ Runs **before drafting anything**, when the app has a **`docs/primitives/`**
77
+ tree (see the **`primitives-format`** skill and `maintaining-primitives`). If
78
+ the tree does not exist, skip this gate — optionally mention
79
+ `bootstrapping-primitives` once — and omit the **Capability:** header line
80
+ (§ Intent impact block).
81
+
82
+ The reading contract is three files, never more: **`index.md`**, the **one**
83
+ target capability doc, and **`compilation.md`**.
84
+
85
+ 1. **Read `docs/primitives/index.md`.** Does an existing capability own this
86
+ outcome? If yes, this plan is an **amendment** to that capability — never
87
+ create a second doc whose intent overlaps an existing one (a plan defect
88
+ the reviewer will flag). **One capability per plan — always.**
89
+ Work spanning two capabilities is two plans (independent subsystems split
90
+ into separate plans): clause IDs are only unambiguous within one
91
+ doc, and every downstream mechanism targets exactly one doc. The
92
+ reading-contract allowance for opening a second capability doc is for
93
+ **context**, never a second target.
94
+
95
+ **This does not mean one plan per capability.** A capability large enough
96
+ to ship in stages gets **several sequenced plans**, each an amendment to
97
+ the same doc serving its own clauses — what the requirements spec's
98
+ `## Delivery sequence` enumerates. Later plans append their own provenance
99
+ line and set the status per § At final approval, exactly like any other
100
+ amendment.
101
+ 2. **Read `docs/primitives/compilation.md`.** These are human-owned, app-wide
102
+ constraints; the plan must not contradict them. If the right approach
103
+ genuinely requires breaking one, **stop and say so** — the constraint
104
+ changes by human amendment, not by a plan working around it.
105
+ 3. **Read (or create) the capability doc** under
106
+ `docs/primitives/capabilities/<name>.md`:
107
+ - **Exists (from brainstorming, `status: shaping`, or earlier work):**
108
+ confirm and extend. Classify every part of this plan against the `intent:`
109
+ clauses — serves an existing clause / **supersedes** one (`superseded_by:`
110
+ plus `superseded_on:`, new id — never renumber or delete) / adds a new
111
+ clause. Read
112
+ `## Provenance` before proposing an approach: do not re-litigate a
113
+ recorded rejection or "fix" a recorded deliberate decision without
114
+ saying so explicitly.
115
+ - **Exists, and this plan changes no behaviour (refactor, migration,
116
+ architecture change):** the fourth classification, and the one with no
117
+ `intent:` edit in it. Leave every clause and `status:` untouched; the active
118
+ clauses become the plan's **regression contract** — list them as
119
+ `unchanged` entries in the Intent impact block and write `no intent delta`.
120
+ Record what future work must respect in `## Shape`, and append a
121
+ `refactored` provenance line only when a constraint actually changed;
122
+ tidying that leaves no constraint behind earns no entry. If a clause's
123
+ wording has to change for the work to be correct, this is **not** this
124
+ branch — it is an amendment, and it takes the supersession mechanics above.
125
+ - **Missing, new feature:** create it now. The requirements-gate answers
126
+ **are** the `intent:` clauses — transcribe them into frontmatter as
127
+ one-sentence `clause:` entries (`I1`, `I2`, …). **Split as you
128
+ transcribe.** Gate answers arrive in umbrella form — *"users need to
129
+ manage their comments"* — and one behaviour per clause is the rule
130
+ (`primitives-format` § Intent clauses). Draft
131
+ `## Shape` (deltas only) from the approach-gate outcome. Skeleton:
132
+ `references/templates.md` in the `maintaining-primitives` skill.
133
+ - **Missing, existing feature:** planning pauses and runs
134
+ `backfilling-primitives` to completion. It then resumes with that doc as
135
+ the capability this plan amends.
136
+ 4. **Write the `intent:` clauses and Shape before drafting tasks.** Tasks then cite clause
137
+ ids (`serves I1, I4` / `supersedes I4 → I5`) instead of restating
138
+ requirements — the plan is ephemeral; the capability doc is the durable
139
+ record.
140
+
141
+ Write each clause **falsifiable** — a spec must be able to go red when it
142
+ stops being true — and then **plan the spec homes that would**. A clause
143
+ carrying a quantifier (*only*, *never*, *any*, *every*, *at most*) is not
144
+ covered by one happy path: its task list names the denial or boundary case at
145
+ the layer that owns it (the app's testing conventions for which spec layer
146
+ owns a behaviour), usually a policy or request spec rather than
147
+ another system spec — and its **Intent impact** entry names those cases one by
148
+ one, because a proof set promised in prose is one nothing can count. A clause whose proof was never planned becomes a green
149
+ row that proves nothing at close-out
150
+ (`tagging-intent` § What counts as proving a clause). When this gate **creates** a doc (new feature),
151
+ add its `docs/primitives/index.md` line at creation —
152
+ final approval then updates it.
153
+
154
+ **Write points:** during drafting this skill writes the **`intent:` clauses** and **Shape**;
155
+ at final approval it also flips `status:` to `planned` (or `built` →
156
+ `amending` with `plan:`), appends the one
157
+ `planned` provenance line, and syncs `index.md` (see **At final approval**
158
+ below). `evaluations:`, `status: built`, and the `built` provenance line
159
+ belong to execution close-out (`closing-out-primitives`); do not fill
160
+ them from intention. A backfilled doc's `evaluations:`, transcribed from
161
+ already-existing specs, are written by `backfilling-primitives` (§ 5. Write the
162
+ doc), not at plan time.
163
+
164
+ ## Intent impact block
165
+
166
+ In the plan header, after the title and its note:
167
+
168
+ ```markdown
169
+ **Capability:** `docs/primitives/capabilities/<name>.md` — serves I1–I4
170
+ [Clause IDs this plan serves, supersedes, or adds. Omit this line and the
171
+ Intent impact block below only when the app has no `docs/primitives/` tree.]
172
+
173
+ **Intent impact:** every clause this plan touches, and where its proof will land.
174
+
175
+ - **I5** Only the author can delete a comment — **new**
176
+ - `spec/policies/comment_policy_spec.rb`
177
+ - deny: reader
178
+ - deny: other author
179
+ - deny: archived post
180
+ - `spec/requests/comments_spec.rb` (Task 3)
181
+ - redirects a non-author
182
+ - **I4** Anyone can delete a comment — **superseded by I5**
183
+ - spec deleted in Task 3; entry retires at close-out
184
+ - **I1** A reader can reply to any comment — **unchanged — regression contract**
185
+ - `spec/system/comment_threads_spec.rb` (exists)
186
+ ```
187
+
188
+ One entry per clause: the clause on the first line with its change in bold, one
189
+ line per proof file under it, one line per case under that. The change is one of
190
+ **new**, **amended**, **superseded by I\<n>**, or **unchanged — regression
191
+ contract**. That last value is not filler: it is the explicit list of promises
192
+ this plan must not break, and it is what makes a **Shape-only plan** expressible
193
+ — a refactor's block is all regression-contract entries, and it says `no intent
194
+ delta` where new clauses would go. List changed clauses first, so the delta
195
+ reads before the contract.
196
+
197
+ An entry names the **cases**, not only the files, whenever a clause needs more
198
+ than one example in the same file — the three denials under
199
+ `spec/policies/comment_policy_spec.rb` above. A file name alone is the granularity
200
+ `agent_primitives evals` can check, and it is satisfied by **one** tag in that
201
+ file: so a clause whose four denials were promised in prose passes every gate
202
+ with three of them tagged. Named cases are countable —
203
+ `agent_primitives proofs 'comment_threads#I5'` lists the tagged examples
204
+ behind the clause, and both execution close-out and review check that listing
205
+ against this entry.
206
+
207
+ Where proof lands is a **plan**, and it lives in this file only. It is never copied
208
+ into the doc's `evaluations:` — those are filled at close-out from the specs the
209
+ implementing agent actually reported, never from intention. Declaring the layer up front
210
+ is still the point: a clause whose only conceivable proof is a wide journey spec
211
+ is a clause that wants splitting, and this block is where that becomes visible
212
+ (`primitives-format` § Intent clauses).
213
+
214
+ ## Citing clauses in tasks
215
+
216
+ ```markdown
217
+ ### Task N: [Resource or slice name] (serves I1, I4)
218
+
219
+ [The clause citation replaces restated requirements — the capability doc owns
220
+ intent. Use `(supersedes I4 → I5)` when the task changes intent. Omit the
221
+ parenthetical only when the app has no primitives tree.]
222
+ ```
223
+
224
+ In the plan's self-review:
225
+
226
+ - **Primitives trace (when the tree exists):** Every task's behaviour maps to
227
+ an active Intent clause in the capability doc; every clause this plan
228
+ touches appears in the header's **Capability:** line; supersessions are
229
+ explicit in both plan and doc; nothing contradicts `compilation.md` or the
230
+ doc's recorded Shape and Provenance. Untraceable behaviour means either a
231
+ missing clause (add it) or scope creep (cut it).
232
+
233
+ ## At final approval
234
+
235
+ Once the plan is finally approved (its last review Approved with no further
236
+ edits to the plan):
237
+
238
+ 1. Flip the capability doc's frontmatter to **`status: planned`** — or, when
239
+ the doc is `built` and this plan adds or supersedes a clause, to
240
+ **`status: amending`** with **`plan: docs/plans/YYYY-MM-DD-<feature>.md`**
241
+ naming this plan (`primitives-format` § Evaluations). A plan with no intent
242
+ delta leaves a `built` doc at `built`: every clause already has its row.
243
+ 2. Append **one** provenance line covering the whole planning session — one
244
+ line per event, not per edit, and nothing about how the plan got written
245
+ (`primitives-format` § Provenance):
246
+
247
+ ```markdown
248
+ - YYYY-MM-DD — planned: docs/plans/YYYY-MM-DD-<feature>.md. [Rejected
249
+ alternatives from the header's Alternatives considered, one line.]
250
+ ```
251
+
252
+ 3. Add or update the capability's line in `docs/primitives/index.md`.
253
+
254
+ ## When the plan is revised
255
+
256
+ **Primitives sync (when the tree exists):** classify the revision. Tactics
257
+ only (snippets, file map, task order) → capability doc untouched. Changes to
258
+ **what the feature does** (scope, outcome) → amend the Intent clauses in the
259
+ same edit as the plan (add / supersede; pre-approval clauses not yet
260
+ referenced by an approved plan may simply be edited). No provenance line per
261
+ revision — the single `planned` line at final approval covers the session.