@xhulz/nina 0.63.1 → 0.64.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.
Files changed (133) hide show
  1. package/package.json +1 -1
  2. package/releases/0.64.0/core/GAPS.md +125 -0
  3. package/releases/0.64.0/core/answered.json +77 -0
  4. package/releases/0.64.0/core/defaults/tree/.claude/agents/architect.md +1 -0
  5. package/releases/0.64.0/core/defaults/tree/.claude/agents/dba.md +3 -0
  6. package/releases/0.64.0/core/defaults/tree/.claude/agents/devops.md +1 -0
  7. package/releases/0.64.0/core/defaults/tree/.claude/agents/implementer.md +1 -0
  8. package/releases/0.64.0/core/defaults/tree/.claude/agents/integration-tester.md +3 -0
  9. package/releases/0.64.0/core/defaults/tree/.claude/agents/qa.md +7 -0
  10. package/releases/0.64.0/core/defaults/tree/.claude/agents/reviewer.md +3 -0
  11. package/releases/0.64.0/core/defaults/tree/.claude/agents/secops.md +3 -0
  12. package/releases/0.64.0/core/defaults/tree/.claude/agents/solidity-auditor.md +3 -0
  13. package/releases/0.64.0/core/defaults/tree/.claude/agents/solidity-dev.md +3 -0
  14. package/releases/0.64.0/core/tree/.claude/agents/architect.md +133 -0
  15. package/releases/0.64.0/core/tree/.claude/agents/dba.md +119 -0
  16. package/releases/0.64.0/core/tree/.claude/agents/design-reviewer.md +76 -0
  17. package/releases/0.64.0/core/tree/.claude/agents/devops.md +118 -0
  18. package/releases/0.64.0/core/tree/.claude/agents/implementer.md +164 -0
  19. package/releases/0.64.0/core/tree/.claude/agents/integration-tester.md +170 -0
  20. package/releases/0.64.0/core/tree/.claude/agents/planner.md +132 -0
  21. package/releases/0.64.0/core/tree/.claude/agents/qa.md +150 -0
  22. package/releases/0.64.0/core/tree/.claude/agents/reviewer.md +187 -0
  23. package/releases/0.64.0/core/tree/.claude/agents/secops.md +120 -0
  24. package/releases/0.64.0/core/tree/.claude/agents/solidity-auditor.md +126 -0
  25. package/releases/0.64.0/core/tree/.claude/agents/solidity-dev.md +123 -0
  26. package/releases/0.64.0/core/tree/.claude/agents-overview.md +65 -0
  27. package/releases/0.64.0/core/tree/.claude/frontend.md +10 -0
  28. package/releases/0.64.0/core/tree/.claude/graph.md +79 -0
  29. package/releases/0.64.0/core/tree/.claude/patterns.md +251 -0
  30. package/releases/0.64.0/core/tree/.claude/pills/README.md +150 -0
  31. package/releases/0.64.0/core/tree/.claude/pipeline.md +101 -0
  32. package/releases/0.64.0/core/tree/.claude/retrieval.md +103 -0
  33. package/releases/0.64.0/core/tree/.claude/router.md +211 -0
  34. package/releases/0.64.0/core/tree/.claude/templates/integration.md +48 -0
  35. package/releases/0.64.0/core/tree/CLAUDE.md +166 -0
  36. package/releases/0.64.0/core/tree/scripts/cost-watch.mjs +25 -0
  37. package/releases/0.64.0/core/tree/scripts/edit-guard.mjs +24 -0
  38. package/releases/0.64.0/core/tree/scripts/harness-check.mjs +80 -0
  39. package/releases/0.64.0/core/tree/scripts/loop-gate.mjs +19 -0
  40. package/releases/0.64.0/core/vocabulary.json +14 -0
  41. package/releases/0.64.0/surfaces/blockchain/tree/.claude/agents/architect.md +5 -0
  42. package/releases/0.64.0/surfaces/blockchain/tree/.claude/agents/devops.md +5 -0
  43. package/releases/0.64.0/surfaces/blockchain/tree/.claude/agents/reviewer.md +5 -0
  44. package/releases/0.64.0/surfaces/blockchain/tree/.claude/agents/solidity-auditor.md +18 -0
  45. package/releases/0.64.0/surfaces/blockchain/tree/.claude/agents/solidity-dev.md +16 -0
  46. package/releases/0.64.0/surfaces/blockchain/tree/.claude/agents-overview.md +6 -0
  47. package/releases/0.64.0/surfaces/blockchain/tree/.claude/graph.md +11 -0
  48. package/releases/0.64.0/surfaces/blockchain/tree/.claude/router.md +6 -0
  49. package/releases/0.64.0/surfaces/blockchain/tree/CLAUDE.md +12 -0
  50. package/releases/0.64.0/surfaces/d1/tree/.claude/agents/dba.md +15 -0
  51. package/releases/0.64.0/surfaces/d1/tree/.claude/agents/devops.md +2 -0
  52. package/releases/0.64.0/surfaces/d1/tree/.claude/agents/implementer.md +2 -0
  53. package/releases/0.64.0/surfaces/d1/tree/.claude/patterns.md +8 -0
  54. package/releases/0.64.0/surfaces/d1/tree/CLAUDE.md +2 -0
  55. package/releases/0.64.0/surfaces/db/tree/.claude/agents/architect.md +5 -0
  56. package/releases/0.64.0/surfaces/db/tree/.claude/agents/dba.md +54 -0
  57. package/releases/0.64.0/surfaces/db/tree/.claude/agents/devops.md +5 -0
  58. package/releases/0.64.0/surfaces/db/tree/.claude/agents/implementer.md +2 -0
  59. package/releases/0.64.0/surfaces/db/tree/.claude/agents/integration-tester.md +10 -0
  60. package/releases/0.64.0/surfaces/db/tree/.claude/agents/planner.md +2 -0
  61. package/releases/0.64.0/surfaces/db/tree/.claude/agents/reviewer.md +22 -0
  62. package/releases/0.64.0/surfaces/db/tree/.claude/agents/secops.md +2 -0
  63. package/releases/0.64.0/surfaces/db/tree/.claude/agents-overview.md +5 -0
  64. package/releases/0.64.0/surfaces/db/tree/.claude/graph.md +8 -0
  65. package/releases/0.64.0/surfaces/db/tree/.claude/patterns.md +22 -0
  66. package/releases/0.64.0/surfaces/db/tree/.claude/pipeline.md +13 -0
  67. package/releases/0.64.0/surfaces/db/tree/.claude/retrieval.md +5 -0
  68. package/releases/0.64.0/surfaces/db/tree/.claude/router.md +4 -0
  69. package/releases/0.64.0/surfaces/db/tree/CLAUDE.md +17 -0
  70. package/releases/0.64.0/surfaces/drizzle/tree/.claude/agents/dba.md +9 -0
  71. package/releases/0.64.0/surfaces/drizzle/tree/.claude/agents/devops.md +5 -0
  72. package/releases/0.64.0/surfaces/drizzle/tree/.claude/agents/implementer.md +2 -0
  73. package/releases/0.64.0/surfaces/drizzle/tree/.claude/patterns.md +7 -0
  74. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/architect.md +14 -0
  75. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/dba.md +2 -0
  76. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/devops.md +29 -0
  77. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/implementer.md +14 -0
  78. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/integration-tester.md +11 -0
  79. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/qa.md +3 -0
  80. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/reviewer.md +8 -0
  81. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/agents/secops.md +8 -0
  82. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/patterns.md +17 -0
  83. package/releases/0.64.0/surfaces/edge-cf/tree/.claude/retrieval.md +8 -0
  84. package/releases/0.64.0/surfaces/edge-cf/tree/CLAUDE.md +27 -0
  85. package/releases/0.64.0/surfaces/frontend/tree/.claude/agents/architect.md +20 -0
  86. package/releases/0.64.0/surfaces/frontend/tree/.claude/agents/devops.md +28 -0
  87. package/releases/0.64.0/surfaces/frontend/tree/.claude/agents/implementer.md +25 -0
  88. package/releases/0.64.0/surfaces/frontend/tree/.claude/agents/qa.md +17 -0
  89. package/releases/0.64.0/surfaces/frontend/tree/.claude/agents/reviewer.md +56 -0
  90. package/releases/0.64.0/surfaces/frontend/tree/.claude/patterns.md +8 -0
  91. package/releases/0.64.0/surfaces/frontend/tree/.claude/retrieval.md +2 -0
  92. package/releases/0.64.0/surfaces/frontend/tree/.claude/router.md +14 -0
  93. package/releases/0.64.0/surfaces/frontend/tree/CLAUDE.md +5 -0
  94. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents/architect.md +16 -0
  95. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents/implementer.md +12 -0
  96. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents/integration-tester.md +20 -0
  97. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents/planner.md +2 -0
  98. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents/reviewer.md +21 -0
  99. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents/secops.md +2 -0
  100. package/releases/0.64.0/surfaces/integrations/tree/.claude/agents-overview.md +8 -0
  101. package/releases/0.64.0/surfaces/integrations/tree/.claude/graph.md +10 -0
  102. package/releases/0.64.0/surfaces/integrations/tree/.claude/patterns.md +38 -0
  103. package/releases/0.64.0/surfaces/integrations/tree/.claude/pipeline.md +16 -0
  104. package/releases/0.64.0/surfaces/integrations/tree/.claude/retrieval.md +16 -0
  105. package/releases/0.64.0/surfaces/integrations/tree/.claude/router.md +6 -0
  106. package/releases/0.64.0/surfaces/integrations/tree/CLAUDE.md +17 -0
  107. package/releases/0.64.0/surfaces/money/tree/.claude/agents/architect.md +12 -0
  108. package/releases/0.64.0/surfaces/money/tree/.claude/agents/dba.md +14 -0
  109. package/releases/0.64.0/surfaces/money/tree/.claude/agents/implementer.md +11 -0
  110. package/releases/0.64.0/surfaces/money/tree/.claude/agents/integration-tester.md +3 -0
  111. package/releases/0.64.0/surfaces/money/tree/.claude/agents/reviewer.md +23 -0
  112. package/releases/0.64.0/surfaces/money/tree/.claude/agents/secops.md +5 -0
  113. package/releases/0.64.0/surfaces/money/tree/.claude/agents/solidity-auditor.md +4 -0
  114. package/releases/0.64.0/surfaces/money/tree/.claude/agents/solidity-dev.md +4 -0
  115. package/releases/0.64.0/surfaces/money/tree/.claude/graph.md +2 -0
  116. package/releases/0.64.0/surfaces/money/tree/.claude/patterns.md +49 -0
  117. package/releases/0.64.0/surfaces/money/tree/.claude/pipeline.md +2 -0
  118. package/releases/0.64.0/surfaces/money/tree/.claude/retrieval.md +2 -0
  119. package/releases/0.64.0/surfaces/money/tree/CLAUDE.md +11 -0
  120. package/releases/0.64.0/surfaces/pii/tree/.claude/agents/dba.md +2 -0
  121. package/releases/0.64.0/surfaces/pii/tree/.claude/agents/devops.md +8 -0
  122. package/releases/0.64.0/surfaces/pii/tree/.claude/agents/reviewer.md +8 -0
  123. package/releases/0.64.0/surfaces/pii/tree/.claude/agents/secops.md +2 -0
  124. package/releases/0.64.0/surfaces/pii/tree/.claude/agents/solidity-auditor.md +5 -0
  125. package/releases/0.64.0/surfaces/pii/tree/CLAUDE.md +5 -0
  126. package/releases/0.64.0/surfaces/prisma/tree/.claude/agents/architect.md +2 -0
  127. package/releases/0.64.0/surfaces/prisma/tree/.claude/agents/dba.md +42 -0
  128. package/releases/0.64.0/surfaces/prisma/tree/.claude/agents/devops.md +11 -0
  129. package/releases/0.64.0/surfaces/prisma/tree/.claude/agents/implementer.md +2 -0
  130. package/releases/0.64.0/surfaces/prisma/tree/.claude/agents/integration-tester.md +2 -0
  131. package/releases/0.64.0/surfaces/prisma/tree/.claude/agents/reviewer.md +2 -0
  132. package/releases/0.64.0/surfaces/prisma/tree/.claude/patterns.md +15 -0
  133. package/releases/0.64.0/surfaces/prisma/tree/CLAUDE.md +5 -0
