@inixiative/config 0.5.260 → 0.5.262
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.
- package/README.md +18 -0
- package/dist/cli.js +545 -175
- package/package.json +3 -1
- package/skills/cleanup-scan/SKILL.md +89 -0
- package/skills/code-walkthrough/SKILL.md +29 -0
- package/skills/experiment/SKILL.md +79 -0
- package/skills/experiment/design.md +44 -0
- package/skills/experiment/finding.json +16 -0
- package/skills/experiment/review.md +33 -0
- package/skills/labeling/SKILL.md +40 -0
- package/skills/no-slop-writing/SKILL.md +69 -0
- package/skills/no-slop-writing/references/register-anchors.md +64 -0
- package/skills/no-slop-writing/references/slop-quarantine.md +97 -0
- package/skills/permissions-syntax-first/SKILL.md +142 -0
- package/skills/probe/SKILL.md +74 -0
- package/skills/probe/record.json +24 -0
- package/skills/reflecting-without-flinching/SKILL.md +32 -0
- package/skills/review-adversarial/SKILL.md +39 -0
- package/skills/review-dedupe/SKILL.md +38 -0
- package/skills/review-naming/SKILL.md +35 -0
- package/skills/review-plan/SKILL.md +38 -0
- package/skills/review-subtractor/SKILL.md +48 -0
- package/skills/worktrees/SKILL.md +57 -0
- package/standards/CODE_STYLE.md +83 -0
- package/standards/ENGINEERING_DOCTRINE.md +84 -0
- package/standards/GREAT_PROGRAMMER.md +128 -0
- package/standards/NAMING_VOCABULARY.md +72 -0
- package/standards/SKILL_AUTHORING.md +55 -0
- package/versions.json +7 -7
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: permissions-syntax-first
|
|
3
|
+
description: Use whenever work touches permissions, auth, tokens, integrations, members, entitlements, the rebac schema (packages/permissions/src/rebac/schema.ts), route permission middleware, or any code that allows, denies, throws 401/403/422, filters or clips. Express the decision in the rule syntax first; anything outside the system needs a justification that survives the user and an adversary.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Permissions: syntax first
|
|
7
|
+
|
|
8
|
+
The permission system is the schema plus the library's check. Its syntax reads any path on the hydrated record and on the actor, so almost every question ("is this yours?", "which owner is this?", "may you set this role?") is a condition in a rule. Most mistakes in this area come from building outside it: a new action, a helper, a hook, a validator, a controller 403, a substitution in code. **If you are not using the system, you are allowed zero checks** — anything outside it is justified to the user and an adversary, or it doesn't get written.
|
|
9
|
+
|
|
10
|
+
## 0. Scope: build the ruling, nothing next to it
|
|
11
|
+
|
|
12
|
+
The goal of a unit is the ruling's sentence, and the change ends there. When this work has gone wrong it has gone wrong the same way: a ruling left a "how" open, the gap was filled with a new mechanism, and that mechanism was then defended and extended instead of asking.
|
|
13
|
+
|
|
14
|
+
- **Every new function, option, callback, type, list or library export is named by a ruling.** A plan line, a review finding or my own reading is not a ruling. If the ruling leaves the how open, ask with the existing primitive you would use; never invent one to close the gap.
|
|
15
|
+
- **No hard-coded model lists.** Where a record sits comes from the polymorphism registry and the relations (`schemaMap`, `hydrate`), never from a list of models in code.
|
|
16
|
+
- **A problem gets the smallest fix inside what exists.** Before adding a layer, check whether `check`, `hydrate`, a json-rules option or a body refinement already answers it. A review finding is fixed at its own size; any new concept it suggests goes to the user as a question.
|
|
17
|
+
- **Library changes are the ruling's change only.** No new schema objects, refinements or exports beyond the ask. Validation of request bodies lives in `bodyRefinement` / `queryRefinement` / `paramsRefinement` (`docs/claude/API_ROUTES.md`), never as a `.refine` / `z.custom` on a schema object.
|
|
18
|
+
- **When the user asks "how did we rule on this", the answer is in `tmp/permissions-rulings.md`.** Read it before proposing; a question that a ruling already settles is never put back to the user.
|
|
19
|
+
- **Circling is the signal to stop.** If the same area comes back a second time with a new mechanism, stop building, quote the ruling and the existing primitive, and ask one question.
|
|
20
|
+
|
|
21
|
+
## 1. Read before you edit
|
|
22
|
+
|
|
23
|
+
- The running rulings doc (`tmp/permissions-rulings.md`; create it if missing — the user requires one). Process rule: every edit names the ruling it implements; no ruling, ask; don't edit.
|
|
24
|
+
- `docs/claude/PERMISSIONS.md`, Vocabulary section. Names are composed of vocabulary words: user, tenant (organization/space), member (OrganizationUser/SpaceUser), JWT, token, actor, owner, delegate (token or integration), permissions (`{ role, full, entitlements }`), anchor, entitlement, pseudo record. No aliases (`person`, `claim`, `hasUser` are wrong). Worked examples use user U1, organization O1, member M1 of O1, integration I1 on M1, token T.
|
|
25
|
+
|
|
26
|
+
## 1a. Disentangle before you design
|
|
27
|
+
|
|
28
|
+
Permissions questions tangle because one sentence mixes several parties and several kinds of access. Untangle mechanically before writing any rule:
|
|
29
|
+
|
|
30
|
+
**Step 1 — name the parties**, each with a vocabulary word:
|
|
31
|
+
- **actor**: who is making the request (a user via JWT or spoof, or a token). Says nothing about relationships.
|
|
32
|
+
- **user**: a person's account. Only a user is ever superadmin.
|
|
33
|
+
- **tenant**: organization or space (a space is a sub-tenancy of its organization).
|
|
34
|
+
- **member**: the row joining a user to an organization or space (OrganizationUser, SpaceUser); the only place a person's role at a tenant is stored. `operate` on it is being the member; `manage`/`own` on it administer it.
|
|
35
|
+
- **delegate**: something that acts for its owner: a token or an integration.
|
|
36
|
+
- **owner**: the immediate thing a delegate belongs to (owners all the way down).
|
|
37
|
+
- **permissions**: a delegate's `{ role, full, entitlements }`. Role = a narrowing of the tenant; entitlements = given by hand only; full = the owner's permissions whole and in sync.
|
|
38
|
+
- **entitlement**: a named grant `{ resource, anchor: { resource, id, path? }, where?, actions }`; **anchor**: the record it acts from, reached from the entitled record along `path` (relation names; none for a self anchor).
|
|
39
|
+
- **pseudo record**: the would-be row checked for a create or a collection action.
|
|
40
|
+
|
|
41
|
+
**Step 2 — put every requirement in exactly one bucket**, for the thing X it is about:
|
|
42
|
+
|
|
43
|
+
| Bucket | Question | Example: integration | Example: token |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| 1. Access to X | who can see or reach X | `read` on it | listing tokens |
|
|
46
|
+
| 2. Actions on X itself | who administers X | by its owner's kind: its user; `operate` on its member row; or `manage` at its tenant. No `own` | revoke, rename: the same split by owner kind |
|
|
47
|
+
| 3. X's access to other things | what X can reach: its owner, capped at its role | its role / entitlements / full, set at or below its owner | its role / entitlements / full, checked against the minter |
|
|
48
|
+
| 4. Acting with X, on its behalf | what X does as an actor | execution — out of scope (Signet) | requests made with the token (`actor:Acting.model == Token`) |
|
|
49
|
+
|
|
50
|
+
**Step 3 — never let one bucket answer another.** Every schema action is an action on the record (bucket 1 or 2), never an action the record takes. A bucket-2 fact ("M manages their integration") must not satisfy a bucket-3 check ("M may give a token admin access") — that merge produced a real bug. A bucket-4 fact (the actor is a token) is a condition on the actor, not on the thing.
|
|
51
|
+
|
|
52
|
+
**Step 4 — one named group per bucket in the schema** (e.g. `integrationAdministering`, `integrationAccess`), spread into the model's actions. If a requirement doesn't fit one bucket, it is two requirements.
|
|
53
|
+
|
|
54
|
+
## 2. What the syntax can say
|
|
55
|
+
|
|
56
|
+
An action rule (`ActionRule`) is one of:
|
|
57
|
+
- a string: another action on the same record (`manage: 'own'`);
|
|
58
|
+
- `null`: terminal — only a held grant passes;
|
|
59
|
+
- `{ rel: 'organization', action: 'own' }`: walk a hydrated to-one relation (dotted paths walk further: `'sourceSpace.organization'`) and ask an action there;
|
|
60
|
+
- `{ any: [...] }` / `{ all: [...] }`;
|
|
61
|
+
- `{ rule: <json-rules condition> }`: evaluated over the record and the supplied `actor:` rows (`actor:Acting.model`, `actor:User.*`, `actor:Token.*`). A condition reads any hydrated path (`field: 'integration.userId'`), compares to another path (`path: 'actor:User.id'`, with `exists` on the field beside it), and uses positive operators only (`equals`, `in`, comparisons; a null check takes an `exists` on its row's key beside it: `all: [id exists, role equals null]`). Negations, `isEmpty`, `notExists`, `if`/`then`/`else`, array and aggregate rules are refused (json-rules `validateRule(…, { positive: true })`).
|
|
62
|
+
|
|
63
|
+
The actor is `{ model: 'User' | 'Token', record }` (sanitized row). Rules read it by path; there are no binds and no other actor machinery.
|
|
64
|
+
|
|
65
|
+
Shared pieces already in `schema.ts` — reuse, don't re-derive:
|
|
66
|
+
- `actorIsUser` (`actor:Acting.model == User`), `actorIsDelegateOfUser` (a token is acting and `actor:Token.ownerModel == User`);
|
|
67
|
+
- `actorMayPerformActionOnOwner(action)`: walk a delegate's direct owner by `ownerModel`;
|
|
68
|
+
- `roleHeldAtOwner`: the role on the row is one the actor holds at the direct owner (owner `own`, admin `manage`, member `operate`, viewer `read`, via `roleToStandardAction`);
|
|
69
|
+
- `memberRowActions(tenant)`: a member row's `operate` and `leave` (`manage` on its user: reaching another tenancy through a user needs manage; `operate` on a user stays in that user's tenancy), `manage`/`own` (the tenant), `read`, `delegateFull`;
|
|
70
|
+
- `memberRoleWrite(tenant)`: manage the tenant and hold there the role being set; `memberRemoval(tenant)` = `leave` or `memberRoleWrite`; `integrationRoleWrite`: `delegateFull` on its owner, or `manage` on the integration and the role held at its owner. Rules routes and controllers check, never named actions;
|
|
71
|
+
- `integrationAdministering` / `integrationAccess`, `actorMayCreateTokenAtOwnerWithRole` / `tokenAdministering`: integrations and tokens administered by their owner's kind (tenant: the tenant's roles; member: `operate` on the member row, the tenant owner reads and deletes; user: the user);
|
|
72
|
+
- `delegateFull`: the person-only action on a delegate's owner that lets you set `full` (`validateFullGrant` checks it);
|
|
73
|
+
- `actorManagesRecordUser(at)`: `{ rel: `${at}user`, action: 'manage' }` — the user, or a delegate of the user at manage or above;
|
|
74
|
+
- `ownedByYouOrOrganizationOrSpaceYouManage(at)`: owned by an organization or space you may `manage`, or `actorManagesRecordUser(at)`;
|
|
75
|
+
- `ownerModelIsOneOf(owners, at)` and `actorMayPerformActionOnOwner(action, at, owners)` with a path prefix (e.g. `'integration.'`): the one per-owner expansion; pass the owner models a rule covers instead of a separate gate.
|
|
76
|
+
|
|
77
|
+
Other parts of the system (use them, don't parallel them):
|
|
78
|
+
- `placeEntitlement` + `canGrantEntitlement` (library, over `schemaMap`) — the only check for writing entitlements, validity included; entitlements are `Entitlement` rows and change only through the holder's sub-resource (`GET …/:id/entitlements` lists rows with ids, `POST` with entries, `DELETE` with row ids) via the one writer `changeEntitlements`, every added entry and removed row through that check, never a record update;
|
|
79
|
+
- `RulesRegistry` json-rules write rules, enforced by the rules hook — a row's own columns only (`full` takes no role; where `full` may be set). Nothing in a rules object reads an entitlement or its anchor. A non-full delegate with no role and no entitlements is not refused; it holds nothing. Don't call `validateRules` from controllers;
|
|
80
|
+
- hydration / the lens — relations come from hydrating, never from copying keys;
|
|
81
|
+
- the one `full` skip at install (`narrowOwnerPermissionsToDelegate`);
|
|
82
|
+
- the `memberSelfGrant` hook: every member row carries `operate` on itself as an entitlement row anchored at itself with no `where`, written after the member is created, backed by its user (`memberSelfGrant`, matched by `isMemberSelfGrant`); `permissionsOfUser` routes it to the user and everything else to the tenant. Unlensed and unconditional, it grants below the member row: a `full` delegate of M1 grants over M1's own integrations (`entitlementEntriesOfHolder` marks every row with no `where` and no lens `grantsBelow`; PERMISSIONS.md § Granting below a held row).
|
|
83
|
+
|
|
84
|
+
## 3. Pseudo records
|
|
85
|
+
|
|
86
|
+
An action on something that does not exist yet, or on a collection, is checked on a **pseudo record of the model it is about**, placed under its owner, through the ordinary check:
|
|
87
|
+
|
|
88
|
+
- **Create:** build the would-be row, hydrate it, check `create` on that model:
|
|
89
|
+
```ts
|
|
90
|
+
const standIn = await hydrate('token', { id: '', ...row } as HydratedRecord);
|
|
91
|
+
check(permix, rebacSchema, 'token', standIn, TokenAction.create);
|
|
92
|
+
```
|
|
93
|
+
The rule for creating a token lives on `db:token`, never on its owner (`token.create` on organization/space/user was the bug behind a bypass: stored actions on a member's organization entry satisfied it).
|
|
94
|
+
- **Collections are pseudo records too** (user, 10-26): `validateSubmodelPermission(action)` checks the action on a pseudo record of the route's submodel under the loaded owner (from the polymorphism registry); it never reads the body. Lists that are really "which of these can I see" (spaces of an organization, member-shaped lists, customers, segment memberships, inquiries) stay a model check on the real owner until AUTH-008.
|
|
95
|
+
- **Role writes** (members, integrations) need the body, so they run in the controller: `memberRoleWrite` / `integrationRoleWrite` on the row as it is and on the row as it will be.
|
|
96
|
+
- **Grants:** the library's `placeEntitlement` builds one pseudo record per kind the entry reaches, from the hydrated anchor down the path (each step's known foreign keys, each owner placed under the anchor), and `canGrantEntitlement` checks each action on every one. A polymorphic step reaches every kind that carries its keys (`organization` on an integration = the org's, its spaces', its members'); the `where`'s root leaves (the `where`, or each leaf of its top `all`) on the kind field narrow the first step's kinds, each checked with json-rules; the path already fixes the keys, so leaves on them narrow nothing. `canGrantEntitlement` is two passes: the writer's role table alone (no entitlements, no actor — person-only actions are never grantable), else one held entitlement passed on whole (same resource and anchor, actions held or lowered by pure delegation, `where` copied or narrowed, its granter still backing it). Held entitlements never combine.
|
|
97
|
+
|
|
98
|
+
## 4. Rules from this branch (what went wrong and the syntax answer)
|
|
99
|
+
|
|
100
|
+
| Built outside the system | The syntax answer |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `token.create` copied onto six owner models | `create` on a pseudo record `db:token` |
|
|
103
|
+
| actions named after other models (`organization.create` on user) | each action on its own model (test: a dotted action is named after its model) |
|
|
104
|
+
| a `yours` action to hop to the integration | a path condition: `ownedByYouOrOrganizationOrSpaceYouManage('integration.')` |
|
|
105
|
+
| `leave` as an alternative that skipped the role check | the role check always runs; "yours" is an extra requirement |
|
|
106
|
+
| `full` arms in the schema | `full` is inheritance: skipped at install (`narrowOwnerPermissionsToDelegate`); setting it takes `delegateFull` on the owner (`validateFullGrant`). CI rule `rebac-schema-never-reads-full` |
|
|
107
|
+
| deciding who is related to what by comparing `actor:` ids | an action on the record: acting as a member is `operate` on the member row; actor rules only gate person-only actions |
|
|
108
|
+
| a role token acting as its member by default | `operate` on the member row: held by `full`, or given by hand as an entitlement |
|
|
109
|
+
| write-time "ceiling" with a trim in `validateDelegateGrant` | `roleHeldAtOwner` + `memberRoleWrite`/`integrationRoleWrite` + `canGrantEntitlement` |
|
|
110
|
+
| copying carried owner keys onto a pseudo record | hydrate the relation and read it |
|
|
111
|
+
| explicit `validateRules` in controllers | the rules hook |
|
|
112
|
+
| a library clause special-casing "conditional" actions | removed in 0.8: the owner walk already re-runs the rule's conditions |
|
|
113
|
+
| `greaterRole` folded into one role check | two checks: the role-write rule on the row as it is and as it will be |
|
|
114
|
+
| members' extra actions stored flat on the role table | entitlements `{ resource, anchor, actions }` like delegates (queue item 15) |
|
|
115
|
+
| a second traversal returning conditions ("proofs") to carry into a grant | the ordinary check on a pseudo record pinned by the `where`'s exact `equals` values; missing fields read as unknown (json-rules `absent: 'unknown'`) |
|
|
116
|
+
| splitting a `where` into branches, one pseudo record each | one pseudo record; anything not pinned exactly stays unknown, so a filtered writer is refused |
|
|
117
|
+
| narrowing what an entitlement reaches to patch a grant-check hole (direct owner, one branch per path) | the path names the anchor and axis, every kind on it is reached, the `where` narrows; the grant judges every kind it reaches |
|
|
118
|
+
| an "own the tenant/anchor" escape hatch beside the grant check | the normal check on the placed pseudo record, nothing else |
|
|
119
|
+
| `z.custom` / `.refine` on a schema object for rule validation | shape-only schemas; validation in a reusable body refinement |
|
|
120
|
+
|
|
121
|
+
## 4a. Principles, in the user's words
|
|
122
|
+
|
|
123
|
+
- "the entitlement is supposed to grant whatever it says... making other machinery around it is a bit bad smelly"
|
|
124
|
+
- "One thing that checks if you can assign a member or integration a role. One thing that detects if you can write the token from your perspective. One thing that... grants some entitlements. One machine that skips for full. We shouldn't have multiple copies."
|
|
125
|
+
- "everything that we need already exists. Please verify... before you're writing new functions"
|
|
126
|
+
- "The syntax is very robust. The fact that you keep trying to build things outside of it is the source of half of our problems."
|
|
127
|
+
- "Actor is just: are you a user or a token? It doesn't say anything about your relationships." Only a JWT or a spoof is a user.
|
|
128
|
+
- "you shouldn't be able to do things for other people's members or integrations. If it is a member and it's not you, no."
|
|
129
|
+
- An integration has three parts: administering it, its access to its owner, its executions (out of scope).
|
|
130
|
+
- "Are we making things simpler?"
|
|
131
|
+
- "Everything just is on."
|
|
132
|
+
- "If the owner is a tenant, you need to be an admin. If the owner is a member, you need to be operate for admin. There's no own, I think, for integration."
|
|
133
|
+
- "Actor things are for stuff that we don't want tokens doing, not for trying to determine the relationship graph"
|
|
134
|
+
|
|
135
|
+
## 5. Procedure
|
|
136
|
+
|
|
137
|
+
1. Name the ruling.
|
|
138
|
+
2. Write the decision as a rule over the hydrated record + the `actor:` rows, reusing section 2's pieces. Prefer a condition on a path over a new action, helper or code.
|
|
139
|
+
3. If it truly can't be written: write one paragraph — what it decides, why the syntax can't say it — show the user, and stop until they approve.
|
|
140
|
+
4. Tests first, in the user's sentences, including attempts to get around the rule (another user's row, a token actor, a lower role, a different tenant). Factories only.
|
|
141
|
+
5. One change at a time: an adversarial pass on the plan before building, then on the change. Behaviour changes beyond the ask are proposals, never applied.
|
|
142
|
+
6. Before committing: `bash scripts/ci/run-ci-rules.sh`, the permissions and API suites, and an adversarial pass on just the change.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: probe
|
|
3
|
+
description: Use before running ANY quick measurement of Foundry, Chorus, agent-session or a Warden host that is too small for the full experiment pipeline — a timing check, a "does this even work" run, a load or cache probe, a curve over sizes. Gives every such run one record shape (what ran, on what versions, under what machine load, what it measured) written to one place, so results compare over time. Use the `experiment` skill instead whenever the run answers "is X better than Y" for a decision, spends more than a few dollars, or needs a design review.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Probes: small measurements, recorded the same way every time
|
|
7
|
+
|
|
8
|
+
**Canonical copy:** `@inixiative/config` (`skills/probe/`), materialized into `.claude/skills/inixiative-probe/` by `inixiative-config standards`. Edit in `inixiative/config`, never in a consumer repo.
|
|
9
|
+
|
|
10
|
+
Aron, 2026-11-19: "We should make some standard things: how we test things, what the load was throughout the test, and whether we're tracking it… We should have a standard way of doing experiments and recording them so that we can compare over time and we're not just doing them ad hoc." Why: on 2026-11-18/19 a dozen probes ran ad hoc at machine loads from 40 to 350; their numbers sat in a scratch folder and a chat, some were unreadable because of the load, and none could be compared with the next day's.
|
|
11
|
+
|
|
12
|
+
A probe **records a result and decides nothing**. It is the small tier below the [`experiment`](../inixiative-experiment/SKILL.md) skill, and shares its rules: Aron decides; private text stays under `~/.foundry/evals/`; at most 3 agents on the account; never work around a gate.
|
|
13
|
+
|
|
14
|
+
## When it is a probe, and when it is an experiment
|
|
15
|
+
|
|
16
|
+
A probe: one question, minutes not hours, a cost you can state in advance and that stays under about $3 at list prices, no fixtures drawn from sessions, no accuracy claim. Anything else, or anything whose result would be used to choose between designs, is an experiment: design, adversarial review, tiny test, serial run.
|
|
17
|
+
|
|
18
|
+
A probe may show that something works, breaks, or roughly how long it takes. It may not be the reason a default changes; it is the reason to run the experiment.
|
|
19
|
+
|
|
20
|
+
## 1. Before: write the question and the baseline
|
|
21
|
+
|
|
22
|
+
In `~/.foundry/evals/probes/<date>-<name>/README.md`, before the first call:
|
|
23
|
+
- **Question**, in one sentence (Aron's words, dated, if he asked it).
|
|
24
|
+
- **What varies** and what is held fixed.
|
|
25
|
+
- **What would count as an answer**, written now ("held again in under 5 s", "errors or not").
|
|
26
|
+
- **Cost ceiling** and how it was estimated.
|
|
27
|
+
|
|
28
|
+
Then run the **standard baseline** once, first, in the same session: 32 synthetic Wardens in today's host layout, two reloads (`bun scripts/diagnose-setup.ts --roles 32 --dispatchers 4 --builders 1 --charter --rounds 2` in agent-session). Its numbers say whether this session is comparable with earlier ones: if its setup or reload time is more than 1.5× the last quiet baseline, say so in the record and treat every timing in the session as an upper bound.
|
|
29
|
+
|
|
30
|
+
## 2. During: one run at a time, with the machine recorded
|
|
31
|
+
|
|
32
|
+
- **Runs go in sequence**, never beside each other or beside a full check, a live re-record or another eval of yours (Aron, 2026-11-19: "run these… in sequence, so they're not in parallel, taking up resources").
|
|
33
|
+
- **Sample the machine through every run**: `python3 ~/.foundry/evals/host-scaling/bin/sample.py <run>/machine.jsonl <pid>` (1-minute load, CPU of the run's own process tree and of everything else, every 2 s).
|
|
34
|
+
- **Record what the run itself felt**, not only the machine: per call, the time waiting on the model against the time in our own code, where the tool can tell them apart. A slow run is the model's, the machine's or ours; the record should let a reader say which.
|
|
35
|
+
- **Timestamps**: when the question is "parallel or in sequence", record events per second (answers, starts, holds), not only totals.
|
|
36
|
+
|
|
37
|
+
## 3. After: one record per run
|
|
38
|
+
|
|
39
|
+
Write `<run>/record.json` in this shape ([record.json](record.json)); numbers only, no prompt or answer text:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"probe": "<date>-<name>",
|
|
44
|
+
"run": "<arm or size>",
|
|
45
|
+
"question": "<one sentence>",
|
|
46
|
+
"varied": { "<name>": "<value>" },
|
|
47
|
+
"fixed": { "<name>": "<value>" },
|
|
48
|
+
"environment": {
|
|
49
|
+
"date": "YYYY-MM-DDTHH:MMZ",
|
|
50
|
+
"machine": { "cores": 0, "load1": { "start": 0, "median": 0, "max": 0 }, "ownCpuPct": { "median": 0 }, "outsideCpuPct": { "median": 0, "max": 0 } },
|
|
51
|
+
"versions": { "claudeCode": "", "agentSession": "", "foundry": "<commit>", "harness": "<commit or script hash>" },
|
|
52
|
+
"models": ["<model id and effort>"],
|
|
53
|
+
"login": { "sevenDayBefore": 0, "sevenDayAfter": 0 },
|
|
54
|
+
"baseline": { "ref": "<this session's baseline run>", "setupMs": 0, "reloadMs": 0, "comparable": true }
|
|
55
|
+
},
|
|
56
|
+
"measures": { "<name>": 0 },
|
|
57
|
+
"n": 0,
|
|
58
|
+
"cost": { "listUsd": 0, "how": "<tokens priced at list rates | estimate>" },
|
|
59
|
+
"notMeasured": ["<what this run cannot say>"]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`environment.baseline.comparable` is false when the session's baseline was off or the load during the run was more than twice the baseline's; such a run is reported with its numbers and the words "not comparable".
|
|
64
|
+
|
|
65
|
+
## 4. Report and file
|
|
66
|
+
|
|
67
|
+
- Say the result against what was written in step 1, with n, and what was **not** measured.
|
|
68
|
+
- Two runs are compared only when both are `comparable`; otherwise the comparison is stated as not readable.
|
|
69
|
+
- Add one dated line to `chorus/docs/HISTORY.md` (the question, the result with n, the record's path) and, when it changes what is true of the running system, to `chorus/docs/STATE.md`.
|
|
70
|
+
- A result that should change a design becomes an experiment: name it in `TRACKING.md` or start its design.
|
|
71
|
+
|
|
72
|
+
## What does not change
|
|
73
|
+
|
|
74
|
+
No default, setting, doc standard or CLAUDE.md line is written from a probe.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"probe": "",
|
|
3
|
+
"run": "",
|
|
4
|
+
"question": "",
|
|
5
|
+
"varied": {},
|
|
6
|
+
"fixed": {},
|
|
7
|
+
"environment": {
|
|
8
|
+
"date": "",
|
|
9
|
+
"machine": {
|
|
10
|
+
"cores": 0,
|
|
11
|
+
"load1": { "start": 0, "median": 0, "max": 0 },
|
|
12
|
+
"ownCpuPct": { "median": 0 },
|
|
13
|
+
"outsideCpuPct": { "median": 0, "max": 0 }
|
|
14
|
+
},
|
|
15
|
+
"versions": { "claudeCode": "", "agentSession": "", "foundry": "", "harness": "" },
|
|
16
|
+
"models": [],
|
|
17
|
+
"login": { "sevenDayBefore": 0, "sevenDayAfter": 0 },
|
|
18
|
+
"baseline": { "ref": "", "setupMs": 0, "reloadMs": 0, "comparable": true }
|
|
19
|
+
},
|
|
20
|
+
"measures": {},
|
|
21
|
+
"n": 0,
|
|
22
|
+
"cost": { "listUsd": 0, "how": "" },
|
|
23
|
+
"notMeasured": []
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reflecting-without-flinching
|
|
3
|
+
description: Use when asked to reflect or evaluate philosophically on a body of work ("wdyt", "what do you think philosophically", a retrospective), or when proactively stepping back after a long or winding piece of work. For producing a grounded, self-critical synthesis — not platitudes, a victory lap, or a list of lessons.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Reflecting Without Flinching
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
A request to reflect philosophically ("wdyt?", "what did this teach us?", a retrospective) is an invitation to find the *through-line* — the one pattern that explains what actually happened — and to say it honestly, including the parts that don't flatter you. The default is comfortable and useless: generic lessons ("we learned to value testing"), a victory lap ("great collaboration, solid execution"), a flat list of observations with no claim, or hedging. None of those are reflection; they're noise that feels like closure.
|
|
11
|
+
|
|
12
|
+
## What a real reflection does
|
|
13
|
+
|
|
14
|
+
1. **Find ONE through-line, not a list.** The synthesis is a single claim that *explains multiple events* at once — ideally one you'd argue for and could be wrong about. A list of disconnected lessons is the tell that you didn't find the pattern. (e.g. "every shortcut taken to save time created a slower path later" ties a dozen scattered decisions into one claim.)
|
|
15
|
+
2. **Ground every claim in what actually happened.** Cite the real decisions, missteps, and reversals — not aphorisms. If a sentence would be true of any project, cut it. A good reflection is impossible to copy-paste onto different work.
|
|
16
|
+
3. **Turn the lens on yourself first.** Name your *own* failures before anything else — where you were confident and wrong, what you missed that others caught. A reflection that critiques the process, the tools, or "we" while sparing the author is the flinch. "I was the source of two of these" beats "mistakes were made."
|
|
17
|
+
4. **Land a thesis, don't hedge.** End on a claim, not "it depends" or "on one hand / on the other." If you genuinely see two forces in tension, say which one wins and why.
|
|
18
|
+
5. **Include the uncomfortable caveat.** State where the work is still *not* clean, where you'd stay skeptical, what you'd watch break. Honesty about the unresolved is what separates reflection from a wrap-up.
|
|
19
|
+
6. **Resist the over-correction.** Don't swing from "it went great" to "it all went wrong." Say plainly what genuinely worked, so the critique of what didn't is credible.
|
|
20
|
+
|
|
21
|
+
## Red flags — you're flinching
|
|
22
|
+
|
|
23
|
+
- Generic lessons true of any project ("communication matters", "testing is valuable").
|
|
24
|
+
- A victory lap / crediting "the collaboration" instead of naming what was hard.
|
|
25
|
+
- A bulleted list of observations with no unifying claim.
|
|
26
|
+
- "On one hand… on the other… it depends." (Pick one. Defend it.)
|
|
27
|
+
- Critiquing the process / tools / "we" but not your own calls.
|
|
28
|
+
- Reflecting only on the last step, not the whole arc.
|
|
29
|
+
|
|
30
|
+
## Bottom line
|
|
31
|
+
|
|
32
|
+
The deliverable is one defensible claim that explains the arc, grounded in what actually happened, with your own failures named first. If it would flatter you to say it, or it would fit any project, you haven't reflected yet.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-adversarial
|
|
3
|
+
description: Part 1 of the `adversarials` 4-pass review suite. Use whenever asked to run "adversarials" or before acting, reporting, or merging any plan, spec, fixture set, eval result, or outgoing code diff. Tries to break correctness, security, auth/tenant boundaries, concurrency, data integrity, API/schema contracts, and style consistency — returning reproduced findings and an APPROVE or REQUEST_CHANGES verdict.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Adversarial Review (Correctness, Security & Style Consistency)
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
The author of a change is anchored on the happy path and the premise they built inside. Passing tests only confirm what the author thought to assert; they miss boundary failures, races, leaked state, stale fallbacks, and subtle style drift that compounds into unreadable codebases. An independent reviewer trying to break the change catches defects and consistency drift before they land.
|
|
11
|
+
|
|
12
|
+
## Scope
|
|
13
|
+
|
|
14
|
+
Inspect the full diff (`git diff origin/<default-branch>...HEAD` plus untracked/uncommitted files) and the surrounding modules it interacts with. Treat the author's summary as an unverified claim, never as truth.
|
|
15
|
+
|
|
16
|
+
## Attack Surfaces
|
|
17
|
+
|
|
18
|
+
1. **Correctness & edge cases:** off-by-one errors, null/undefined/empty inputs, swapped relation or polymorphic sides, stale caches, silent partial failures, unhandled error paths, mutation of caller-owned inputs during async work.
|
|
19
|
+
2. **Security, auth & tenant boundaries:** privilege escalation, missing or bypassed permission checks, cross-tenant data leaks, spoofing holes, unvalidated external input, unbounded work/DoS, secret leaks in responses or logs.
|
|
20
|
+
3. **Data integrity & concurrency:** races across concurrent requests/jobs, check-then-act outside a transaction or lock, non-atomic multi-step writes, soft-delete leaks, stored-value or schema changes missing a migration/port note.
|
|
21
|
+
4. **Contracts & callers:** signature changes with stale callers, tests, types, or docs; swallowed errors (`catch` without rethrow or real state action); unintended behavioral changes.
|
|
22
|
+
5. **Parallel machinery & cutouts:** new code duplicating an existing primitive or bolting an invariant-bypassing cutout onto a primitive instead of fixing the general rule.
|
|
23
|
+
6. **Stale plumbing & superseded invariants:** after an architectural change or refactor round, surviving fallbacks, double-checks, dead branches, wrappers, routes, or tests left over from the previous design. Never ask the author to *harden* a superseded or unreachable path — flag it as a blocking deletion instead.
|
|
24
|
+
7. **Style & structural consistency (`docs/standards/CODE_STYLE.md`):** enforce consistent style across every touched file — flat controller-style early exits (no nested `if`/`else` pyramids or nested ternaries), step-by-step readable decomposition (no dense monolithic multi-phase functions), atomic files, `lodash-es` over hand-rolled object-transform loops, direct throws with no Go-isms (`{ ok }` unions / `*OrThrow` twins / redundant pre-checks), and zero narrating comments.
|
|
25
|
+
8. **Tests & verification:** tests that mock away real behavior, assertions that pass trivially, untested failure paths, or unrun checks.
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
|
|
29
|
+
- **Prove every blocking finding.** Cite exact `file:line` and show a concrete trace, failing input, or reproduced test/command output.
|
|
30
|
+
- **Distinguish defects from intended behavior.** When an effect is the explicit, intended outcome of a requirement the user specified, do not flag it as a bug or reopen the design; note it only if it is undocumented or violates a separate invariant.
|
|
31
|
+
- **Keep style consistent.** Style consistency is a first-class readability requirement, not a nitpick — flag violations of `docs/standards/CODE_STYLE.md` cleanly.
|
|
32
|
+
- **Separate severity cleanly:** `Blocking` (must fix before landing) vs `Non-blocking` (optional hardening or follow-up).
|
|
33
|
+
|
|
34
|
+
## Output Format
|
|
35
|
+
|
|
36
|
+
1. **Verdict:** `APPROVE` or `REQUEST_CHANGES`
|
|
37
|
+
2. **Blocking Findings:** numbered list — title, `file:line`, concrete proof/reproduction, minimal fix.
|
|
38
|
+
3. **Non-Blocking Findings:** concise bullets if any.
|
|
39
|
+
4. **Confirmed Clean:** 2–4 bullets naming what you explicitly checked and verified safe.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-dedupe
|
|
3
|
+
description: Part 3 of the `adversarials` 4-pass review suite. Use whenever asked to run "adversarials" or before reporting non-trivial work or publishing any package. Runs a full-package and cross-repo duplication audit by building a concept inventory across the whole repo, lower-level libraries, and sibling repos first — requiring an actual run before accepting any "it doesn't fit" claim.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Full-Package & Cross-Repo Duplication Audit
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
Parallel machinery is the biggest source of drift across a multi-repo codebase. A diff-only review misses helpers that already live elsewhere in the package, in a lower-level library, or in a sibling repo — and verbal claims that an existing primitive "doesn't quite fit" routinely collapse the moment the case is actually run against it (`docs/standards/ENGINEERING_DOCTRINE.md` §3).
|
|
11
|
+
|
|
12
|
+
## Scope
|
|
13
|
+
|
|
14
|
+
Your scope is the **entire package, lower-level `@inixiative/*` libraries, standard utilities (`lodash-es`), and sibling repos** — never just the diff in isolation.
|
|
15
|
+
|
|
16
|
+
## Procedure
|
|
17
|
+
|
|
18
|
+
1. **Inventory first (by concept, not name):**
|
|
19
|
+
- List every distinct job the diff performs (traversal, caching, locking, validation, auth/permissions, serialization, error mapping, query building, object/collection transforms, UI state, CLI parsing, etc.).
|
|
20
|
+
- Search by concept across:
|
|
21
|
+
1. The whole current repository (code search and map/index tools where available),
|
|
22
|
+
2. Every lower-level internal library it depends on (check each library's `docs/VERBS.md` and `src/`),
|
|
23
|
+
3. Sibling repositories where the same concern already has an owner.
|
|
24
|
+
2. **Judge the diff against the inventory:**
|
|
25
|
+
- Flag any new helper, utility, walker, validator, schema, hook, or component that re-implements or parallels an existing one.
|
|
26
|
+
- Flag hand-rolled object/collection transforms where `lodash-es` already provides the operation (`docs/standards/CODE_STYLE.md` §3).
|
|
27
|
+
- Flag the same job implemented in two repositories — **one repo owns it, the others consume it**.
|
|
28
|
+
3. **Enforce "run before claiming it doesn't fit":**
|
|
29
|
+
- Never accept a verbal argument that an existing primitive cannot handle the case.
|
|
30
|
+
- To clear a near-match, express the real case on the existing primitive and run it (or prove from its code/tests with exact line citations) why extending or composing it fails.
|
|
31
|
+
4. **Follow signature changes everywhere:**
|
|
32
|
+
- When a shared helper or export changes, verify no old copy, alias, or stale caller/doc remains.
|
|
33
|
+
|
|
34
|
+
## Output Format
|
|
35
|
+
|
|
36
|
+
1. **Verdict:** `APPROVE` or `REQUEST_CHANGES`
|
|
37
|
+
2. **Concept Inventory Checked:** short table mapping each touched concept → existing primitives/repos searched.
|
|
38
|
+
3. **Duplication Findings:** for each finding — new path, existing owner path, what to delete, and how to consume/extend the existing owner.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-naming
|
|
3
|
+
description: Part 4 of the `adversarials` 4-pass review suite. Use whenever asked to run "adversarials" or before pushing or publishing. Audits every file name, type, function, variable, schema field, route, export, test title, and doc term against docs/standards/NAMING_VOCABULARY.md, repo-local NAMING.md, library docs/VERBS.md, and retired terms — explicitly hunting within-diff synonym drift so one concept has one exact name everywhere.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vocabulary & Naming Consistency Review
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
A second name for the same concept is the same failure as a second implementation: it hides parallel machinery, forces every human and agent reader to mentally translate between synonyms, and lets code, tests, and docs drift apart. Checking vocabulary independently catches both rule violations and loose within-diff synonym drift that correctness reviews overlook (`docs/standards/NAMING_VOCABULARY.md`).
|
|
11
|
+
|
|
12
|
+
## Scope
|
|
13
|
+
|
|
14
|
+
Audit every file name, type, function, variable, parameter, schema field, route, export, test title, and doc/comment term introduced or changed in the diff against `docs/standards/NAMING_VOCABULARY.md`, repo-local `NAMING.md`, library `docs/VERBS.md`, and retired-term lists.
|
|
15
|
+
|
|
16
|
+
## Checklist
|
|
17
|
+
|
|
18
|
+
1. **Within-diff synonym drift (one concept, one exact word):** list the core domain concepts introduced or touched by the diff and verify every file name, type, variable, helper, test title, and doc uses the **exact same noun and verb** for each concept — never mixing loose synonyms across layers, files, or prose.
|
|
19
|
+
2. **Codebase concept reuse:** search the repository and lower libraries for each concept. If an established term already exists, use it instead of inventing a new one.
|
|
20
|
+
3. **Verbs match behavior:**
|
|
21
|
+
- `fetch*` for I/O reads; noun phrase (no verb) for pure in-memory lookups; `*OrThrow` when absence throws; **no new `get*`**.
|
|
22
|
+
- `make*` returns a function/handler/handle; `create*` writes records or builds adapter clients; `register*` mutates a registry; `define*` declares metadata only; `validate*`/`assert*` throws on failure; `is*`/`has*`/`can*` returns boolean.
|
|
23
|
+
4. **Literal, sentence-like labels:** read each name aloud as a short sentence. Rename anything cryptic, mechanism-focused, metaphorical, or misdescribing what the code actually does.
|
|
24
|
+
5. **Full model names in interfaces:** exported names, parameters, schema fields, and API payloads use full model names (never abbreviations in public contracts).
|
|
25
|
+
6. **Polymorphic sides:** `owner` (tenancy), `source`/`target` (directed edge), `resource` (one-sided slot), `subject` (log/event target), `actor` (who acted). Never `referenced*`.
|
|
26
|
+
7. **Soft-delete & field sensitivity:** `deleted` / `notDeleted` (never `live` for non-deleted rows); `sensitive` / `mask` / `redact` / `internal` / `no-op`.
|
|
27
|
+
8. **Shared-space IDs & casing:** namespaced through one central registry (no bare strings); model resources use `map:Model` casing; methods are `camelCase`, structured issue codes stay `snake_case`.
|
|
28
|
+
9. **Library `VERBS.md` & retired terms:** core library exports appear in `docs/VERBS.md` with a one-sentence meaning; zero retired terms reintroduced (`inixiative-config terms`).
|
|
29
|
+
|
|
30
|
+
## Output Format
|
|
31
|
+
|
|
32
|
+
1. **Verdict:** `APPROVE` or `REQUEST_CHANGES`
|
|
33
|
+
2. **Concept Vocabulary Checked:** short list of the diff's core concepts and the one canonical term used for each.
|
|
34
|
+
3. **Renames Required:** table of `Location` | `Current Name` | `Proposed Name` | `Rule`.
|
|
35
|
+
4. **Confirmed Clean:** brief summary of scopes checked.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-plan
|
|
3
|
+
description: Use before writing code on any semantic, architectural, or multi-file change to review the plan, 10-line prose flow, 20-40 line code specimen, diagram, primitive bridge analysis, and competing premises against prior decisions and engineering doctrine.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pre-Coding Plan & Bridge Review
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
Catching a flawed premise, missing primitive, or bloated abstraction on a 10-line plan and a 30-line code specimen takes two minutes; catching it after implementation costs hours of rewrite and review. Abstract prose makes bad designs sound reasonable — concrete shapes and competing edge cases expose holes immediately (`docs/standards/ENGINEERING_DOCTRINE.md` §3, §5, §6; `docs/standards/GREAT_PROGRAMMER.md` Principles 4, 7).
|
|
11
|
+
|
|
12
|
+
## Checklist
|
|
13
|
+
|
|
14
|
+
1. **Clear "why", plain prose, and a concrete code specimen:**
|
|
15
|
+
- Does the plan state the purpose in one sentence, walk the end-to-end flow in ~10 lines of plain prose, **and show a 20–40 line concrete code specimen** ("what is it going to look like?" — actual schema, type shape, registry, or call site, plus a simple diagram for multi-step mechanisms)?
|
|
16
|
+
- If the specimen or mechanism is missing or hand-waved, stop and write it before coding.
|
|
17
|
+
2. **Symmetrical premise check (when an assumption is in doubt or options compete):**
|
|
18
|
+
- Put the current premise and the alternative on equal footing: name both plainly, trace at least one hard concrete user intent for each without hand-waving over gaps (the holes are the point), compare the machinery delta, and check for self-inflicted objections caused by another assumption in doubt. Argue strictly from exposed holes and trade-offs, never sunk cost (`GREAT_PROGRAMMER.md` Principle 7).
|
|
19
|
+
3. **History & prior rulings check:**
|
|
20
|
+
- Does the plan contradict any standing decision, `CLAUDE.md` rule, repo doc, or prior git history? Name any conflict explicitly.
|
|
21
|
+
4. **Primitive map & bridge analysis:**
|
|
22
|
+
- For every concern touched, does the plan name the existing primitive and its path?
|
|
23
|
+
- For every `"new"` decision, does the bridge analysis show what was tried on the closest existing primitive and why extending/composing it fails? Reject `"doesn't match exactly"`.
|
|
24
|
+
- If the plan overrides or bypasses an existing system without explicit user acknowledgement, block and flag the question to ask.
|
|
25
|
+
5. **Premise smell & cutouts:**
|
|
26
|
+
- Does the plan introduce a new flag, bypass option, special-case mode, or second path to paper over a mismatch? Name the underlying premise flaw instead.
|
|
27
|
+
6. **Scope calibration (overbuild vs. underbuild):**
|
|
28
|
+
- Flag invented scope nobody asked for *and* incomplete foundations that would force an immediate v2.
|
|
29
|
+
- Surface genuine user-intent forks as concrete questions rather than guessing.
|
|
30
|
+
7. **Subtraction challenge:**
|
|
31
|
+
- Pair with `review-subtractor` to test whether 30–50% of the proposed surface area can be collapsed before writing line 1.
|
|
32
|
+
|
|
33
|
+
## Output Format
|
|
34
|
+
|
|
35
|
+
1. **Verdict:** `APPROVE` or `REQUEST_CHANGES`
|
|
36
|
+
2. **Blocking Plan Gaps / Premise Flaws:** concrete issues to resolve before writing code.
|
|
37
|
+
3. **Open Questions for the User:** only genuine forks that cannot be inferred from existing rules/code.
|
|
38
|
+
4. **Suggested Collapses:** any proposed new pieces that can fold into existing primitives.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-subtractor
|
|
3
|
+
description: Part 2 of the `adversarials` 4-pass review suite. Use whenever asked to run "adversarials", before coding (on a 10-line prose/diagram plan), before merge (on the full outgoing diff), and after every architectural or refactor round before pushing. Operates under an explicit 30-50% deletion mandate to collapse excess surface area into existing primitives, sweep stale/superseded plumbing across the whole touched subsystem, and reassess whether every surviving part still needs to exist.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Architectural Subtractor Review
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
Iterative coding and review rounds naturally accrete locally reasonable layers — a wrapper here, a fallback there, an extra route or flag to patch an earlier turn — and architectural refactors routinely wire up a new invariant while leaving old plumbing alive beside it. Bug-hunting (`review-adversarial`) and line-level deduping (`review-dedupe`) rarely delete whole layers. Code is read 10×–50× more than it is written, so an explicit deletion pass is required to keep surface area small and honest (`docs/standards/GREAT_PROGRAMMER.md`).
|
|
11
|
+
|
|
12
|
+
**Starting premise:** assume this plan or PR has **30–50% too much surface area** and that any architectural change left superseded plumbing behind. Cut surface area and strip every dead layer without losing required behavior.
|
|
13
|
+
|
|
14
|
+
## Checkpoints
|
|
15
|
+
|
|
16
|
+
1. **Pre-coding (cheap):** review the 10-line prose flow, code specimen, and any diagram *before* code is written. Every new part must justify why the simpler design before it failed.
|
|
17
|
+
2. **Pre-merge & every architectural/refactor round:** read the *entire* outgoing diff **and** every surviving file in the touched subsystem fresh — ignoring sunk cost from earlier turns — on **every** push after an architectural or multi-file refactor round (never skip later rounds).
|
|
18
|
+
|
|
19
|
+
## Pass 1 — Stale-Plumbing & Surviving-Parts Reassessment
|
|
20
|
+
|
|
21
|
+
Whenever a change introduces a new invariant or replaces an earlier mechanism:
|
|
22
|
+
|
|
23
|
+
1. **Name every invariant or mechanism that changed** (old model → new model).
|
|
24
|
+
2. **Trace the old mechanism across the whole touched subsystem** — not only lines in the latest commit diff. Find every caller, fallback, defensive guard, obsolete helper, dead branch, column, DTO, route, wrapper, test, and doc that only existed before the new invariant held.
|
|
25
|
+
3. **Reassess every surviving part** in the touched area: *under the new architecture, does this part still need to exist?* If it was only load-bearing under the previous design, mark it as a blocking deletion.
|
|
26
|
+
4. **Never harden dead plumbing:** if a refactor round added guards or tests around a path the new invariant already makes unreachable or unnecessary, delete the path instead of polishing it.
|
|
27
|
+
|
|
28
|
+
## Pass 2 — Challenge Every New Piece
|
|
29
|
+
|
|
30
|
+
For every new module, route, table/column, store, flag, option, or wrapper:
|
|
31
|
+
|
|
32
|
+
1. **Primitive absorption:** which existing primitive in this repo or its core libraries already owns this job or can absorb it directly?
|
|
33
|
+
2. **Fresh-eyes rebuild:** knowing everything we know now, if we built this from scratch in one pass, would this piece exist? If not, cut it.
|
|
34
|
+
3. **One concept, one place:** is one rule or invariant enforced in two places? Collapse it to one structural site.
|
|
35
|
+
4. **Cutout elimination:** does this add a bypass flag, escape hatch, or special-case mode to paper over a caller mismatch? Delete the cutout and fix the general rule.
|
|
36
|
+
5. **Module depth & step-by-step readability:** does this module hide real complexity behind a clean interface, or is it either a shallow pass-through wrapper or a dense monolithic function that should be broken into clear step-by-step helpers?
|
|
37
|
+
|
|
38
|
+
## Rules
|
|
39
|
+
|
|
40
|
+
- **Never rubber-stamp.** Even on a clean diff, list the top 2–3 pieces (new or surviving) you tried to delete and why each survived (or didn't).
|
|
41
|
+
- **Show the collapsed shape.** Whenever proposing a deletion or collapse, state in 2–4 lines how the existing primitive or new invariant handles the case without losing any requirement.
|
|
42
|
+
|
|
43
|
+
## Output Format
|
|
44
|
+
|
|
45
|
+
1. **Verdict:** `APPROVE` or `REQUEST_CHANGES`
|
|
46
|
+
2. **Superseded / Stale Parts Audited:** every changed invariant/mechanism traced across the touched subsystem, listing stale files, fallbacks, helpers, branches, routes, or tests to delete (or explicitly confirming none remain).
|
|
47
|
+
3. **Proposed Deletions / Collapses:** each with target path/concept, what replaces it, estimated surface reduction, and whether blocking.
|
|
48
|
+
4. **Tested & Survived:** the main new and surviving pieces you challenged and why they genuinely earn their keep.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worktrees
|
|
3
|
+
description: Use when starting feature work that needs isolation, when dispatching subagents that will edit code, or when managing existing worktrees across any inixiative repository. Teaches worktree-only discipline, when to use repo `bun run worktree:*` slot scripts vs plain `git worktree`, and cleanup after merge.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Worktrees
|
|
7
|
+
|
|
8
|
+
Never commit feature or fix work directly in a shared `main` checkout. Every repo has other sessions, daemons, or test runs reading its main checkout — work in an isolated worktree off `origin/main` and clean it up as soon as the branch merges.
|
|
9
|
+
|
|
10
|
+
## 1. Check whether this repo has slot worktree scripts
|
|
11
|
+
|
|
12
|
+
Inspect `package.json` for `worktree:create`:
|
|
13
|
+
|
|
14
|
+
### A. Repos with `bun run worktree:*` (`template`, `kingdom`, `tribe`)
|
|
15
|
+
|
|
16
|
+
These repos run Postgres, Redis, MinIO, and multiple apps with per-slot isolation (slots 1–9). **Always use the repo scripts — never raw `git worktree add/remove/move/prune`** (denied by hooks):
|
|
17
|
+
|
|
18
|
+
| Command | Use |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `bun run worktree:create <base> <new-branch> [--skip-db]` | Provision a new isolated worktree with its own slot ports, Postgres local+test DBs, MinIO buckets, Redis DB, `bun install`, generated Prisma/routes/SDK artifacts, and schema push. Pass `--skip-db` only for docs/skills edits that need no DB or tests. |
|
|
21
|
+
| `bun run worktree:create <existing-branch> [--skip-db]` | Attach an existing local or remote branch (e.g. reviewing a PR). |
|
|
22
|
+
| `bun run worktree:list` | List all active worktrees, slots, branches, and ports. |
|
|
23
|
+
| `bun run worktree:ports [<name>]` | Re-apply `@inixiative/config` registry ports to a checkout's env files. |
|
|
24
|
+
| `bun run worktree:destroy <name> [--force]` | Drop the slot's Postgres DBs, MinIO buckets, Redis DB, kill slot listeners, remove the git worktree, and free the slot. |
|
|
25
|
+
|
|
26
|
+
Why scripts instead of bare `git worktree`: bare `git worktree add` leaves no `node_modules` or generated artifacts, causing Bun to resolve up to `main`'s workspace links and collide on `main`'s DB/ports.
|
|
27
|
+
|
|
28
|
+
### B. Libraries and standalone repos without `worktree:create` (`config`, `foundry`, `oracle`, primitives)
|
|
29
|
+
|
|
30
|
+
Use standard git worktrees placed under `.worktrees/<name>` off `origin/main`:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git fetch origin main
|
|
34
|
+
git worktree add .worktrees/<name> -b <type>/<name> origin/main
|
|
35
|
+
cd .worktrees/<name> && bun install --frozen-lockfile
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
When merged and clean:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
git worktree remove .worktrees/<name>
|
|
42
|
+
git branch -d <type>/<name>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Never touch a shared `main` checkout that runs a live daemon (e.g. `foundry` serves `:4500` from its main checkout).
|
|
46
|
+
|
|
47
|
+
## 2. Subagents and working-directory resets
|
|
48
|
+
|
|
49
|
+
- **Subagents do not inherit your `cwd`** — they start at the main repo root. Always pass the exact absolute worktree path in the prompt: `Work entirely in <abs-path-to-worktree>. Do NOT touch the main repo path.`
|
|
50
|
+
- **Shell tools often reset `cwd` between calls.** Prefix commands with `cd <abs-worktree> && ...` or `git -C <abs-worktree> ...`.
|
|
51
|
+
- After a subagent finishes, check `git status` in both the worktree and the main checkout to verify nothing leaked into `main`.
|
|
52
|
+
|
|
53
|
+
## 3. Clean up after merge
|
|
54
|
+
|
|
55
|
+
- Confirm the branch is merged (for squash merges, verify via `git merge-tree --write-tree origin/main <branch>` or the merged PR's `headRefOid` — `git cherry` lies after squash merges).
|
|
56
|
+
- Destroy the worktree and delete the local branch so slots and disk stay free. Leave other sessions' unmerged worktrees alone.
|
|
57
|
+
- **Never run `git stash`** to switch or test — use a separate worktree or `git show HEAD:<path>` instead.
|