@really-knows-ai/foundry 2.3.1 → 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 +200 -198
  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 +42 -6
  122. package/{skills → dist/skills}/add-artefact-type/SKILL.md +49 -21
  123. package/{skills → dist/skills}/add-cycle/SKILL.md +60 -14
  124. package/dist/skills/add-extractor/SKILL.md +133 -0
  125. package/{skills → dist/skills}/add-flow/SKILL.md +39 -7
  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 -90
  150. package/docs/concepts.md +0 -59
  151. package/docs/getting-started.md +0 -78
  152. package/docs/work-spec.md +0 -193
  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 -105
  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
@@ -0,0 +1,490 @@
1
+ # Changelog
2
+
3
+ ## [3.0.0] - 2026-05-10
4
+
5
+ A consolidation release covering every change since v2.4.2. Foundry 3.0.0
6
+ restructures the branch model into three explicit kinds (`config/*`,
7
+ `work/*`, `dry-run/*/*`), introduces deterministic attestation, replaces
8
+ the markdown-parsed feedback section with a typed YAML store, adds the
9
+ assay pre-forge stage and the flow-memory subsystem, unifies law
10
+ authoring around a JSONL-validator model, and adds a verbose tracing /
11
+ forensic-snapshot loop for dry-runs. The work was developed across what
12
+ were originally numbered as 2.5.0, 2.6.0, 2.7.0, and 3.0.0 internal
13
+ milestones; only 3.0.0 is being released. Where an intermediate
14
+ milestone introduced a feature and a later milestone modified it, this
15
+ entry documents the 3.0.0 end-state only.
16
+
17
+ ### Branch-model breaking changes
18
+
19
+ - **`foundry_git_branch` requires explicit `kind`.** The previous
20
+ `{ flowId, description }` signature is removed. Callers must now pass
21
+ `kind: 'config' | 'work' | 'dry-run'`. Per-kind requirements:
22
+ `kind: 'config'` needs `description` and a non-`config/*`,
23
+ non-`work/*` starting branch; `kind: 'work'` needs `flowId`,
24
+ `description`, and a non-`config/*`, non-`work/*` starting branch;
25
+ `kind: 'dry-run'` needs `flowId`, `description`, and the operator
26
+ must already be on a `config/<x>` branch. `flowId` is invalid for
27
+ `kind: 'config'`.
28
+ - **`foundry_git_finish` dispatches on the current branch prefix.**
29
+ `work/<x>` retains existing semantics (squash-merge plus WORK
30
+ cleanup); `config/<x>` is new (squash-merge, no WORK cleanup);
31
+ `dry-run/<x>/<y>` writes a forensic snapshot under `.snapshots/`
32
+ on the parent `config/<x>` working tree and force-deletes the
33
+ dry-run branch (see "Dry-run finish writes a forensic snapshot"
34
+ below). Any other branch is refused with "nothing to finish".
35
+ `baseBranch` is rejected for dry-run finish (the parent config
36
+ branch is encoded in the dry-run branch name).
37
+ - **Dry-run namespace is `dry-run/<parent>/<flowId>-<desc>`, not
38
+ nested under `config/<parent>`.** Originally specified as
39
+ `config/<x>/dry-run/<y>`; git refuses to coexist a parent ref with
40
+ a child-prefixed ref, so the namespace is a flat sibling instead.
41
+ - **Schema/config mutation now requires a `config/*` branch.**
42
+ Affected tools: `foundry_config_create_artefact_type`,
43
+ `_create_appraiser`, `_create_flow`, `_create_cycle`,
44
+ `foundry_config_add_law`, `foundry_config_edit_law`,
45
+ `foundry_memory_create_entity_type` / `_create_edge_type` /
46
+ `_rename_entity_type` / `_rename_edge_type` / `_drop_entity_type` /
47
+ `_drop_edge_type`, `foundry_extractor_create`, `foundry_memory_init`,
48
+ `foundry_memory_reset`, `foundry_memory_change_embedding_model`. All
49
+ refuse on any branch other than `config/<description>`.
50
+ - **Flow-data mutation now requires a `work/*` or `dry-run/*/*`
51
+ branch.** Affected tools: `foundry_orchestrate`,
52
+ `foundry_workfile_create` / `_delete`, `foundry_artefacts_set_status`,
53
+ `foundry_feedback_*` (mutating variants), `foundry_assay_run`,
54
+ `foundry_validate_run`, `foundry_appraisers_select`,
55
+ `foundry_stage_begin` / `_end` / `_retry`, `foundry_memory_put` /
56
+ `_relate` / `_unrelate`.
57
+
58
+ ### Attestation, dry-run, and snapshot breaking changes
59
+
60
+ - **`foundry_git_finish` on `work/*` refuses without ATTEST.md at HEAD.**
61
+ Work-branch merges are gated on a deterministic attestation commit
62
+ produced by `foundry_attest`. Operators must run `foundry_attest`
63
+ with `confirm: true` before finishing a work branch.
64
+ - **Dry-run finish writes a forensic snapshot.** `foundry_git_finish`
65
+ on a `dry-run/<x>/<y>` branch writes `.snapshots/<run-id>/` on the
66
+ parent `config/<x>` working tree (containing `README.md`,
67
+ `work/WORK*`, `diff.patch`, `trace.jsonl`) and force-deletes the
68
+ dry-run branch. No merge, no commit.
69
+ - **`.snapshots/` is a new gitignored top-level directory.** It
70
+ appears in projects only after the first dry-run finish. Snapshots
71
+ are local operator artefacts and never committed by foundry.
72
+ - **Verbose tool-call tracing on dry-run branches.** Every `foundry_*`
73
+ tool call (except `foundry_orchestrate`, which uses inline guards)
74
+ appends a JSONL record to `.foundry/trace/<branch-slug>.jsonl` while
75
+ on a dry-run branch. The trace is truncated when the dry-run branch
76
+ is created and copied into the snapshot at finish.
77
+
78
+ ### Feedback and state-machine breaking changes
79
+
80
+ - **Feedback storage moved from markdown to YAML.** The `## Feedback`
81
+ section in `WORK.md` is removed. Feedback items now live in
82
+ `WORK.feedback.yaml` with full transition history per item. Any
83
+ legacy `## Feedback` content in an old `WORK.md` is inert text:
84
+ not parsed, not deleted, not written to.
85
+ - **Feedback tools switch from `{ file, index }` to `{ id }`
86
+ addressing.** `foundry_feedback_add` drops the `stageBase?`
87
+ argument (source is read from the active stage).
88
+ `foundry_feedback_list` response shape is now
89
+ `{ id, file, tag, text, source, state, depth, reason? }`. Item ids
90
+ are ULIDs.
91
+ - **Feedback state machine expands from 4 states to 6:** `open |
92
+ actioned | wont-fix | rejected | deadlocked | resolved`. `approved`
93
+ is renamed to `resolved` internally; the public resolve tool still
94
+ accepts `resolution: 'approved' | 'rejected'` as input.
95
+ - **Deadlock detection is per-item.** Each item's depth in its own
96
+ transition history is checked against `deadlock-iterations`. Items
97
+ freshly added in the threshold-th iteration are never auto-deadlocked.
98
+ - **Source-authorship rule.** Only the stage that created a feedback
99
+ item can resolve or reject it. `human-appraise` has universal
100
+ override authority — it may transition any non-resolved item to any
101
+ legal target state regardless of source.
102
+ - **Assay rejected as a feedback source.** `foundry_feedback_add`
103
+ and `WORK.feedback.yaml` refuse `source: 'assay'`. Assay failures
104
+ surface as a hard flow failure (see Assay breaking changes below).
105
+
106
+ ### Cycle and artefact-type breaking changes
107
+
108
+ - **Cycle frontmatter key renamed: `output:` → `output-type:`.** The
109
+ orchestrator no longer reads `output:`. Cycle definitions in
110
+ `foundry/flows/*/cycles/*.md` must use `output-type:` to declare
111
+ the artefact-type id the cycle produces. Unmigrated cycles yield a
112
+ hard violation pointing to the upgrade skill.
113
+ - **Artefact-type frontmatter `output:` is removed.** The field had
114
+ zero runtime consumers — forge's write scope is governed by
115
+ `file-patterns`, and `file-patterns` legitimately spans multiple
116
+ directories, so a single `output:` (or earlier-proposed
117
+ `output-dir:`) could not honestly describe artefact location.
118
+ Stale `output:` entries are harmless but should be deleted.
119
+
120
+ ### Assay and memory breaking changes
121
+
122
+ - **Assay extractor failure marks the workfile failed.** When an
123
+ extractor exits non-zero, parses incorrectly, violates permissions,
124
+ or times out, `foundry_assay_run` calls `markWorkfileFailed` and
125
+ returns `{flow_failed: true, error, …}`. It does not file a
126
+ `#validation` feedback item. Rationale: the failure cause (a
127
+ project-authored script under `foundry/memory/extractors/`) lives
128
+ outside any artefact's `file-patterns`, so forge has no way to act
129
+ on assay-sourced feedback; the prior behaviour produced
130
+ unsatisfiable state-machine items. Tooling that pattern-matched
131
+ assay-sourced feedback must instead detect `flow_failed: true` on
132
+ the assay-run response.
133
+ - **Memory NDJSON relations moved to `foundry-memory/relations/`.**
134
+ Per-type row data (`<entity-type>.ndjson`, `<edge-type>.ndjson`)
135
+ lives at the top-level `foundry-memory/relations/` directory,
136
+ sibling to `foundry/`. The rest of the memory tree (`config.md`,
137
+ `schema.json`, `entities/`, `edges/`, `extractors/`, the gitignored
138
+ `memory.db*` runtime files) stays under `foundry/memory/`.
139
+ Rationale: the relations directory is large, frequently rewritten,
140
+ and benefits from being separable from the human-authored config.
141
+
142
+ ### Law model breaking changes
143
+
144
+ - **Quench executes law-defined JSONL validators.** Each law in
145
+ `foundry/laws/*.md` or `foundry/artefacts/<typeId>/laws.md` declares
146
+ one or more validator commands in a fenced code block.
147
+ `foundry_validate_run` executes them, parses their JSONL output, and
148
+ returns per-item feedback (`{ lawId, validatorId, file, text,
149
+ location?, severity? }`). The quench skill emits one
150
+ `foundry_feedback_add` call per item tagged
151
+ `law:<lawId>:<validatorId>`. Items whose `file` falls outside the
152
+ artefact type's `file-patterns` are surfaced as `pattern-mismatch`
153
+ errors rather than silently swallowed.
154
+ - **Law authoring split into `add` and `edit`.** There is no
155
+ `foundry_config_create_law`; use `foundry_config_add_law` for new
156
+ laws and `foundry_config_edit_law` to replace an existing law in
157
+ place. `foundry_config_read_law` returns the full markdown for a
158
+ single law by id, and `foundry_config_validate_law` runs schema
159
+ validation against a candidate body without writing.
160
+
161
+ ### Added
162
+
163
+ - **`foundry_attest`, `foundry_attestation_show`,
164
+ `foundry_attestation_verify`.** Deterministic attestation
165
+ primitives. `foundry_attest` verifies the current work cycle is
166
+ complete (all required stages ran, no unresolved feedback, no
167
+ blocked artefacts), writes a canonical-JSON ATTEST.md payload
168
+ (cycle id, diff sha, stages, attestation tools, models), and
169
+ commits it to the work branch. `foundry_attestation_show` and
170
+ `_verify` read and re-verify an attestation after the fact. Takes
171
+ `baseBranch` (optional, default `main`), `message` (required goal
172
+ text), and `confirm` (must be `true` to write).
173
+ - **`foundry_stage_retry` tool.** Re-runs the last failed stage on a
174
+ failed workfile without abandoning the cycle. Requires the
175
+ workfile to be in `status: failed` and the cause to be transient
176
+ (network, model error). Restores the active-stage token and clears
177
+ the failed marker.
178
+ - **`foundry_config_create_*` tools** for the four kinds with a
179
+ single-file canonical layout (artefact-type, appraiser, flow,
180
+ cycle). Each produces one git commit per invocation on the current
181
+ `config/*` branch. Updates (replacing an existing file) are not
182
+ exposed as MCP tools for these kinds; operators edit by hand on
183
+ the current `config/*` branch.
184
+ - **`foundry_config_validate_*` tools** for all five config kinds
185
+ (artefact-type, law, appraiser, flow, cycle). Schema-only, no
186
+ branch guard, callable from any branch. Authors iterate on a draft
187
+ body, then call the corresponding `_create_*` or `_add_law` /
188
+ `_edit_law` to commit.
189
+ - **`foundry_config_read_law` tool.** Reads a single law by id,
190
+ returning its full markdown including the validators block. No
191
+ branch guard.
192
+ - **`foundry_snapshot_*` tools.** `foundry_snapshot_list`, `_show`,
193
+ `_delete`, `_prune` — programmatic inspection and cleanup of
194
+ dry-run forensic snapshots. Allowed on every branch.
195
+ - **Assay stage.** A deterministic pre-forge stage that runs
196
+ project-authored extractor scripts to populate flow memory before
197
+ forge starts. Opt-in per cycle via `assay: { extractors: [...] }`
198
+ in cycle frontmatter. Iteration-0-only. See
199
+ [docs/concepts.md](docs/concepts.md#assay).
200
+ - **`foundry_assay_run` and `foundry_extractor_create` plugin tools.**
201
+ `foundry_assay_run` executes the extractors declared by the active
202
+ assay stage. `foundry_extractor_create` registers a new extractor
203
+ definition at `foundry/memory/extractors/<name>.md`.
204
+ - **`add-extractor` skill.** Authoring loop for extractor definitions.
205
+ - **Flow memory subsystem.** A typed, graph-shaped knowledge store
206
+ that persists across cycles. Entity types, edge types, and their
207
+ prose briefs live in `foundry/memory/`; row data is committed as
208
+ NDJSON under `foundry-memory/relations/`; the live database
209
+ (`foundry/memory/memory.db*`) is gitignored and rebuilt on demand
210
+ from the NDJSON files. Each cycle declares read/write permissions
211
+ in its frontmatter (`memory: { read: [...], write: [...] }`). The
212
+ dispatched stage prompt is augmented with a vocabulary block
213
+ listing the entity/edge types and memory tools visible to that
214
+ cycle.
215
+ - **20 memory tools.** `foundry_memory_{put,relate,unrelate,get,list,
216
+ neighbours,query,search}` for read/write,
217
+ `foundry_memory_{create,rename,drop}_{entity,edge}_type` for
218
+ vocabulary management, `foundry_memory_{init,validate,reset,dump,
219
+ vacuum,change_embedding_model}` for admin. Destructive operations
220
+ (`_drop_*`) take an optional `confirm` — without it they return a
221
+ preview of affected rows.
222
+ - **9 memory authoring skills.** `init-memory`,
223
+ `add-memory-entity-type`, `add-memory-edge-type`,
224
+ `rename-memory-entity-type`, `rename-memory-edge-type`,
225
+ `drop-memory-entity-type`, `drop-memory-edge-type`, `reset-memory`,
226
+ `change-embedding-model`.
227
+ - **Optional semantic search.** When `embeddings.enabled` is true in
228
+ `foundry/memory/config.md`, entities are embedded on write against
229
+ an OpenAI-compatible endpoint (default: local Ollama
230
+ `nomic-embed-text`, 768 dims) and exposed via
231
+ `foundry_memory_search`. Embeddings can be disabled; the graph
232
+ still works without them.
233
+ - **`dry-run` skill.** Documents the
234
+ config-edit → dry-run → finish → inspect-snapshot loop.
235
+ - **`WORK.feedback.yaml`.** First-class persistent record of every
236
+ feedback item and its full transition history. Atomic writes via
237
+ write-temp-then-rename.
238
+ - **`open_feedback` and `seq` on every `WORK.history.yaml` entry.**
239
+ `open_feedback` records the count of open items at each tick; `seq`
240
+ acts as a tiebreaker for same-millisecond timestamps.
241
+ - **Failed-flow guards on mutating tools.** `foundry_validate_run`
242
+ and 11 mutating memory admin tools (`foundry_memory_init`,
243
+ `_reset`, `_vacuum`, `_change_embedding_model`,
244
+ `_create_entity_type`, `_create_edge_type`, `_rename_entity_type`,
245
+ `_rename_edge_type`, `_drop_entity_type`, `_drop_edge_type`, and
246
+ `foundry_extractor_create`) refuse on a failed workfile. Read-only
247
+ memory tools (`_dump`, `_validate`) remain callable.
248
+ - **Deterministic orchestration.** `foundry_orchestrate` owns the
249
+ sort → history → dispatch → finalize → history → commit loop in
250
+ plugin code. Orphaned-stage detection: if `orchestrate` is called
251
+ without `lastResult` while an active stage exists, returns
252
+ `violation`.
253
+ - **Atomic stage tokens.** `foundry_stage_begin(stage, cycle, token)`
254
+ consumes a single-use HMAC-signed token issued by `foundry_sort`;
255
+ `foundry_stage_end(summary)` closes a stage preserving `baseSha`
256
+ for finalize; `foundry_stage_finalize` verifies stage output
257
+ against allowed file patterns and registers matching files as
258
+ draft artefacts, rejecting stray writes with
259
+ `{error: "unexpected_files", files: [...]}`.
260
+ - **`.foundry/` state directory** (gitignored) — holds `.secret`
261
+ (per-worktree HMAC key, mode 0600), `active-stage.json` (present
262
+ only during an active stage), `last-stage.json` (for finalize
263
+ lookup), and `trace/` (dry-run JSONL traces).
264
+
265
+ ### Changed
266
+
267
+ - **`foundry_memory_dump` response wrapped in a JSON envelope.** Now
268
+ returns `{ dump: "<text>" }`, matching every other plugin tool's
269
+ contract. Callers that previously consumed the raw string must
270
+ read `.dump`.
271
+ - **`foundry_git_branch` errors return a JSON envelope.** Failures
272
+ are returned as `{ error: "<message>" }`, giving callers a
273
+ structured alternative to raw `execFileSync` errors.
274
+ - **`cozo-node` is now an optional dependency.** Foundry installs
275
+ without it; the memory subsystem reports
276
+ `"cozo-node is not installed on this platform"` if a memory tool
277
+ is invoked. This unblocks installation on platforms without
278
+ prebuilt cozo binaries.
279
+ - **Test suite split into unit, integration, and e2e tiers.** Run
280
+ individually with `pnpm run test`, `pnpm run test:integration`,
281
+ `pnpm run test:e2e`, or all together with `pnpm run test:all`.
282
+ `pnpm run build:all` chains lint → test:all → build.
283
+ - **`prepublishOnly` runs `build:all`.** Publish is now gated on the
284
+ full quality pipeline, not just `build`.
285
+
286
+ ### Fixed
287
+
288
+ - **Stage-end memory sync failure is a hard flow failure.** When
289
+ `foundry_stage_end` cannot flush the in-memory DB to the NDJSON
290
+ source of truth, WORK.md is marked `status: failed` with the sync
291
+ error as `reason`, and every mutating tool refuses until the cycle
292
+ is abandoned via `foundry_workfile_delete`. Read-only tools and
293
+ the escape hatches (`workfile_delete`, `git_finish`) remain
294
+ callable. Skills driving each stage (`forge`, `quench`, `appraise`,
295
+ `human-appraise`, `orchestrate`, `assay`, `flow`) were updated to
296
+ check for the failed state at the top of their procedure and hand
297
+ control back to the user. Previously, sync failures were silently
298
+ swallowed and the live DB was allowed to drift ahead of on-disk
299
+ NDJSON.
300
+ - **`foundry_orchestrate` catches `requireNotFailed` violations.**
301
+ Moved the failed-flow check inside the wrapper try/catch so a
302
+ malformed-frontmatter `YAMLException` collapses to
303
+ `{action: 'violation'}` instead of an uncaught throw.
304
+ - **Missing artefact-type definitions surface a typed finalize error.**
305
+ The orchestrator's finalize bridge now returns
306
+ `{ok: false, error: "missing_artefact_type: <type> (<reason>)"}`
307
+ when `getArtefactType` fails, preserving the real error and
308
+ avoiding a false `unexpected_files` violation.
309
+ - **Atomic history writes.** `WORK.history.yaml` writes use
310
+ write-temp-then-rename, closing observed incompleteness in the
311
+ wild. Malformed history on read now marks the flow failed via
312
+ `markWorkfileFailed`, allowing graceful recovery rather than
313
+ silent corruption.
314
+ - **Validation results structured per item.** `foundry_validate_run`
315
+ returns `{ ok, validatorsRun, items, errors }` with `items` as
316
+ parsed JSONL entries and `errors` separating parse failures from
317
+ pattern mismatches. Replaces the prior unstructured aggregate.
318
+
319
+ ### Migration
320
+
321
+ Run the `upgrade-foundry` skill from a clean project state. Foundry
322
+ upgrades use a rebuild-style workflow: the skill preserves the
323
+ existing `foundry/` directory, initialises a clean current-version
324
+ configuration, analyses the preserved directory as source material,
325
+ and recreates supported concepts through current tools.
326
+
327
+ The skill asks clarifying questions for ambiguous flow routing, input
328
+ contracts, validation behaviour, memory settings, and deprecated
329
+ concepts. It does not migrate in-flight `WORK.md` state, feedback
330
+ state, branch state, or active flow execution. Complete or discard
331
+ active flows before upgrading.
332
+
333
+ Cycle definitions must rename `output:` to `output-type:`. Artefact-type
334
+ definitions should delete the `output:` line. Projects with a populated
335
+ memory store should `git mv foundry/memory/relations
336
+ foundry-memory/relations` before re-initialising; projects that have
337
+ not yet populated memory can simply re-run `foundry_memory_init` on a
338
+ fresh `config/*` branch. Pre-3.0.0 in-flight feedback in the markdown
339
+ `## Feedback` section is not auto-migrated: finish or discard
340
+ in-flight cycles before upgrading.
341
+
342
+ Projects with populated memory should validate memory before upgrading
343
+ so the preserved source material reflects committed state. The
344
+ recreated current-version config should be validated with the current
345
+ config and memory validation tools before merging the config branch.
346
+
347
+ ### Known issues
348
+
349
+ - **Flow memory backend (`cozo-node`) is unmaintained.** The optional
350
+ flow-memory subsystem persists to `cozo-node`, whose upstream
351
+ packages have not seen a release since December 2023
352
+ (`cozo-node@0.7.6`) and whose Rust core (`cozodb/cozo`) has not
353
+ been pushed to since December 2024. The memory tools continue to
354
+ work and there are no known runtime issues, but `cozo-node@0.7.6`
355
+ transitively depends on `@mapbox/node-pre-gyp@^1`, which surfaces
356
+ six `deprecated subdependency` warnings at install time
357
+ (`are-we-there-yet`, `gauge`, `glob@7`, `inflight`, `npmlog`,
358
+ `rimraf@3`). These warnings are cosmetic: `pnpm audit` reports
359
+ zero vulnerabilities. Foundry will migrate to a maintained graph +
360
+ vector backend in a future release; the memory tool surface
361
+ (`foundry_memory_*`) and the on-disk vocabulary / NDJSON format
362
+ are designed to remain stable across that migration.
363
+
364
+ ## 2.4.2 — 2026-04-23
365
+
366
+ ### Changed
367
+
368
+ - README: new hero-style "Governed work for AI" section before the TOC — names the discipline problem, lists what developers get, speaks to teams under a "structural, not cultural" framing.
369
+ - README: old "Why Foundry?" section removed; the five bullets it contained now live under a renamed "Design principles" section (was "Design decisions"), prefaced with the governing rule (*trust the tool, not the LLM*) and extended with a new principle entry on human-in-the-loop gates.
370
+
371
+ ## 2.4.1 — 2026-04-23
372
+
373
+ ### Fixed
374
+
375
+ - `docs/getting-started.md` install snippet used a `packages` key that doesn't exist in OpenCode's config schema. Corrected to the `plugin: ["@really-knows-ai/foundry"]` form already shown in `README.md`.
376
+
377
+ ## 2.4.0 — 2026-04-23
378
+
379
+ ### Added
380
+
381
+ - **Flow memory** — a typed, graph-shaped knowledge store that persists across cycles. Entity types, edge types, and their prose briefs live in `foundry/memory/`; entity rows and edge rows are committed as NDJSON under `foundry/memory/relations/`; the live Cozo 0.7 database (`foundry/memory/memory.db*`) is gitignored and rebuilt on demand from the NDJSON files. Each cycle declares read/write permissions in its frontmatter (`memory: { read: [...], write: [...] }`); the dispatched stage prompt is augmented with a vocabulary block listing the entity/edge types visible to that cycle and the memory tools available to it.
382
+ - **Optional semantic search.** When `embeddings.enabled` is true in `foundry/memory/config.md`, entities are embedded on write against an OpenAI-compatible endpoint (default: local Ollama `nomic-embed-text`, 768 dims) and exposed via `foundry_memory_search`. Embeddings can be disabled; the graph still works.
383
+ - **20 memory tools** registered by the plugin: `foundry_memory_{put,relate,unrelate,get,list,neighbours,query,search}` for read/write, `foundry_memory_{create,rename,drop}_{entity,edge}_type` for vocabulary management, `foundry_memory_{init,validate,reset,dump,vacuum,change_embedding_model}` for admin. Destructive operations (`drop_*`) take an optional `confirm` — without it they return a preview of affected rows.
384
+ - **9 memory skills**: `init-memory`, `add-memory-entity-type`, `add-memory-edge-type`, `rename-memory-entity-type`, `rename-memory-edge-type`, `drop-memory-entity-type`, `drop-memory-edge-type`, `reset-memory`, `change-embedding-model`. All wrap the deterministic admin tools with the usual conflict-checking, preview-then-confirm, and commit discipline.
385
+ - `docs/memory-maintenance.md` — contributor notes on Cozo 0.7 adaptations (`::compact`, typed `<F32;N>?` vector columns, `?[...] <- [[...]]` put syntax, single-vs-double-quote string literal semantics, `::relations` HNSW filtering) and the session-singleton lifecycle constraint.
386
+
387
+ ### Notes
388
+
389
+ - Memory is strictly opt-in. A project without `foundry/memory/` behaves exactly as before; the prompt-extras injection no-ops, and cycles that don't declare a `memory:` block see no vocabulary and no memory tools in their prompt.
390
+ - On store open, orphan relations left behind by drops/renames are reconciled automatically (`::relations` filtered to `^(ent|edge)_[^:]+$`, HNSW indices dropped before `::remove`).
391
+ - Memory prompt injection is wrapped in a swallow-errors guard: if memory is misconfigured or drifted, dispatch still succeeds with no vocabulary block rather than failing the cycle.
392
+
393
+ ## 2.3.2 — 2026-04-21
394
+
395
+ ### Changed
396
+
397
+ - Config-modifying skills (`add-flow`, `add-cycle`, `add-law`, `add-appraiser`, `add-artefact-type`) now refuse to run on a work branch. They require the current branch to not start with `work/`, directing the user to complete or discard the in-flight flow before changing foundry configuration. Structural changes belong on the base branch, not alongside transient flow state.
398
+
399
+ ### Removed
400
+
401
+ - Historical planning docs (`docs/plans/`, `docs/specs/`, `docs/superpowers/`) and `HARDEN.md`. All described features that shipped in v2.2.0–v2.3.1; git history preserves the full record.
402
+
403
+ ## 2.3.1 — 2026-04-20
404
+
405
+ ### Changed
406
+
407
+ - `flow` skill: any cycle in a flow may now be the starting cycle (previously limited to `starting-cycles`). The list becomes a hint for ambiguous requests. A cycle whose `inputs` contract cannot be satisfied from files on disk is not eligible to start.
408
+ - `flow` skill: between-cycles logic no longer implies any carry-over ceremony. The next cycle's forge discovers the previous cycle's output via filesystem scan against its input types' `file-patterns`.
409
+ - `forge` skill: input discovery now explicitly uses filesystem scan against each input type's `file-patterns`, with the goal guiding which candidates are relevant.
410
+ - `forge` skill: the write invariant is restated accurately — forge may only write to files matching the output artefact type's `file-patterns` (plus the tool-managed files). All other files on disk are read-only. The previous "inputs are read-only" framing was a special case of this rule.
411
+
412
+ ### Notes
413
+
414
+ - No tool, schema, or enforcement changes. Existing flows continue to work. `sort.js`'s `checkModifiedFiles` already enforces the write invariant.
415
+
416
+ ## 2.3.0 — 2026-04-20
417
+
418
+ ### Breaking
419
+
420
+ - **LLM orchestration replaced with deterministic `foundry_orchestrate` tool.** The `cycle` and `sort` skills are removed; replaced by a single thin `orchestrate` skill that drives a 3-line loop.
421
+ - **Six tools deregistered** from the plugin (still exist as internal imports for tests): `foundry_sort`, `foundry_history_append`, `foundry_stage_finalize`, `foundry_git_commit`, `foundry_workfile_configure_from_cycle`, `foundry_workfile_set`.
422
+ - Upgrade requires clean main + no in-flight workfile (see `upgrade-foundry` skill).
423
+
424
+ ### Added
425
+
426
+ - `foundry_orchestrate` — single tool that owns the sort → history → dispatch → finalize → history → commit loop. Atomic stage completion.
427
+ - `scripts/orchestrate.js` — deterministic orchestration logic, composes existing internal functions.
428
+ - Orphaned-stage detection: if orchestrate is called without `lastResult` but an active stage exists, returns `violation`. Fixes the ses_256c failure mode where an LLM skipped the post-dispatch history append and wedged the cycle.
429
+
430
+ ### Fixed
431
+
432
+ - Root cause of all deferred HARDEN.md bugs (B, C, D, E, G) and the ses_256c bug: LLM misfollowing a deterministic protocol. Protocol now lives inside the plugin tool.
433
+
434
+ ### Migration
435
+
436
+ See `skills/upgrade-foundry/SKILL.md` for v2.3.0 pre-flight checks. No automated state migration — complete or discard in-flight cycles on v2.2.x before upgrading.
437
+
438
+ ## 2.2.1 — 2026-04-20
439
+
440
+ Follow-up patch addressing the five bugs deferred from v2.2.0 (see `HARDEN.md` §Deferred).
441
+
442
+ ### Breaking changes
443
+
444
+ - **Cycle-definition deadlock config flattened.** The nested `human-appraise: {enabled, deadlock-threshold}` block is replaced by three flat keys:
445
+ - `human-appraise: <bool>` (default `false`) — include `human-appraise` in the stage loop every iteration
446
+ - `deadlock-appraise: <bool>` (default `true`) — route to `human-appraise` when LLM appraisers deadlock
447
+ - `deadlock-iterations: <number>` (default `5`) — deadlock threshold
448
+ Run the `upgrade-foundry` skill to migrate existing cycle defs — the old nested form is no longer read.
449
+
450
+ ### New
451
+
452
+ - **`foundry_workfile_configure_from_cycle({cycleId, stages})`** — populates WORK.md frontmatter from a cycle definition in one call. Replaces the prior 6–7 sequential `foundry_workfile_set` calls at cycle start. Defaults for `max-iterations`, `human-appraise`, `deadlock-appraise`, `deadlock-iterations`, and `models` now live in plugin code rather than skill prose.
453
+ - **`foundry_artefacts_list({cycle})`** — optional cycle filter. Callers should always pass the current cycle to avoid picking up stale rows from prior aborted sessions.
454
+
455
+ ### Fixed
456
+
457
+ - **Bug B — deadlock routing.** Sort now reads the flat deadlock keys from WORK.md frontmatter and routes to `human-appraise` on deadlock (either an existing `human-appraise:<cycle>` stage in `stages`, or a synthesized one). When `deadlock-appraise: false`, deadlock marks the cycle `blocked`.
458
+ - **Bug C — stale artefact validation.** `quench`, `appraise`, and `human-appraise` skills now pass the current cycle to `foundry_artefacts_list`, scoping validation to artefacts produced by the current cycle.
459
+ - **Bug D — overwriting WORK.md.** The `flow` skill now calls `foundry_workfile_get` before `foundry_workfile_create` and prompts the user to resume, discard, or abort when an existing workfile is detected. Silent overwrite is not offered; resume requires matching `flow` and `cycle`.
460
+ - **Bug E — missing micro-commits.** `foundry_sort` now returns `{route: 'violation'}` when `WORK.md`, `WORK.history.yaml`, or anything under `.foundry/` has uncommitted changes at the start of a sort call and history is non-empty. Structurally enforces the one-commit-per-stage contract that previously lived only in skill prose. First sort of a cycle is exempt (empty history).
461
+ - **Bug G — workfile setup boilerplate.** See `foundry_workfile_configure_from_cycle` above.
462
+
463
+ ### Migration
464
+
465
+ Run the `upgrade-foundry` skill to migrate cycle definitions to the flat deadlock keys (Bug B). No other migration required — WORK.md, `.foundry/`, and feedback state are forward-compatible.
466
+
467
+ ## 2.2.0 — 2026-04-19
468
+
469
+ ### Breaking changes
470
+
471
+ - **`foundry_artefacts_add` removed.** Artefact registration now happens exclusively via `foundry_stage_finalize` after a forge stage closes.
472
+ - **`foundry_artefacts_set_status` no longer accepts `draft`.** Only `done` and `blocked` are valid. New artefacts are registered as `draft` automatically by `stage_finalize`.
473
+ - **Feedback / artefact / workfile mutation tools now enforce stage-lock preconditions.** Tools callable by subagents require an active stage matching their role; tools callable by the orchestrator require no active stage. Out-of-band calls return a structured error.
474
+ - **Feedback state machine strictly enforced.** `approved` is terminal. `quench` cannot approve/reject `wont-fix` items. See `HARDEN.md` §4 for the full matrix.
475
+ - **`foundry_sort` dispatchable routes now return a `token` field.** Subagents must redeem the token via `foundry_stage_begin`; forged or replayed tokens are rejected.
476
+
477
+ ### New
478
+
479
+ - **`foundry_stage_begin(stage, cycle, token)`** — subagents open a work stage by consuming a single-use HMAC-signed token.
480
+ - **`foundry_stage_end(summary)`** — subagents close a stage; preserves `baseSha` for finalize.
481
+ - **`foundry_stage_finalize(cycle)`** — orchestrator verifies stage output against allowed file patterns, registers matching files as draft artefacts, rejects stray writes with `{error: "unexpected_files", files: [...]}`.
482
+ - **`.foundry/` state directory** (gitignored) — holds `.secret` (per-worktree HMAC key, mode 0600), `active-stage.json` (present only during an active stage), `last-stage.json` (for finalize lookup).
483
+
484
+ ### Fixed
485
+
486
+ - Normalized `maxIterations` → `max-iterations` across workfile read/write paths (previously inconsistent between flow and cycle skills, causing latent deadlock-detection issues).
487
+
488
+ ### Migration
489
+
490
+ Upgrade with the `upgrade-foundry` skill. `.foundry/` is created automatically on first plugin boot; `.secret` is generated idempotently. No data migration required — existing `WORK.md` and `foundry/*` configs are compatible.
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Really Knows AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.