@really-knows-ai/foundry 2.3.2 → 3.0.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 (170) hide show
  1. package/README.md +180 -369
  2. package/dist/.opencode/plugins/foundry-tools/appraiser-tools.js +28 -0
  3. package/dist/.opencode/plugins/foundry-tools/artefact-tools.js +58 -0
  4. package/dist/.opencode/plugins/foundry-tools/assay-tools.js +92 -0
  5. package/dist/.opencode/plugins/foundry-tools/attestation-tools.js +191 -0
  6. package/dist/.opencode/plugins/foundry-tools/config-create-tools.js +128 -0
  7. package/dist/.opencode/plugins/foundry-tools/config-law-tools.js +380 -0
  8. package/dist/.opencode/plugins/foundry-tools/config-tools.js +43 -0
  9. package/dist/.opencode/plugins/foundry-tools/feedback-tools.js +234 -0
  10. package/dist/.opencode/plugins/foundry-tools/git-helpers.js +354 -0
  11. package/dist/.opencode/plugins/foundry-tools/git-tools.js +181 -0
  12. package/dist/.opencode/plugins/foundry-tools/helpers.js +340 -0
  13. package/dist/.opencode/plugins/foundry-tools/history-tools.js +20 -0
  14. package/dist/.opencode/plugins/foundry-tools/memory-admin-tools.js +296 -0
  15. package/dist/.opencode/plugins/foundry-tools/memory-helpers.js +104 -0
  16. package/dist/.opencode/plugins/foundry-tools/memory-tools.js +286 -0
  17. package/dist/.opencode/plugins/foundry-tools/orchestrate-tool.js +159 -0
  18. package/dist/.opencode/plugins/foundry-tools/snapshot-tools.js +104 -0
  19. package/dist/.opencode/plugins/foundry-tools/stage-tools.js +186 -0
  20. package/dist/.opencode/plugins/foundry-tools/validate-tools.js +263 -0
  21. package/dist/.opencode/plugins/foundry-tools/workfile-tools.js +102 -0
  22. package/dist/.opencode/plugins/foundry.js +105 -0
  23. package/dist/CHANGELOG.md +490 -0
  24. package/dist/LICENSE +21 -0
  25. package/dist/README.md +278 -0
  26. package/dist/docs/README.md +59 -0
  27. package/dist/docs/architecture.md +434 -0
  28. package/dist/docs/concepts.md +396 -0
  29. package/dist/docs/getting-started.md +345 -0
  30. package/dist/docs/memory-maintenance.md +176 -0
  31. package/dist/docs/tools.md +1411 -0
  32. package/dist/docs/work-spec.md +283 -0
  33. package/dist/scripts/lib/artefacts.js +151 -0
  34. package/dist/scripts/lib/assay/loader.js +151 -0
  35. package/dist/scripts/lib/assay/parse-jsonl.js +102 -0
  36. package/dist/scripts/lib/assay/permissions.js +52 -0
  37. package/dist/scripts/lib/assay/run.js +219 -0
  38. package/dist/scripts/lib/assay/spawn-with-timeout.js +138 -0
  39. package/dist/scripts/lib/attestation/attest.js +111 -0
  40. package/dist/scripts/lib/attestation/canonical-json.js +109 -0
  41. package/dist/scripts/lib/attestation/hash.js +17 -0
  42. package/dist/scripts/lib/attestation/parse.js +14 -0
  43. package/dist/scripts/lib/attestation/payload.js +106 -0
  44. package/dist/scripts/lib/attestation/render.js +16 -0
  45. package/dist/scripts/lib/attestation/verify.js +15 -0
  46. package/dist/scripts/lib/branch-guard.js +72 -0
  47. package/dist/scripts/lib/config-creators/appraiser.js +9 -0
  48. package/dist/scripts/lib/config-creators/artefact-type.js +9 -0
  49. package/dist/scripts/lib/config-creators/cycle.js +11 -0
  50. package/dist/scripts/lib/config-creators/factory.js +49 -0
  51. package/dist/scripts/lib/config-creators/flow.js +11 -0
  52. package/dist/scripts/lib/config-validators/appraiser.js +49 -0
  53. package/dist/scripts/lib/config-validators/artefact-type.js +38 -0
  54. package/dist/scripts/lib/config-validators/cycle.js +131 -0
  55. package/dist/scripts/lib/config-validators/flow.js +57 -0
  56. package/dist/scripts/lib/config-validators/helpers.js +96 -0
  57. package/dist/scripts/lib/config-validators/law.js +96 -0
  58. package/dist/scripts/lib/config.js +393 -0
  59. package/dist/scripts/lib/failed-flow.js +131 -0
  60. package/dist/scripts/lib/feedback-store.js +249 -0
  61. package/dist/scripts/lib/feedback-transitions.js +105 -0
  62. package/dist/scripts/lib/finalize.js +70 -0
  63. package/dist/scripts/lib/foundational-guards.js +13 -0
  64. package/dist/scripts/lib/git-bridge.js +77 -0
  65. package/dist/scripts/lib/git-finish/work-finish.js +233 -0
  66. package/dist/scripts/lib/git-policy.js +101 -0
  67. package/dist/scripts/lib/guards.js +125 -0
  68. package/dist/scripts/lib/history.js +132 -0
  69. package/dist/scripts/lib/memory/admin/create-edge-type.js +91 -0
  70. package/dist/scripts/lib/memory/admin/create-entity-type.js +43 -0
  71. package/dist/scripts/lib/memory/admin/create-extractor.js +67 -0
  72. package/dist/scripts/lib/memory/admin/drop-edge-type.js +40 -0
  73. package/dist/scripts/lib/memory/admin/drop-entity-type.js +172 -0
  74. package/dist/scripts/lib/memory/admin/dump.js +47 -0
  75. package/dist/scripts/lib/memory/admin/helpers.js +31 -0
  76. package/dist/scripts/lib/memory/admin/init.js +170 -0
  77. package/dist/scripts/lib/memory/admin/live-store.js +76 -0
  78. package/dist/scripts/lib/memory/admin/reembed.js +285 -0
  79. package/dist/scripts/lib/memory/admin/rename-edge-type.js +54 -0
  80. package/dist/scripts/lib/memory/admin/rename-entity-type.js +151 -0
  81. package/dist/scripts/lib/memory/admin/reset.js +24 -0
  82. package/dist/scripts/lib/memory/admin/vacuum.js +9 -0
  83. package/dist/scripts/lib/memory/admin/validate.js +19 -0
  84. package/dist/scripts/lib/memory/config.js +149 -0
  85. package/dist/scripts/lib/memory/cozo.js +136 -0
  86. package/dist/scripts/lib/memory/drift.js +71 -0
  87. package/dist/scripts/lib/memory/embeddings.js +128 -0
  88. package/dist/scripts/lib/memory/frontmatter.js +75 -0
  89. package/dist/scripts/lib/memory/ndjson.js +84 -0
  90. package/dist/scripts/lib/memory/paths.js +25 -0
  91. package/dist/scripts/lib/memory/permissions.js +41 -0
  92. package/dist/scripts/lib/memory/prompt.js +109 -0
  93. package/dist/scripts/lib/memory/query.js +56 -0
  94. package/dist/scripts/lib/memory/reads.js +109 -0
  95. package/dist/scripts/lib/memory/schema.js +64 -0
  96. package/dist/scripts/lib/memory/search.js +73 -0
  97. package/dist/scripts/lib/memory/singleton.js +49 -0
  98. package/dist/scripts/lib/memory/store.js +162 -0
  99. package/dist/scripts/lib/memory/types.js +93 -0
  100. package/dist/scripts/lib/memory/validate.js +58 -0
  101. package/dist/scripts/lib/memory/writes.js +40 -0
  102. package/{scripts → dist/scripts}/lib/pending.js +7 -2
  103. package/dist/scripts/lib/secret.js +59 -0
  104. package/{scripts → dist/scripts}/lib/slug.js +3 -2
  105. package/dist/scripts/lib/snapshot/finish.js +103 -0
  106. package/dist/scripts/lib/snapshot/inspect.js +253 -0
  107. package/dist/scripts/lib/snapshot/render.js +55 -0
  108. package/dist/scripts/lib/sort-fs-check.js +121 -0
  109. package/dist/scripts/lib/sort-routing.js +101 -0
  110. package/{scripts → dist/scripts}/lib/stage-guard.js +12 -6
  111. package/{scripts → dist/scripts}/lib/state.js +4 -0
  112. package/dist/scripts/lib/token.js +57 -0
  113. package/dist/scripts/lib/tracing.js +59 -0
  114. package/dist/scripts/lib/ulid.js +100 -0
  115. package/dist/scripts/lib/validator-jsonl.js +162 -0
  116. package/{scripts → dist/scripts}/lib/workfile.js +38 -20
  117. package/dist/scripts/orchestrate-cycle.js +215 -0
  118. package/dist/scripts/orchestrate-phases.js +314 -0
  119. package/dist/scripts/orchestrate.js +163 -0
  120. package/dist/scripts/sort.js +278 -0
  121. package/{skills → dist/skills}/add-appraiser/SKILL.md +39 -9
  122. package/{skills → dist/skills}/add-artefact-type/SKILL.md +46 -24
  123. package/{skills → dist/skills}/add-cycle/SKILL.md +57 -17
  124. package/dist/skills/add-extractor/SKILL.md +133 -0
  125. package/{skills → dist/skills}/add-flow/SKILL.md +36 -10
  126. package/dist/skills/add-law/SKILL.md +191 -0
  127. package/dist/skills/add-memory-edge-type/SKILL.md +52 -0
  128. package/dist/skills/add-memory-entity-type/SKILL.md +74 -0
  129. package/{skills → dist/skills}/appraise/SKILL.md +62 -13
  130. package/dist/skills/assay/SKILL.md +72 -0
  131. package/dist/skills/change-embedding-model/SKILL.md +58 -0
  132. package/dist/skills/drop-memory-edge-type/SKILL.md +54 -0
  133. package/dist/skills/drop-memory-entity-type/SKILL.md +57 -0
  134. package/dist/skills/dry-run/SKILL.md +116 -0
  135. package/{skills → dist/skills}/flow/SKILL.md +15 -2
  136. package/dist/skills/forge/SKILL.md +121 -0
  137. package/dist/skills/human-appraise/SKILL.md +153 -0
  138. package/{skills → dist/skills}/init-foundry/SKILL.md +23 -4
  139. package/dist/skills/init-memory/SKILL.md +92 -0
  140. package/{skills → dist/skills}/orchestrate/SKILL.md +30 -4
  141. package/dist/skills/quench/SKILL.md +99 -0
  142. package/{skills → dist/skills}/refresh-agents/SKILL.md +1 -1
  143. package/dist/skills/rename-memory-edge-type/SKILL.md +50 -0
  144. package/dist/skills/rename-memory-entity-type/SKILL.md +51 -0
  145. package/dist/skills/reset-memory/SKILL.md +54 -0
  146. package/dist/skills/upgrade-foundry/SKILL.md +192 -0
  147. package/package.json +34 -17
  148. package/.opencode/plugins/foundry.js +0 -761
  149. package/CHANGELOG.md +0 -100
  150. package/docs/concepts.md +0 -122
  151. package/docs/getting-started.md +0 -187
  152. package/docs/work-spec.md +0 -207
  153. package/scripts/lib/artefacts.js +0 -124
  154. package/scripts/lib/config.js +0 -175
  155. package/scripts/lib/feedback-transitions.js +0 -25
  156. package/scripts/lib/feedback.js +0 -440
  157. package/scripts/lib/finalize.js +0 -41
  158. package/scripts/lib/history.js +0 -59
  159. package/scripts/lib/secret.js +0 -23
  160. package/scripts/lib/tags.js +0 -108
  161. package/scripts/lib/token.js +0 -26
  162. package/scripts/orchestrate.js +0 -418
  163. package/scripts/sort.js +0 -370
  164. package/scripts/validate-tags.js +0 -54
  165. package/skills/add-law/SKILL.md +0 -111
  166. package/skills/forge/SKILL.md +0 -88
  167. package/skills/human-appraise/SKILL.md +0 -82
  168. package/skills/quench/SKILL.md +0 -62
  169. package/skills/upgrade-foundry/SKILL.md +0 -216
  170. /package/{skills → dist/skills}/list-agents/SKILL.md +0 -0