@@ -0,0 +1,123 @@
1
+ <!-- nina:requires blockchain -->
2
+ ---
3
+ name: solidity-dev
4
+ <!-- nina:slot project.1 description -->
5
+ tools: Read, Write, Edit, Glob, Grep, Bash, Skill
6
+ model: {{DEEP_MODEL}}
7
+ effort: {{DEEP_EFFORT}}
8
+ ---
9
+
10
+ ## Consult your pills first
11
+
12
+ Before acting, read your lessons. Handed their list as you start, open those whose trigger matches the task; with no list, read `.claude/pills/solidity-dev/*.md` and any `.claude/pills/shared/*.md` whose `applies_to` includes **solidity-dev**. Treat an active pill as binding whenever the current task matches its `trigger`. If a pill cites code that no longer exists, prefer current code and note the pill is stale. See `.claude/pills/README.md`.
13
+
14
+ ## Skills you MUST consult
15
+
16
+ Retrieval beats recall — the same standard as the `node_modules:<line>` premise rule. Invoke via the
17
+ `Skill` tool **before** acting, and only when the trigger matches; a skill pulled for a task it does
18
+ not cover is wasted context.
19
+
20
+ | Skill | Invoke when the change will touch… |
21
+ |---|---|
22
+ <!-- nina:slot blockchain.1 -->
23
+ <!-- nina:slot blockchain.2 -->
24
+ <!-- nina:slot blockchain.3 -->
25
+ <!-- nina:slot project.5 skills -->
26
+
27
+ Cite in your report which skills you consulted, or state that no trigger matched.
28
+
29
+ <!-- nina:slot project.2 role-intro -->
30
+
31
+ ## What makes this surface different from every other one
32
+
33
+ **Deployed code is immutable.** Everywhere else in this pipeline a defect is a patch away; here it is
34
+ a migration, a proxy upgrade, or a loss that cannot be reversed by anyone. Every rule below follows
35
+ from that one fact, and it is why a second gate exists for a diff this small.
36
+
37
+ Two consequences that change how you work:
38
+
39
+ - **There is no "fix it in the next release".** A contract ships or it does not. Work that is not
40
+ ready is `BLOCKED`, never merged with a follow-up note.
41
+ - **The adversary reads your source.** Everything you write is public and permanently callable by
42
+ anyone, in any order, at any block. "Nothing calls this" is not a property of deployed code.
43
+
44
+ ## Inputs
45
+ - An architect spec whose "Files to touch" includes contract sources, tests, or deploy scripts.
46
+ <!-- nina:slot blockchain.4 -->
47
+
48
+ ## Outputs
49
+ A diff containing the contracts, their tests, and nothing outside the spec's file list.
50
+
51
+ ## You MUST
52
+
53
+ - **Use the library rather than re-implement it.** Token standards, access control, pausing and
54
+ reentrancy protection all ship as audited components. A hand-written version of one of these is
55
+ rejected on sight — not because it is necessarily wrong, but because it is unreviewed code doing a
56
+ job that reviewed code already does.
57
+ - **Cite the library source for every premise, `path:line`.** "`_mint` is internal", "the modifier
58
+ reverts", "the initializer can only run once" — each is a claim about code you did not write, and
59
+ it carries a citation the same way an external-library premise does elsewhere in this pipeline.
60
+ Recall about a library version you are not on is how a storage collision ships.
61
+ - **Follow checks-effects-interactions.** Validate, then write state, then call out. An external
62
+ call is a transfer of control to code that may call you back before your first call returns.
63
+ - **Treat every external call as untrusted and every return value as load-bearing.** A call that
64
+ can fail silently is a bug even when the callee is "our own" contract today.
65
+ - **Write the adversarial test, not the happy path.** The suite must cover re-entry, the unauthorized
66
+ caller, the zero value, the boundary amount, and the second call that should fail. A suite that
67
+ only proves the intended flow proves nothing about a contract. Each test names, in its title or a
68
+ comment above it, the change to the contract that turns it red; the reviewer checks it.
69
+ - **Keep loops bounded.** An unbounded loop over caller-supplied data is a denial of service, and on
70
+ this surface a denial of service can be permanent.
71
+ - **Emit an event for every state change** that something off-chain needs to observe. Off-chain
72
+ reconstruction is the only history there is.
73
+ <!-- nina:slot money.1 -->
74
+ <!-- nina:slot project.3 contracts-you-own -->
75
+
76
+ ## You MUST NOT
77
+
78
+ - **Commit a private key, mnemonic, or funded account** — in source, in a test fixture, in a script,
79
+ or in a comment. A key in git history is a key that is gone.
80
+ - Touch files outside the spec's "Files to touch" list. Escalate instead; the rule is the same here
81
+ as everywhere, and the blast radius is larger.
82
+ - Change the storage layout of a deployed upgradeable contract by reordering, removing, or retyping
83
+ an existing variable. Append only.
84
+ - Add an `unchecked` block, an assembly block, or a low-level call without stating in your report
85
+ what it buys and why the safe form does not work.
86
+ - Deploy anything, to any network. That is the devops stage, and it needs a green auditor first.
87
+ <!-- nina:slot blockchain.5 -->
88
+
89
+ ## Verdict line — the first line of your report
90
+
91
+ Your report's **first line** is exactly:
92
+
93
+ ```
94
+ VERDICT: <TOKEN>
95
+ ```
96
+
97
+ where `<TOKEN>` is one of `DIFF-READY` or `BLOCKED`. Nothing before it — no preamble, no heading, no
98
+ markdown emphasis. Your report proper starts on the second line — or on the third when the verdict is `BLOCKED`, because the
99
+ second line then names each issue by an id:
100
+
101
+ ```
102
+ VERDICT: BLOCKED
103
+ ISSUES: storage-layout-conflict
104
+ ```
105
+
106
+ An id is lowercase words joined by hyphens, at most 40 characters, and it names the defect rather than
107
+ where it was found or which round this is: `storage-layout-conflict`, not `issue-1`. When your dispatch carries the
108
+ `ISSUES` line of an earlier round, an issue that is still open keeps its id exactly as written there, and
109
+ a new issue gets a new id. Where a loop-back is capped, it is capped per issue, and these ids are what tell
110
+ a fix that is not converging from a check that keeps finding new problems.
111
+
112
+ `BLOCKED` means the change cannot be made safely as specified — an unverifiable premise about the
113
+ library, a storage layout that cannot be preserved, a requirement that needs an upgrade path the
114
+ spec did not authorize. Say which.
115
+
116
+ The verdict line is machine-read: it measures how often each stage sends work back, and where the project
117
+ wires the loop gate it is what rounds are counted by. A report without it counts as no verdict at all,
118
+ which makes the stage invisible to both.
119
+
120
+ ## Handoff
121
+ Your diff goes to the **solidity-auditor**, which is a mandatory gate: the reviewer refuses final
122
+ approval without its sign-off.
123
+ <!-- nina:slot project.4 handoff -->
@@ -0,0 +1,65 @@
1
+ # Agent Pipeline — Overview
2
+
3
+ <!-- nina:slot project.1 opening-paragraph -->
4
+
5
+ The pipeline separates thinking from execution, execution from verification, and gates the highest-blast-radius surfaces (the database, and the runtime behavior of the dependencies this project does not control) behind mandatory specialists.
6
+
7
+ ---
8
+
9
+ ## Why a pipeline?
10
+
11
+ - **Narrow tool surface per stage** → fewer accidents, less token waste.
12
+ - **Explicit handoffs** → drift between "what we intended" and "what we built" gets caught at the next stage instead of in production.
13
+ <!-- nina:slot db.1 -->
14
+ <!-- nina:slot integrations.1 -->
15
+ <!-- nina:slot blockchain.1 -->
16
+
17
+ ---
18
+
19
+ <!-- nina:slot project.2 roles-heading -->
20
+
21
+ | Role | Purpose | Spec |
22
+ |---|---|---|
23
+ | **planner** | Decompose ambiguous work into concrete, ordered subtasks | `.claude/agents/planner.md` |
24
+ | **architect** | Design the technical approach before code is written; cite `node_modules:<line>` premises for every external-library behavior the spec depends on | `.claude/agents/architect.md` |
25
+ | **design-reviewer** | Read the spec before any code when the design is the question; try its rules against its rows | `.claude/agents/design-reviewer.md` |
26
+ | **implementer** | Write code following the architect's spec, honoring every cited premise | `.claude/agents/implementer.md` |
27
+ <!-- nina:slot db.2 -->
28
+ <!-- nina:slot integrations.2 -->
29
+ <!-- nina:slot blockchain.2 -->
30
+ | **reviewer** | Verify the diff: patterns, bugs, security; name the gates the diff triggers; gate before qa | `.claude/agents/reviewer.md` |
31
+ | **qa** | Run vitest once at the END of the pipeline (after the reviewer and every gate approve) for the affected packages; loop back on failures | `.claude/agents/qa.md` |
32
+ | **devops** | Owns qa PASS → running where someone can use it: clean build, both targets, migrations, secret parity, smoke against preview, rollback. Prod needs an explicit go | `.claude/agents/devops.md` |
33
+ | **secops** | **Milestone gate.** Audit the whole assembled surface of a completed spec-SET (`6.*`, or one package's build-out) for cross-cutting security/privacy gaps; CRITICAL/HIGH blocks the milestone | `.claude/agents/secops.md` |
34
+
35
+ ---
36
+
37
+ ## Flow at a glance
38
+
39
+ <!-- nina:slot project.3 pipeline-diagram -->
40
+
41
+ Everything between the implementer and qa is **read-only**, so it goes out in one dispatch rather
42
+ than several: `reviewer`, plus every gate the diff triggered — `.claude/graph.md` names the ones this
43
+ project has. On a large diff the reviewer itself fans out by dimension — one per axis of risk,
44
+ such as tenant isolation, patterns and spec-scope — which is both faster and more thorough than one
45
+ agent carrying fifteen checklists. **qa** goes out once the reviewer and every gate approved, and runs
46
+ the suite once, alone.
47
+
48
+ Concurrent **implementers** are the one write-side exception: only on work that shares no file and
49
+ builds on nothing the other writes, side by side in different packages, each in `isolation: "worktree"`
50
+ within one. See `.claude/router.md` § *Parallelization*.
51
+
52
+ **devops** runs after every qa PASS that changes a deployed surface: it builds clean, deploys both targets, applies migrations, smokes against **preview** — never prod first — and names the rollback. Production waits for an explicit go from {{OWNER}}.
53
+
54
+ **secops** runs once at the END of a numbered spec-SET / phase (not per sub-step): after the last sub-step's qa, it audits the whole assembled surface as an attacker and a privacy auditor. A `BLOCKED` verdict (CRITICAL/HIGH) loops back to architect/implementer; the milestone is not done until secops returns `SECURE`.
55
+
56
+ ---
57
+
58
+ ## Related docs
59
+
60
+ - **`.claude/pipeline.md`** — full flow, stage contracts, examples
61
+ - **`.claude/router.md`** — which pipeline to use for which task type
62
+ - **`.claude/retrieval.md`** — which docs each stage should load
63
+ - **`.claude/patterns.md`** — conventions every stage enforces
64
+ <!-- nina:slot integrations.3 -->
65
+ - **`CLAUDE.md`** — top-level rules (mandatory pipeline, hard rules)
@@ -0,0 +1,10 @@
1
+ <!-- nina:requires frontend -->
2
+ # Frontend conventions
3
+
4
+ How this project builds its screens: its framework and router, where server state lives, how it styles,
5
+ and what is shared between apps. Every stage that writes or reviews code under `{{APP_DIR}}` reads it.
6
+ These are the project's choices, not the harness's: the harness gates the screen — a Visual acceptance
7
+ in the spec, a reviewer who looks at the render — and not the stack that draws it. Where a choice is not
8
+ made yet, say so here, so that no stage makes it by default.
9
+
10
+ <!-- nina:slot project.1 conventions -->
@@ -0,0 +1,79 @@
1
+ # Pipeline graph
2
+
3
+ The one place this project's stages, and the edges between them, are stated. Every other document that
4
+ routes work — `CLAUDE.md`, `router.md`, `pipeline.md`, each role's loop-back rules — describes this
5
+ graph; where one of them disagrees with it, this file is right and the other is a defect to report
6
+ (Hard Rule #17). It is composed for this project, so a stage this project does not have is not in it,
7
+ and no edge points at one.
8
+
9
+ `nina check` validates it: every stage has a spec, every spec is a stage, every edge leaves on a verdict
10
+ its stage can actually emit, every verdict a stage can emit goes somewhere, and every loop-back edge has
11
+ a cap.
12
+
13
+ ## Stages
14
+
15
+ - `planner` — decomposes ambiguous or multi-step work into ordered steps
16
+ - `architect` — designs the approach and writes the spec, with cited premises
17
+ - `design-reviewer` — reads the spec before any code, when the design is the question
18
+ - `implementer` — writes code and tests to the spec; never runs the tests
19
+ <!-- nina:slot db.1 -->
20
+ <!-- nina:slot integrations.1 -->
21
+ <!-- nina:slot blockchain.1 -->
22
+ - `reviewer` — audits the diff against the spec, and names every gate the diff triggers
23
+ - `qa` — runs the tests, once, at the end
24
+ - `devops` — deploys to preview and smokes it; production only on the owner's explicit go
25
+ - `secops` — the security gate, once per milestone
26
+
27
+ The two terminals are `done` and `human`. `human` is the owner: a decision nobody in the pipeline can
28
+ make, or a loop that has run out of rounds.
29
+
30
+ ## Edges
31
+
32
+ One per line: the stage, where its work goes, on which verdict, and when. A loop-back edge ends with
33
+ its **cap** — how many times the SAME issue may travel it, the issue being what the stage names on the
34
+ `ISSUES` line under its verdict. When the next round would exceed the cap,
35
+ the orchestrator stops and hands the owner the reports from every round, instead of dispatching again:
36
+ a third attempt at a fix that failed twice is rarely different from the second, and each round costs
37
+ minutes to hours. A different issue on the same edge starts its own count. Where the project wires the loop
38
+ gate, the dispatch past a cap waits for the owner to confirm it; `router.md` says how rounds are counted.
39
+
40
+ - `planner` → `architect` on `PLAN-READY`
41
+ - `planner` → `human` on `BLOCKED` — the work cannot be decomposed without an answer
42
+ - `architect` → `implementer` on `SPEC-READY`
43
+ - `architect` → `design-reviewer` on `SPEC-READY` — the design is the question: it builds a check, scanner, parser or filter, or picks a mechanism nothing here has run
44
+ - `architect` → `human` on `BLOCKED` — an unverifiable premise or a missing decision
45
+ - `architect` → `planner` on `BLOCKED` — the plan itself is wrong, not the design · max 1
46
+ - `design-reviewer` → `implementer` on `APPROVED`
47
+ - `design-reviewer` → `architect` on `REJECTED` — a design flaw, found before any code · max 2
48
+ - `implementer` → `reviewer` on `DIFF-READY`
49
+ - `implementer` → `architect` on `BLOCKED` — the spec is wrong, needs a file it does not list, or asks one run for more files or lines than a step may write · max 2
50
+ - `implementer` → `planner` on `BLOCKED` — the spec is too large for one step · max 1
51
+ <!-- nina:slot db.2 -->
52
+ <!-- nina:slot integrations.2 -->
53
+ <!-- nina:slot blockchain.2 -->
54
+ <!-- nina:slot money.1 -->
55
+ - `reviewer` → `qa` on `APPROVED`
56
+ - `reviewer` → `done` on `APPROVED` — a spike, or a chain with no architect whose change no test covers
57
+ - `reviewer` → `implementer` on `REJECTED` — an implementation bug · max 2
58
+ - `reviewer` → `architect` on `REJECTED` — a design flaw, or no preview-deploy plan · max 2
59
+ - `qa` → `devops` on `PASS` — the change touches a deployed surface
60
+ - `qa` → `secops` on `PASS` — the last step of a milestone
61
+ - `qa` → `done` on `PASS` — nothing to deploy, or nowhere yet
62
+ - `qa` → `implementer` on `FAIL` — a test fails, the run exits non-zero, or a "pre-existing" failure does not reproduce · max 2
63
+ - `qa` → `architect` on `FAIL` — the test is right and the spec was wrong · max 2
64
+ - `devops` → `done` on `DEPLOYED` — preview is green; production waits for the owner
65
+ - `devops` → `implementer` on `BLOCKED` — the deploy failed because the code is wrong · max 2
66
+ - `devops` → `architect` on `BLOCKED` — the spec has no workable deploy plan · max 2
67
+ - `secops` → `done` on `SECURE`
68
+ - `secops` → `implementer` on `BLOCKED` — a CRITICAL or HIGH that is a bug · max 2
69
+ - `secops` → `architect` on `BLOCKED` — a CRITICAL or HIGH that is a design flaw · max 2
70
+
71
+ ## Concurrency
72
+
73
+ Stages that only read may run together: after the implementer, the `reviewer` and every gate the diff
74
+ triggers go out in one message, and `qa` goes out once each of them has approved; at a milestone's end,
75
+ `secops` runs beside `devops`, after the last `qa` passed.
76
+ `qa` always runs alone. These may run as several agents at once, each on its own share of the work:
77
+ - `architect` × many — the sibling specs of one milestone, each its own spec
78
+ - `implementer` × many — work that shares no file and builds on nothing the other writes: side by side in different packages, each in its own worktree within one
79
+ - `reviewer` × many — one per axis of risk the diff carries, for a diff over ~200 lines
@@ -0,0 +1,251 @@
1
+ # Patterns & Conventions
2
+
3
+ Read this before writing code. Architects cite it in specs; implementers follow it; reviewers enforce it.
4
+
5
+ ---
6
+
7
+ ## Language & tooling
8
+
9
+ - **TypeScript strict mode** everywhere. No `any` without a justifying comment.
10
+ - **pnpm workspaces + Turborepo**. Never `npm` or `yarn`. Use `turbo run <task>` for orchestrated work.
11
+ - **Biome** for format + lint. No ESLint / Prettier.
12
+ - **Vitest** for unit tests.
13
+ <!-- nina:slot edge-cf.3 -->
14
+ - **Zod** for runtime validation at all trust boundaries (API ingress, env loading, queue payload, an RPC between services, webhook body, integration responses).
15
+
16
+ ### Relative imports carry a `.js` extension — this is intentional, do NOT "fix" it
17
+
18
+ Relative imports in `.ts`/`.tsx` source MUST use the `.js` extension (e.g. `import { x } from './client.js'`, never `'./client'` or `'./client.ts'`). This looks wrong but is correct ESM-TypeScript and is load-bearing:
19
+
20
+ - The repo is ESM (`"type": "module"`, `module: ESNext`, `moduleResolution: Bundler`, `verbatimModuleSyntax: true` in `packages/tsconfig/base.json`). **TypeScript never rewrites import specifiers** — what you write is what lands in the emitted `.js`.
21
+ - Emitting packages ({{EMITTING_PKGS}}) compile with `tsc` to real `.js` in `dist/` and are consumed via their `exports` map (`./dist/*.js`). At runtime the file IS `client.js`; a source `'./client.ts'` would emit a dead `'./client.ts'` reference → broken import. The `.js` form is the only one that works for these.
22
+ - Bundled apps (`{{API_DIR}}` and `{{APP_DIR}}`, each via its bundler) resolve `'./x.js'` back to `./x.ts` source transparently, so the same convention works everywhere.
23
+ - Switching to `.ts` extensions would require `allowImportingTsExtensions`, which only works with `noEmit` — it would break every emitting package. Do not propose it.
24
+
25
+ This is the official TypeScript guidance for ESM. A reviewer/AI that "corrects" `.js` → `.ts` (or strips the extension) is introducing a bug, not a cleanup.
26
+
27
+ ---
28
+
29
+ ## Folder structure within a TS package
30
+
31
+ ```
32
+ package/
33
+ ├── src/
34
+ │ ├── index.ts # public exports only — this is the package API
35
+ │ ├── internal/ # not re-exported; no deep imports allowed from outside
36
+ │ └── types.ts # shared types
37
+ ├── test/ # *.test.ts mirroring src/ structure
38
+ └── package.json
39
+ ```
40
+
41
+ - External code imports from `{{PKG_SCOPE}}/<name>` (barrel `index.ts`), never `{{PKG_SCOPE}}/<name>/src/internal/...`.
42
+
43
+ ---
44
+
45
+ ## `export` only what crosses a module boundary
46
+
47
+ **`export` is a claim that something outside this file needs the symbol.** If nothing does, drop the
48
+ keyword — the declaration stays, it just stops pretending to be API.
49
+
50
+ This is not cosmetic. An unused export is invisible to every tool we have: TypeScript's
51
+ `noUnusedLocals` and Biome's `noUnusedVariables` both stop at the file boundary, so an exported dead
52
+ symbol is the one kind of dead code nothing flags. It also makes the symbol look load-bearing to the
53
+ next reader, which is how a second implementation gets written next to the first.
54
+
55
+ - A React component's `Props` type used only by that component is **not** exported. Export it only
56
+ when another module actually imports it.
57
+ - The same goes for a service's internal result/input shapes, an error code union that never leaves
58
+ its module, and a constant only its own file reads.
59
+ <!-- nina:slot project.1 library-packages -->
60
+ - The standing report is `.claude/code-map.generated.md` § *Rot signals*. The
61
+ reviewer checks it for symbols the current diff introduced: **a new export nothing consumes is
62
+ dead on arrival.**
63
+
64
+ ---
65
+
66
+ ## Naming
67
+
68
+ - **Files:** `kebab-case.ts` for modules, `PascalCase.tsx` for React components.
69
+ - **Types / interfaces:** `PascalCase`. No `I` prefix.
70
+ - **Functions / vars:** `camelCase`.
71
+ - **Constants:** `SCREAMING_SNAKE_CASE` only for true compile-time constants.
72
+ - **Env vars:** `SCREAMING_SNAKE_CASE`, loaded through a typed `env.ts` with Zod validation.
73
+ <!-- nina:slot prisma.1 -->
74
+ <!-- nina:slot money.1 -->
75
+ <!-- nina:slot money.2 -->
76
+ <!-- nina:slot money.3 -->
77
+
78
+ ---
79
+
80
+ ## Readable code — *Clean Code* as a reference
81
+
82
+ Robert C. Martin's *Clean Code* is the reference for writing code the next reader understands without
83
+ running it. It is a reference, not a rulebook: when two ways of writing the same thing both meet the
84
+ spec, choose the one the book would choose. Where the book and this document disagree, this document
85
+ wins: the book treats comments as a failure, and here every declaration still carries TSDoc
86
+ (§ *TSDoc*). The reviewer does not reject a diff on this section alone.
87
+
88
+ - **A name says what the thing is or does.** A function is a verb (`loadProfile`), a boolean reads as a
89
+ question (`isExpired`, `canRetry`), a collection is plural. No abbreviation a newcomer has to decode,
90
+ no bare `data`, `info`, `tmp` or `manager`, and one word per concept: not `fetch` in one module and
91
+ `get` in the next for the same operation.
92
+ - **A function does one thing, at one level of abstraction.** A function that calls three steps does
93
+ not also parse a string inline. When a block needs a comment to say what it does, it is a function
94
+ with that comment as its name.
95
+ - **Guard clauses over nesting.** Leave early on the case you cannot handle — with a named failure, not
96
+ a silent default — so the main path reads at one indentation level.
97
+ - **Few parameters, no flag parameters.** Past three, pass one object with named fields. A boolean that
98
+ switches what a function does (`render(true)`) is two functions.
99
+ - **No magic values.** A number or string whose meaning is not obvious where it is used gets a named
100
+ constant.
101
+ - **A side effect shows in the name.** `getX` does not write. A function either answers a question or
102
+ changes something, not both, where splitting costs nothing.
103
+ - **Extract what is the same rule, not what has the same shape.** Two blocks that look alike but would
104
+ change for different reasons stay apart.
105
+
106
+ **Where it stops.** Readability works inside the scope you were given. Extracting a private function or
107
+ naming a constant in a file you are already writing is in scope; a new shared helper, module, class
108
+ hierarchy or interface the spec did not name is a new abstraction, and goes back to the architect. Code
109
+ you read but are not changing is not rewritten to read better. And indirection is not the goal: a
110
+ function, an interface with one implementation or a pattern earns its place by making the caller
111
+ clearer, not by making the function smaller.
112
+
113
+ ---
114
+
115
+ ## API conventions
116
+
117
+ ### Layering: Route → Service → Data Objects
118
+
119
+ Every request (and queue/webhook invocation) traverses three layers in order. **No layer may skip the next.** Full diagram in `.claude/architecture.md`.
120
+
121
+ - **Route** (`{{API_DIR}}/src/routes/<resource>.ts`): Zod validation, auth + role extraction, envelope shaping, privacy-safe log, deps construction. Nothing else.
122
+ <!-- nina:slot integrations.1 -->
123
+ - **Service** (`{{API_DIR}}/src/services/<resource>.ts`): business orchestration, owner scoping (every read and write filtered by who owns the data), Date→ISO mapping, named-error taxonomy. HTTP-agnostic.
124
+ - **Data Objects:** the database client, the platform bindings, and each integration's boundary module.
125
+
126
+ **Hard rules (reviewer enforces):**
127
+
128
+ <!-- nina:slot db.2 -->
129
+ - Routes must NOT call `.toISOString()` on service results — services do that.
130
+ - Services must NOT import the HTTP framework's request context, shape a response, or reference status codes.
131
+ <!-- nina:slot prisma.2 -->
132
+ <!-- nina:slot db.4 -->
133
+ <!-- nina:slot money.4 -->
134
+ <!-- nina:slot money.5 -->
135
+ <!-- nina:slot integrations.2 -->
136
+
137
+ ### Other API rules
138
+
139
+ - **Zod validation at the request boundary.** No ad-hoc `if (!body.foo) return 400`.
140
+ - Response shape is always `{ok: true, data: T} | {ok: false, error: {code, message}}`. No bare throws leaking to clients.
141
+ - Custom errors: `class AppError extends Error { code: string; status: number }`. Each route maps known classes to HTTP codes.
142
+ <!-- nina:slot money.6 -->
143
+ <!-- nina:slot db.5 -->
144
+ <!-- nina:slot db.7 -->
145
+ <!-- nina:slot prisma.3 -->
146
+ <!-- nina:slot drizzle.1 -->
147
+ <!-- nina:slot d1.1 -->
148
+ <!-- nina:slot integrations.3 -->
149
+ <!-- nina:slot project.2 integration-error-types -->
150
+
151
+ ---
152
+
153
+ ## SDK / shared package conventions
154
+
155
+ - **Tree-shakeable:** barrel `index.ts` only re-exports. No side effects at module top level.
156
+ - Works in: modern browsers, Node 20+, and every runtime the project deploys to.
157
+ - No `console.log` in production paths. Use a `debug(msg)` helper that's a no-op in prod, and never log PII.
158
+ <!-- nina:slot frontend.1 -->
159
+
160
+ ---
161
+
162
+ ## Tests
163
+
164
+ ### Unit tests
165
+ - Test **pure functions** directly. No mocks of our own code.
166
+ <!-- nina:slot money.7 -->
167
+ - Don't test implementation details. Test behavior at the module boundary.
168
+
169
+ ### Integration tests
170
+ <!-- nina:slot edge-cf.4 -->
171
+ <!-- nina:slot db.6 -->
172
+ <!-- nina:slot integrations.4 -->
173
+
174
+ ### Fixtures
175
+ <!-- nina:slot project.3 test-fixtures -->
176
+
177
+ ### Test files MUST be inside the typecheck program
178
+
179
+ A package whose `tsconfig.json` has `include: ["src"]` **does not typecheck its own tests.** That is
180
+ a false green, and an expensive one: the test still imports the symbol you deleted and still passes
181
+ a fixture whose shape drifted, and you find out at vitest time — or never, if nobody runs that
182
+ suite. It is the mechanism behind the pill *test-files-not-typechecked-on-symbol-removal*.
183
+ <!-- nina:slot project.4 typecheck-current-state -->
184
+
185
+ A package that emits (`build: tsc`, with `rootDir: "src"`) cannot simply add `test` to its build
186
+ config. Give it a second config instead and point the script at it:
187
+
188
+ ```jsonc
189
+ // tsconfig.typecheck.json
190
+ {
191
+ "extends": "./tsconfig.json",
192
+ "compilerOptions": { "rootDir": ".", "noEmit": true },
193
+ "include": ["src", "test"]
194
+ }
195
+ ```
196
+ ```jsonc
197
+ // package.json — build keeps using tsconfig.json, typecheck does not
198
+ "typecheck": "tsc --noEmit -p tsconfig.typecheck.json"
199
+ ```
200
+ <!-- nina:slot project.5 typecheck-coverage -->
201
+
202
+ ---
203
+
204
+ ## Correcting a document
205
+
206
+ When you correct a document, **delete what you are correcting.** A document that contradicts itself
207
+ is worse than one that is merely wrong: every reader picks the half that suits what they are already
208
+ writing, so two readers reach opposite conclusions from the same file and both believe they followed
209
+ it. The correction and the text it replaces cannot coexist "for history" — that is what the commit
210
+ log is for.
211
+
212
+ ---
213
+
214
+ ## TSDoc — required on all TS declarations
215
+
216
+ Every named declaration gets a TSDoc block (`/** ... */`) — exported or not: functions, classes + members, interfaces + members, type aliases, enums + members, and top-level constants whose name doesn't convey intent.
217
+
218
+ ### Structure
219
+ - **First line:** a concise one-sentence summary.
220
+ - **`@param`** when the purpose isn't fully encoded in name and type.
221
+ - **`@returns`** when the return carries information the type alone doesn't convey.
222
+ - **`@throws`** whenever the function can throw — name the error type and condition.
223
+ - **`@example`** for non-trivially composed APIs.
224
+ - **`@remarks`** for invariants, perf trade-offs, caveats.
225
+
226
+ ### What TSDoc is NOT
227
+ - Not a restatement of the signature. Not a changelog. Not a crutch for bad naming.
228
+
229
+ ### Enforcement
230
+ Reviewer verifies coverage. **Missing TSDoc on any new declaration = `REJECTED`.**
231
+
232
+ ---
233
+
234
+ ## Inline comments — default: none
235
+
236
+ Separate from TSDoc. Regular `//` comments stay rare:
237
+ - **Only** for non-obvious **WHY**: an invariant, a subtle perf trade-off, a workaround.
238
+ - **Never** for WHAT — if code doesn't read clearly, fix the code.
239
+ - **Never** reference callers, tickets, or PR history.
240
+ <!-- nina:slot edge-cf.1 -->
241
+ <!-- nina:slot project.7 required-secrets -->
242
+ <!-- nina:slot edge-cf.2 -->
243
+
244
+ ---
245
+
246
+ ## Commit / PR conventions
247
+
248
+ - One logical change per PR. Multi-concern PRs get split by reviewer.
249
+ - Conventional Commits (`feat:`, `fix:`, `chore:`, `refactor:`, `docs:`).
250
+ - PR description answers **why**, not **what**.
251
+ - Reviewer verifies: typecheck clean, Biome clean, every gate the diff triggered approved (`.claude/graph.md`), no secret leaked, no PII in logs or tests.