package/dist/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # Foundry
2
+
3
+ > Engineered confidence for AI-generated work. Define what good looks like.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@really-knows-ai/foundry.svg)](https://www.npmjs.com/package/@really-knows-ai/foundry)
6
+ [![Tests](https://github.com/really-knows-ai/foundry/actions/workflows/test.yml/badge.svg)](https://github.com/really-knows-ai/foundry/actions/workflows/test.yml)
7
+ [![license](https://img.shields.io/npm/l/@really-knows-ai/foundry.svg)](LICENSE)
8
+
9
+ ---
10
+
11
+ ## Engineering confidence
12
+
13
+ ### Confidence is engineered
14
+
15
+ Generation is cheap; trust is expensive. An agent can produce output quickly, skip
16
+ validation, or lose feedback between iterations. The work arrives fast, but the
17
+ evidence is incomplete and trust is fragile. Nobody can see the path from prompt to
18
+ finish. Nobody knows how many times the agent tried, what it fixed, or why it
19
+ stopped.
20
+
21
+ Foundry is the system around the prompt: explicit standards, repeatable checks, and
22
+ recorded sign-off applied to every artefact your AI produces. It transforms "ask an
23
+ agent and hope" into a staged system where the checks are structural and mandatory.
24
+ If an artefact should be validated, it is validated. If feedback must be resolved,
25
+ that state is recorded. If a stage writes outside its lane, the cycle stops. The
26
+ framework is deterministic; the LLM is not. Your laws are.
27
+
28
+ Variability helps where creativity matters; control enforces discipline where
29
+ reliability does. You choose what gates each stage passes through, what laws your
30
+ artefacts must satisfy, and which models you trust for each decision. Foundry runs
31
+ the loop and records every step in git, so the path from draft to approved artefact
32
+ is auditable, repeatable, and defensible to auditors and stakeholders. You can show
33
+ exactly how the output was made. Confidence is engineered; it is not hoped for.
34
+
35
+ ### The operating model: assay, then forge → quench → appraise
36
+
37
+ A codebase-aware cycle can begin with **assay**: a deterministic pre-forge stage
38
+ that runs project-authored extractor scripts, parses the strict JSONL facts they
39
+ emit, and writes typed facts into flow memory. In the foundry metaphor, an assay
40
+ establishes composition before work begins. In Foundry, assay gives forge a
41
+ measured map of the project before it creates an artefact. Cycles without memory
42
+ configuration skip this stage.
43
+
44
+ After assay, one draft enters a short loop and leaves only when it passes quality
45
+ gates. Each loop has four distinct roles that turn a candidate into a verified output:
46
+
47
+ - **Forge** produces or revises the artefact. The stage that creates and reshapes
48
+ work, responding to feedback from appraisers or building on prior drafts.
49
+
50
+ - **Quench** runs deterministic checks that harden or reject the work. Validation is
51
+ fast and non-negotiable, catching errors before they reach appraisers.
52
+
53
+ - **Appraise** judges quality against written laws. Independent evaluators inspect
54
+ whether the work meets the subjective standards you define.
55
+
56
+ - **Human-appraise** provides direct judgement when the stakes require it or the loop
57
+ deadlocks. Offers human oversight at critical decision points.
58
+
59
+ Every stage commits separately, so every step leaves a record. Every decision is
60
+ timestamped. A single loop produces an **output** — a verified draft. A flow
61
+ composes one or more such loops to produce an **outcome** — the final artefact that
62
+ reaches your codebase or customers.
63
+
64
+ ### What you describe, what Foundry enforces
65
+
66
+ You write the laws — the criteria that define acceptable. You describe the artefact
67
+ types you want produced and what files they generate. You choose which stages each
68
+ cycle passes through and what models to use at each step. You control the operating
69
+ model entirely. Your configuration is law.
70
+
71
+ Foundry runs the loop, gates writes per stage so only the right mutation happens at
72
+ the right time, records every decision in git, and stops when there is nothing left
73
+ to fix. Each stage holds a token that authorises its mutations. Stages cannot write
74
+ outside their assigned lane. Feedback state moves through a state machine that
75
+ prevents invalid transitions. The framework owns the process and enforces the rules;
76
+ the LLM performs the creative and evaluative work inside each stage. You define the
77
+ machine; Foundry runs it. Confidence is the difference.
78
+
79
+ ---
80
+
81
+ ## Compatibility
82
+
83
+ Foundry works primarily with OpenCode. The skills and tools are portable to other
84
+ skill-aware AI systems. Multi-model stage routing is OpenCode-specific today.
85
+
86
+ - **OpenCode** — full support. Multi-model routing via file-based `foundry-*` agents.
87
+ This is the primary target platform.
88
+
89
+ - **Other skill-aware AI tools** — the skills and tools are portable to any
90
+ skill-aware AI system. Multi-model stage routing is OpenCode-specific today
91
+ because it relies on `.opencode/agents/` files.
92
+
93
+ ---
94
+
95
+ ## Install
96
+
97
+ Add the plugin to `opencode.json`:
98
+
99
+ ```json
100
+ {
101
+ "$schema": "https://opencode.ai/config.json",
102
+ "plugin": ["@really-knows-ai/foundry"]
103
+ }
104
+ ```
105
+
106
+ Restart OpenCode so the plugin registers its tools and skills. You will see new
107
+ tools and skills become available in OpenCode's command palette once the restart
108
+ completes. The `init-foundry` skill and flow-management tools are now ready to use.
109
+
110
+ ---
111
+
112
+ ## Upgrade
113
+
114
+ Run the `upgrade-foundry` skill from a clean project state when moving an existing project to the installed Foundry version. The skill preserves the existing `foundry/` directory, initialises a fresh current-version configuration, analyses the preserved configuration as source material, and recreates supported concepts through current tools.
115
+
116
+ The upgrade process asks clarifying questions for ambiguous routing, input contracts, validation behaviour, memory settings, and deprecated concepts. It leaves the preserved source directory in place until you explicitly approve cleanup.
117
+
118
+ ---
119
+
120
+ ## Quick start
121
+
122
+ ### Phase 1 — Install
123
+
124
+ Add the plugin to `opencode.json` (see Install section above):
125
+
126
+ ```json
127
+ {
128
+ "$schema": "https://opencode.ai/config.json",
129
+ "plugin": ["@really-knows-ai/foundry"]
130
+ }
131
+ ```
132
+
133
+ Then restart OpenCode so the plugin registers its tools and skills. You will see new
134
+ tools and skills become available in OpenCode's command palette once the restart
135
+ completes. The `init-foundry` skill and flow-management tools are now ready to use.
136
+
137
+ ### Phase 2 — Initialise
138
+
139
+ Open OpenCode in your project repo and say:
140
+
141
+ ```
142
+ > run init-foundry
143
+ ```
144
+
145
+ Foundry scaffolds a `foundry/` directory, generates one `foundry-<model>` agent file
146
+ per model available in your session, commits the structure, and then asks you to
147
+ restart. All the foundational configuration directories are created; you will
148
+ populate them next.
149
+
150
+ Restart OpenCode so the new `foundry-<model>` agents register — multi-model dispatch cannot route to agents it cannot discover.
151
+
152
+ ### Phase 3 — Build a flow without writing one
153
+
154
+ Ask Foundry to set up a flow:
155
+
156
+ ```
157
+ > set up a flow that writes haikus
158
+ ```
159
+
160
+ Foundry will ask clarifying questions about the flow's purpose, constraints, and
161
+ entry points. It will then scaffold a haiku artefact type with a syllable-count
162
+ validator, laws for form / imagery / mood, two appraisers with different
163
+ sensibilities and bias profiles, a cycle that connects them in sequence, and a flow
164
+ that ties it all together. Everything is scaffolded; you do not write any
165
+ configuration by hand. This demonstrates the full system in action.
166
+
167
+ Now run it:
168
+
169
+ ```
170
+ > write me a haiku about autumn
171
+ ```
172
+
173
+ Here is what the loop produces:
174
+
175
+ ```
176
+ forge → drafts a haiku [commit]
177
+ quench → 7/7/5 — fails syllable check [commit]
178
+ forge → revises [commit]
179
+ quench → 5/7/5 — passes [commit]
180
+ appraise → 2 appraisers, one flags weak imagery [commit]
181
+ forge → revises [commit]
182
+ appraise → clean [commit]
183
+ done → squash-merged to main with attestation
184
+ ```
185
+
186
+ Every stage commits. Every decision is recorded. Every piece of feedback and every
187
+ revision leaves a trace in the work branch. The final artefact on `main` carries a
188
+ signed attestation showing exactly how that output was produced, which models
189
+ contributed, and when each appraiser signed off.
190
+
191
+ This trace is the proof. You can play it back, audit it, replay it under a different
192
+ model, or use it to argue that the AI output is trustworthy. Every step is visible.
193
+ Nothing is hidden.
194
+
195
+ For codebase-aware flows, add flow memory after the first run: initialise memory,
196
+ declare the entity and edge vocabulary, add extractors, and opt a cycle into
197
+ `assay.extractors`. See [Optional: flow memory](docs/getting-started.md#optional-flow-memory)
198
+ and [Assay](docs/concepts.md#assay) for the configuration path.
199
+
200
+ > **Note (3.0.0):** flow memory currently persists to `cozo-node`, which is
201
+ > unmaintained upstream. Installation produces six cosmetic deprecation warnings
202
+ > from transitive dependencies (`pnpm audit` is clean). Foundry will migrate to
203
+ > a maintained backend in a future release; the public `foundry_memory_*` tools
204
+ > and on-disk vocabulary/NDJSON format are designed to survive that migration.
205
+ > See `CHANGELOG.md` and [docs/memory-maintenance.md](docs/memory-maintenance.md#backend-status-as-of-300).
206
+
207
+ ---
208
+
209
+ ## What you can show your team
210
+
211
+ After the quick start completes, you have five concrete artefacts to point at to
212
+ demonstrate engineered confidence:
213
+
214
+ - **The artefact itself** — `haikus/autumn.md` on `main`. The final, approved output
215
+ ready for use or deployment.
216
+
217
+ - **The laws it satisfied** — `foundry/artefacts/haiku/laws.md`. The criteria it was
218
+ measured against, written in markdown and version-controlled.
219
+
220
+ - **The feedback ledger** — `WORK.feedback.yaml` on the archived work branch. Every
221
+ issue raised, by whom, and how it was resolved during the loop.
222
+
223
+ - **The per-stage commit history** — the raw commits on `archive/work/<flow>-<...>`.
224
+ A micro-commit per stage showing exactly what changed and why at each step.
225
+
226
+ - **The signed attestation on main** — the squash commit with the Foundry attestation
227
+ block embedded in its message. Proof of approval, signed and timestamped.
228
+
229
+ This is what makes "engineered confidence" concrete. You can show your team exactly
230
+ how that AI output was produced, what it passed through, why you trust it, and who
231
+ signed off. Every step is auditable. Every decision is recorded. The loop is
232
+ reproducible.
233
+
234
+ ---
235
+
236
+ ## What's in the box
237
+
238
+ - **Deterministic governance** — routing, commits, write boundaries, and feedback
239
+ state live in tested plugin code, outside LLM control.
240
+
241
+ - **Written quality criteria** — laws are markdown files; an appraiser panel scores
242
+ each artefact against them, so quality is objective.
243
+
244
+ - **Multi-model diversity** — forge on one model, appraise on another, every
245
+ appraiser on a different model if you want. Different models catch different
246
+ mistakes.
247
+
248
+ - **Full git audit trail** — one commit per stage with `WORK.md`,
249
+ `WORK.feedback.yaml`, and `WORK.history.yaml`. Every iteration is recorded.
250
+
251
+ - **Signed attestation on main** — every flow finishes with a squash commit carrying
252
+ a canonical Foundry attestation block that proves the artefact was processed.
253
+
254
+ - **Archived forensic branch** — the raw work branch is retained for auditors as
255
+ `archive/work/<flow>-<desc>-<hash>`. The full micro-history is never lost.
256
+
257
+ - **Bring your own pipeline** — artefact types, laws, and stages are yours; works
258
+ for code, specs, docs, data, and anything else you can describe as files with
259
+ pass/fail criteria.
260
+
261
+ - **Assay preflight** — deterministic extractor stage that measures the project
262
+ before forge starts, so codebase-aware flows can begin from structured facts.
263
+
264
+ - **Flow memory** — typed graph store with scoped tools, semantic search when
265
+ enabled, and committed NDJSON rows for cross-cycle reuse.
266
+
267
+ ---
268
+
269
+ ## Further reading
270
+
271
+ The full reference set lives in [docs/](docs/) — start at [docs/README.md](docs/README.md)
272
+ for a guided index of every document and when to read it.
273
+
274
+ ---
275
+
276
+ ## License
277
+
278
+ MIT.
@@ -0,0 +1,59 @@
1
+ # Foundry docs
2
+
3
+ This directory contains the reference set behind the project README. Every document here serves a single purpose; use this index to find what you need.
4
+
5
+ **How to navigate:** Work through the sections in order: **Start here** establishes conceptual foundations, **Reference** provides detailed specifications for implementation, and **Contributors** covers subsystem maintenance and extensions.
6
+
7
+ ## Start here
8
+
9
+ Getting oriented with Foundry means understanding both the concepts it uses and how to work within it practically. These documents establish the mental model and hands-on practice you need before authoring configuration or working with flows.
10
+
11
+ **Reading order:** Work through them in order; [getting-started.md](getting-started.md) builds hands-on confidence, and [concepts.md](concepts.md) provides reference depth. Most implementers spend 1–2 hours on getting-started before moving to Reference materials.
12
+
13
+ - **getting-started.md** — Complete end-to-end installation, bootstrap (`init-foundry`), and first flow walkthrough. Read this immediately after installing the plugin and before authoring any of your own configuration.
14
+
15
+ It establishes the operating model, directory structure, and practical confidence in one pass. Includes hands-on guidance on authoring the five foundational concepts (artefact types, laws, appraisers, cycles, flows) with worked examples you can run against real code. Also covers the optional flow-memory path: initialise memory, declare vocabulary, add extractors, and opt a cycle into assay for codebase-aware flows.
16
+
17
+ Implementers must follow every step and complete the bootstrap; architects typically skim for structure before moving to [concepts.md](concepts.md) and [architecture.md](architecture.md) to reason about their designs.
18
+
19
+ - **concepts.md** — The glossary and conceptual foundation for Foundry's key terms and ideas, arranged top-down from flows through cycles, stages, artefacts, and feedback loops.
20
+
21
+ Reach for this when you encounter terminology you need to understand, or as a reference map before diving into [work-spec.md](work-spec.md) or [architecture.md](architecture.md). Defines each concept affirmatively with concrete examples and links outward to spec documents that elaborate them in detail. Defines `Assay`, `Flow memory`, `Extractor`, and the read/write permission model that scopes memory tools per cycle.
22
+
23
+ Architects especially need this to reason about system boundaries, design decisions, and invariants; implementers reference it iteratively as they build configuration, debug unexpected behaviour, and reason about state transitions.
24
+
25
+ ## Reference
26
+
27
+ These documents specify formats, tools, and design principles. Use them when implementing tooling, understanding the work-file lifecycle, debugging state transitions, or reasoning about Foundry's guarantees and safety properties.
28
+
29
+ **Key property:** These are sources of truth and normative references. Changes to Foundry flow formats or tool behaviour must be reflected here first. Use them together—cross-references appear throughout.
30
+
31
+ - **work-spec.md** — Complete specification of the `WORK.md`, `WORK.feedback.yaml`, and `WORK.history.yaml` file formats, including frontmatter fields, the artefact registry, and the full feedback state machine with all valid transitions and guards.
32
+
33
+ Use this when implementing tooling around work files, validating state transitions, or understanding what metadata flows carry through an execution. It is the authoritative source of truth for all transient work-branch structures, format validation rules, and field semantics.
34
+
35
+ Implementers and tool builders rely on this heavily; keep it updated immediately as formats evolve or new fields are added.
36
+
37
+ - **tools.md** — Categorical index and reference documentation for all custom tools, organised by family (lifecycle, artefacts, feedback, config, memory, etc.) with complete signatures and permissions.
38
+
39
+ Consult this when you need to understand what a specific tool does, its branch requirements, what stage locks apply, what arguments it accepts, and how it integrates with the overall system. Covers calling conventions, enforcement invariants, and the permission model for memory access. References `foundry_assay_run`, `foundry_extractor_create`, and memory data and admin tools.
40
+
41
+ Tool authors and system integrators use this constantly; it is the comprehensive reference for all custom tools in the Foundry ecosystem.
42
+
43
+ - **architecture.md** — The design and enforcement model covering token lifecycle, stage-locked mutations, write invariants, branch namespaces, multi-model routing, and core design principles.
44
+
45
+ Read this when you need to understand how Foundry maintains safety (how tokens prevent replay, why stages lock mutations, how writes are validated), what guarantees it makes and where they live in the code, or why it is structured the way it is. Explains the memory layout, assay write boundary, and failed-flow behaviour that keep extractor-populated memory auditable.
46
+
47
+ Architects and contributors working on core systems need this to reason about changes and implications; see also concepts.md for the high-level flow model context and work-spec.md for specifics on format validation and state machines.
48
+
49
+ ## Contributors
50
+
51
+ Documentation for those extending Foundry's internals or maintaining subsystems. These documents go deeper into implementation detail and capture learning from production experience.
52
+
53
+ **When to use:** Start here if you are modifying core functionality, debugging subsystem behaviour, or maintaining systems beyond the public API.
54
+
55
+ - **memory-maintenance.md** — Cozo 0.7 adaptations, memory session lifecycle notes, and derived implementation wisdom for contributors working on the memory subsystem.
56
+
57
+ Start here if you are maintaining or extending memory-related functionality; it documents known footguns (string literal syntax, HNSW index pseudo-relations), session-lifecycle edge cases, tracing techniques, and runtime extractor population in precise detail.
58
+
59
+ Captures learning from actual bugs and debugging sessions so the next maintainer does not have to discover them again through repeated debugging. Core contributors should read this before touching memory code; it explains why certain patterns are necessary, which changes cascade across the system, and common pitfalls to avoid.