@staix/agent-hub 0.34.1 → 0.36.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 (213) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +53 -7
  3. package/docs/adding-an-ai-tool.md +2 -2
  4. package/docs/addons/claude-mem.md +4 -4
  5. package/docs/addons/open-code-review.md +1 -1
  6. package/docs/agent-notes/README.md +66 -0
  7. package/docs/agent-notes/adapters.md +14 -7
  8. package/docs/agent-notes/budget.md +1 -1
  9. package/docs/agent-notes/bus.md +2 -1
  10. package/docs/agent-notes/daemon.md +9 -7
  11. package/docs/agent-notes/local-worker.md +1 -1
  12. package/docs/agent-notes/models.md +5 -2
  13. package/docs/agent-notes/tasks.md +9 -2
  14. package/docs/agent-notes/tests.md +6 -0
  15. package/docs/design/adapters.md +182 -2
  16. package/docs/design/agent-hub-architecture.md +64 -2
  17. package/docs/design/agent-hub.md +6 -0
  18. package/docs/design/bus.md +26 -0
  19. package/docs/design/execution-reference.md +306 -0
  20. package/docs/design/guidance-experiments.md +438 -0
  21. package/docs/design/model-routes.md +628 -0
  22. package/docs/design/supervision.md +121 -0
  23. package/docs/design/task-board.md +121 -0
  24. package/docs/dogfood.md +45 -13
  25. package/docs/events.md +38 -20
  26. package/docs/memory.md +21 -7
  27. package/docs/operations.md +824 -40
  28. package/docs/profiles.md +2 -2
  29. package/docs/quickstart.md +117 -4
  30. package/docs/research.md +73 -13
  31. package/docs/roles.md +1 -1
  32. package/docs/sdlc.md +117 -11
  33. package/docs/security.md +153 -15
  34. package/docs/smoke.md +14 -0
  35. package/docs/specs/2026-09-19-agent-hub-design.md +13 -7
  36. package/docs/verification/2026-10-25-qwen-dual-output-t0.md +22 -0
  37. package/docs/verification/2026-11-07-compat-python-startup-1248.md +51 -0
  38. package/docs/verification/2026-11-07-compat-receipt-harness-1248.md +105 -0
  39. package/docs/verification/2026-11-07-compat-receipt-producers-1248.md +96 -0
  40. package/docs/verification/2026-11-07-compat-workflow-1248.md +94 -0
  41. package/docs/verification/2026-11-07-daemon-startup-1232.md +169 -0
  42. package/docs/verification/2026-11-07-jcode-receipt-reconstruction-1248.md +118 -0
  43. package/docs/verification/2026-11-07-kimi-delayed-usage.md +34 -0
  44. package/docs/verification/2026-11-07-kimi-review-watch-1284.md +115 -0
  45. package/docs/verification/2026-11-08-agy-1.5.3.md +96 -0
  46. package/docs/verification/2026-11-08-agy-acp-t0.md +56 -0
  47. package/docs/verification/2026-11-08-hub-visual-1058.md +161 -0
  48. package/docs/verification/2026-11-08-jcode-0991-model-setter-1317.md +143 -0
  49. package/docs/verification/2026-11-08-kimi-252-model-setter-1317.md +137 -0
  50. package/docs/verification/2026-11-08-kimi-tui-completion-1282.md +45 -0
  51. package/docs/verification/2026-11-08-kimi-wire-yield-1283.md +31 -0
  52. package/docs/verification/2026-11-08-live-model-override-1317.md +250 -0
  53. package/docs/verification/2026-11-08-qwen-0269-acp.md +138 -0
  54. package/docs/verification/2026-11-08-qwen-0269-model-setter-1317.md +91 -0
  55. package/docs/verification/2026-11-09-0.35.0.md +129 -0
  56. package/docs/verification/2026-11-09-headless-records-1320.md +157 -0
  57. package/docs/verification/2026-11-09-qwen-0270-acp.md +181 -0
  58. package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +46 -0
  59. package/docs/verification/2026-11-10-0.36.0.md +59 -0
  60. package/docs/verification/2026-11-10-claude-implementer-2.1.322.md +59 -0
  61. package/docs/verification/2026-11-10-qwen-0270-dual-output.md +367 -0
  62. package/docs/verification/2026-11-10-qwen-0271-dual-output.md +101 -0
  63. package/docs/verification/claude-permission-transport-native.py +10 -3
  64. package/docs/verification/claude-shell-wrapper-native.py +8 -8
  65. package/docs/verified.json +245 -15
  66. package/package.json +3 -3
  67. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  68. package/plugins/agent-hub/kimi-hook.js +21230 -0
  69. package/plugins/agent-hub/kimi-review-policy-worker.js +217 -0
  70. package/plugins/agent-hub/server.js +4359 -1071
  71. package/scripts/check-docs.mjs +12 -1
  72. package/src/adapters/acp-model-policy.ts +56 -0
  73. package/src/adapters/acp.ts +175 -5
  74. package/src/adapters/agy/entry.ts +8 -5
  75. package/src/adapters/agy/hooks.ts +65 -15
  76. package/src/adapters/channel-peer.ts +33 -1
  77. package/src/adapters/claude-channel.ts +7 -4
  78. package/src/adapters/claude-implementer.ts +16 -3
  79. package/src/adapters/codex-appserver.ts +118 -8
  80. package/src/adapters/codex-review-isolation.ts +3 -1
  81. package/src/adapters/compat.ts +18 -13
  82. package/src/adapters/definitions/builtin-metadata.ts +8 -1
  83. package/src/adapters/definitions/native-cli-entry-kimi.ts +76 -7
  84. package/src/adapters/definitions/native-cli-preview-common.ts +2 -2
  85. package/src/adapters/definitions/native-cli-preview-kimi.ts +9 -2
  86. package/src/adapters/definitions/reviewer-variants.ts +3 -1
  87. package/src/adapters/kimi-review-policy-worker.js +2 -0
  88. package/src/adapters/kimi-review-policy-worker.ts +85 -0
  89. package/src/adapters/kimi-review-policy.ts +68 -0
  90. package/src/adapters/kimi-review.ts +41 -41
  91. package/src/adapters/kimi-tui-facts.ts +153 -0
  92. package/src/adapters/kimi-wire-usage.ts +33 -8
  93. package/src/adapters/local-worker.ts +60 -21
  94. package/src/adapters/model-token.ts +3 -0
  95. package/src/adapters/pi.ts +27 -5
  96. package/src/adapters/qwen-dual.ts +324 -44
  97. package/src/adapters/registry-types.ts +34 -3
  98. package/src/adapters/registry.ts +1 -0
  99. package/src/adapters/reviewer-policy-watch.ts +86 -0
  100. package/src/adapters/reviewer-print.ts +80 -18
  101. package/src/cli/agents.ts +1 -1
  102. package/src/cli/facts-hook.ts +4 -2
  103. package/src/cli/guidance.ts +67 -0
  104. package/src/cli/help.ts +13 -5
  105. package/src/cli/identity.ts +13 -3
  106. package/src/cli/init-prompt.ts +15 -2
  107. package/src/cli/init-required-checks.ts +122 -0
  108. package/src/cli/init-settings.ts +10 -4
  109. package/src/cli/init.ts +39 -3
  110. package/src/cli/kimi-facts-hook.ts +11 -0
  111. package/src/cli/kimi-plugin.ts +157 -0
  112. package/src/cli/lineage.ts +78 -0
  113. package/src/cli/main.ts +159 -19
  114. package/src/cli/model.ts +52 -0
  115. package/src/cli/output.ts +23 -1
  116. package/src/cli/reset.ts +1 -1
  117. package/src/cli/setup-research.ts +10 -0
  118. package/src/cli/status-lines.ts +8 -4
  119. package/src/hub/autonomy-defaults.ts +20 -9
  120. package/src/hub/board.ts +346 -4
  121. package/src/hub/budget.ts +1 -1
  122. package/src/hub/build-entry.ts +11 -0
  123. package/src/hub/bus.ts +52 -2
  124. package/src/hub/ci-watch.ts +4 -4
  125. package/src/hub/code-facts.ts +10 -3
  126. package/src/hub/completions.ts +3 -1
  127. package/src/hub/config-apply.ts +3 -1
  128. package/src/hub/config-trust.ts +1 -0
  129. package/src/hub/control-client.ts +1 -1
  130. package/src/hub/daemon.ts +1387 -121
  131. package/src/hub/deliverable-files.ts +38 -5
  132. package/src/hub/delivery-hints.ts +4 -2
  133. package/src/hub/delivery-journal.ts +50 -2
  134. package/src/hub/delivery-public.ts +51 -0
  135. package/src/hub/dogfood-profile.ts +9 -5
  136. package/src/hub/envelope.ts +1 -1
  137. package/src/hub/events.ts +28 -18
  138. package/src/hub/execution-lineage-owner.ts +272 -0
  139. package/src/hub/execution-lineage.ts +164 -0
  140. package/src/hub/execution-links.ts +85 -0
  141. package/src/hub/execution-reference.ts +36 -0
  142. package/src/hub/guidance-variants.ts +398 -0
  143. package/src/hub/handoff.ts +1 -0
  144. package/src/hub/hub-tools.ts +62 -2
  145. package/src/hub/instances.ts +4 -3
  146. package/src/hub/kimi-events.ts +46 -0
  147. package/src/hub/kimi-usage.ts +132 -29
  148. package/src/hub/lifecycle.ts +31 -15
  149. package/src/hub/limits.ts +13 -4
  150. package/src/hub/manager.ts +58 -3
  151. package/src/hub/memory-policy.ts +4 -3
  152. package/src/hub/memory-sync-attestation.ts +54 -0
  153. package/src/hub/memory-sync-state.ts +20 -5
  154. package/src/hub/model-overrides.ts +115 -0
  155. package/src/hub/native-hook-launch.ts +12 -3
  156. package/src/hub/operational-view.ts +2 -2
  157. package/src/hub/peers.ts +28 -1
  158. package/src/hub/permission-mode.ts +1 -1
  159. package/src/hub/person-figures.ts +88 -0
  160. package/src/hub/planning.ts +1 -1
  161. package/src/hub/progress.ts +24 -7
  162. package/src/hub/report.ts +38 -4
  163. package/src/hub/research-dataset.ts +158 -0
  164. package/src/hub/research-memory.ts +68 -0
  165. package/src/hub/research-quality.ts +118 -0
  166. package/src/hub/research-record.ts +279 -0
  167. package/src/hub/research.ts +126 -27
  168. package/src/hub/restart.ts +27 -0
  169. package/src/hub/roles.ts +26 -0
  170. package/src/hub/routing.ts +4 -1
  171. package/src/hub/sdlc-merge.ts +39 -1
  172. package/src/hub/sdlc-release.ts +1 -1
  173. package/src/hub/sdlc.ts +62 -11
  174. package/src/hub/settings.ts +5 -0
  175. package/src/hub/startup-event-seeds.ts +51 -0
  176. package/src/hub/startup-readiness.ts +65 -0
  177. package/src/hub/startup-timing.ts +38 -0
  178. package/src/hub/supervision-proposals.ts +405 -0
  179. package/src/hub/supervision-rules.ts +388 -0
  180. package/src/hub/supervision.ts +2 -0
  181. package/src/hub/task-approval.ts +2 -2
  182. package/src/hub/task-repository.ts +5 -0
  183. package/src/hub/tasks.ts +632 -59
  184. package/src/hub/ui.ts +9 -5
  185. package/src/hub/visual-assets.ts +50 -0
  186. package/src/hub/visual.ts +257 -0
  187. package/src/memory/brief.ts +169 -14
  188. package/src/memory/capture.ts +4 -3
  189. package/src/memory/recall.ts +46 -5
  190. package/src/memory/record-provenance.ts +82 -0
  191. package/src/memory/records.ts +116 -0
  192. package/src/models/relay.ts +9 -2
  193. package/src/models/route/adec.ts +190 -0
  194. package/src/models/route/config.ts +64 -3
  195. package/src/models/route/decision-evidence.ts +83 -0
  196. package/src/models/route/decision.ts +215 -0
  197. package/src/models/route/relay-selector.ts +8 -7
  198. package/src/models/route/runtime.ts +35 -22
  199. package/src/models/route/stage-diagnostics.ts +22 -0
  200. package/src/models/route/stage-evidence.ts +55 -0
  201. package/src/models/route/stage-fallback.ts +58 -0
  202. package/src/models/route/stage-input.ts +155 -0
  203. package/src/models/route/stage.ts +5 -147
  204. package/src/ui/guidance-panel.ts +156 -0
  205. package/src/ui/guidance-view.ts +43 -0
  206. package/src/ui/index.html +134 -6
  207. package/src/ui/lineage-view.ts +34 -0
  208. package/src/ui/plugin.ts +136 -11
  209. package/templates/AGENTS.block.md +1 -1
  210. package/templates/config.json +1 -1
  211. package/templates/profiles/general.json +1 -1
  212. package/templates/profiles/research.json +1 -1
  213. package/templates/profiles/writing.json +1 -1
@@ -0,0 +1,438 @@
1
+ ---
2
+ id: guidance-experiments
3
+ type: module
4
+ title: Immutable Guidance Variants
5
+ status: draft
6
+ parent: agent-hub-architecture
7
+ depends-on: [execution-reference, task-board]
8
+ references: [execution-reference, task-board]
9
+ implements: []
10
+ covers: [guidance-experiments]
11
+ tags: [agent-hub]
12
+ paths:
13
+ - src/hub/roles.ts
14
+ - src/hub/guidance-variants.ts
15
+ - test/guidance-variants.test.ts
16
+ - test/fixtures/guidance-variant-v1.json
17
+ - test/guidance-variants-lifecycle.test.ts
18
+ - test/guidance-variants-privacy.test.ts
19
+ - test/guidance-variants-recovery.test.ts
20
+ - src/cli/guidance.ts
21
+ - src/ui/guidance-view.ts
22
+ - src/ui/guidance-panel.ts
23
+ - test/guidance-views.test.ts
24
+ - test/guidance-control.test.ts
25
+ - test/guidance-console.test.ts
26
+ - test/guidance-pagination.test.ts
27
+ ---
28
+
29
+ # Immutable guidance variants
30
+
31
+ This is the T1/T2 contract for [#1225](https://github.com/STAIxBWLB/agent-hub/issues/1225).
32
+ T1 represents a proposed change to one task role as immutable local data. Its
33
+ pure APIs do not persist an experiment. T2 adds Tasks admission and private
34
+ lifecycle storage. Neither slice creates a live role, rewrites a catalog, changes
35
+ a session, grants permission or runs a probe. Public CLI/MCP/console dispatch is
36
+ T3; actual confined handoff and probe receipts belong to #1226. Parsing establishes shape and binding comparisons, not semantic safety,
37
+ authority, testing, model consumption or improvement.
38
+
39
+ ## Closed V1 record
40
+
41
+ `GuidanceVariantV1` has exactly these fields:
42
+
43
+ - `v`: integer 1.
44
+ - `id`: lowercase 64-hex content key.
45
+ - `projectKey`, `experimentId`: nonempty opaque identities. Project keys use the
46
+ ExecutionReferenceV1 project-key bound; experiment ids use its id bound. There
47
+ is no trimming, Unicode normalization, path interpretation or resolver.
48
+ - `taskId`, `taskCreated`, `flowRevision`: safe integers; id is positive and the
49
+ existing task creation epoch and flow revision are nonnegative.
50
+ - `baseline`: exactly `{roleId, layer, sha256, bytes}`. The layer is `shipped` or
51
+ `project`. `bytes` is the exact admitted UTF-8 role text, represented as a JSON
52
+ string. `sha256` is its lowercase raw UTF-8 digest, including original spacing
53
+ and final newlines. The role id must match the role file's flat header.
54
+ - `candidate`: exactly `{sha256, bytes}` with the same raw snapshot/hash rules,
55
+ parsed for the baseline role id and layer.
56
+ - `author`: the existing local execution-link actor grammar with controls and
57
+ unpaired surrogates rejected before that check, compared verbatim with the host
58
+ context actor. It grants no role or authority.
59
+ - `rationale`: exactly `{problemHypothesis, expectedObservableDifference}`,
60
+ containing nonempty prose-shaped strings.
61
+ - `evidenceRefs`: an ordered list of distinct ExecutionReferenceV1 addresses.
62
+ Each address uses the existing closed producer parser and canonical key.
63
+ References are inert declarations, not proof of existence, source-read
64
+ admission, provenance or a resolver instruction.
65
+
66
+ Reject unknown fields, unsupported versions, accessors, proxies detectable by
67
+ Node's `types.isProxy`, symbol/nonenumerable properties, non-plain objects and
68
+ sparse/accessor/decorated arrays. Normalize only into new own-data objects; never
69
+ invoke a producer getter, iterator or `toJSON`. Successful parses clone and freeze
70
+ all record containers. This protects the admitted value from later caller
71
+ mutation; it does not authenticate a caller or make arbitrary host JavaScript
72
+ immutable.
73
+
74
+ | Bound | V1 meaning |
75
+ | --- | --- |
76
+ | Role file | At most 8192 UTF-8 bytes, using the existing role parser |
77
+ | Complete guidance | At most 2000 JavaScript UTF-16 units, including the existing task-role header; no truncation |
78
+ | Rationale | At most 2000 UTF-8 bytes of the complete canonical rationale object, including keys and JSON escapes |
79
+ | Full record | At most 32768 UTF-8 bytes of normalized record JSON, including id and both snapshots |
80
+ | Evidence refs | At most 16, with no duplicate canonical reference |
81
+ | Experiment variants | At most 16 historical keys, including withdrawn variants |
82
+
83
+ These are contract bounds, not tunable operational settings. Existing catalog
84
+ parse/render behavior remains unchanged. In particular, the role parser's body
85
+ limit and the complete `taskRoleText` limit retain their existing UTF-16 units;
86
+ they are not substituted with UTF-8 byte counts.
87
+
88
+ ## Restricted source difference
89
+
90
+ `parseRoleDocument` first calls the existing `parseRole`. It then retains the raw
91
+ header including delimiters, the body prefix before Scope, and the six ordered
92
+ heading/content slices from the original text. Offsets are explicitly UTF-16
93
+ string offsets, not UTF-8 byte offsets. A section starts at its heading and ends
94
+ immediately before the next heading, including its own newline/blank/trailing
95
+ spacing. Evidence extends to the actual source EOF. The helper does not reuse the
96
+ parser's trimmed body to reconstruct admitted bytes.
97
+
98
+ The candidate must keep the raw metadata header, body prefix and every heading
99
+ line identical. Complete `Not in scope`, `Hub use` and `Review duties` sections
100
+ must be byte-identical. Only the content spans of `Scope`, `Deliverables` and
101
+ `Evidence` may differ. Existing code/tool text in protected baseline sections
102
+ stays unchanged if the original role parser admits it. No canonical reconstruction
103
+ or sanitization is used to excuse a protected-byte change.
104
+
105
+ Editable content and rationale use a conservative prose-shaped grammar:
106
+
107
+ - Lines are blank ASCII-space lines or sentences, optionally prefixed by one
108
+ `- ` bullet. A nonempty sentence starts with a Unicode letter and ends with
109
+ `.`, `!` or `?`.
110
+ - Characters are Unicode letters, marks and numbers, ASCII spaces, and only the
111
+ ASCII punctuation `. , : ; ! ? ' " ( ) / -`. Tabs, carriage returns, controls,
112
+ format characters and unpaired surrogates are excluded.
113
+ - Reject `--`, an identifier directly followed by `(`, hub/channel header syntax,
114
+ fences/backticks, headings, links/HTML, braces/brackets, variable, assignment,
115
+ pipeline and escape syntax.
116
+ - Reject command-shaped leading executable tokens, including the existing role
117
+ parser's command vocabulary plus common Node/package/shell executors; reject
118
+ code-statement prefixes such as import, function, const and await. The source
119
+ validator defines the exact closed vocabulary for V1.
120
+
121
+ This deliberately declines some harmless formatting. It recognizes a lexical
122
+ shape, not the meaning of natural language or every possible custom executable.
123
+ A prose sentence can still be unsafe, false or manipulative. Mandatory host tool,
124
+ permission, privacy, routing and role policy remain authoritative; review and
125
+ later Tasks admission are still required. A model-supplied origin or confidence
126
+ flag cannot elevate this text.
127
+
128
+ ## Content identity and current context
129
+
130
+ Canonical payload order is `v`, `projectKey`, `experimentId`, `taskId`,
131
+ `taskCreated`, `flowRevision`, `baseline`, `candidate`, `author`, `rationale`,
132
+ `evidenceRefs`. Nested objects use the field order shown above; references use the
133
+ existing parser's field order and retain their declared list order. The key is
134
+ SHA-256 of UTF-8 `JSON.stringify(["agent-hub.guidance-variant/v1", payload])`,
135
+ excluding only `id`. Both raw snapshots, actor and rationale are part of the
136
+ identity. Reordered producer properties produce the same key; changed content
137
+ cannot reuse it. A digest is not an attestation.
138
+
139
+ `GuidanceVariantContext` is separate host-owned data with exactly
140
+ `projectKey`, `experimentId`, `taskId`, `taskCreated`, `flowRevision`, `actor`,
141
+ `baseline`, `currentBaseline` and `variantIds`. Its baseline is the experiment's
142
+ frozen admitted snapshot, never a live catalog value silently substituted into
143
+ an old experiment. `currentBaseline` is a separately obtained current
144
+ `roleIdentity`: `{id, layer, hash}`. Record baseline, frozen snapshot and current
145
+ catalog identity must all agree, and the record/frozen raw bytes must agree.
146
+ A current baseline change requires a new experiment binding.
147
+
148
+ The validator compares author to host actor and all supplied project/task/epoch/
149
+ revision/experiment fields exactly. It does not discover the task, authenticate
150
+ an actor, know whether a host snapshot is fresh or recheck policy across awaits.
151
+ T2 must build the context from current authorized owner data and recheck its live
152
+ fences before effects. Producer-supplied context or a matching string is never
153
+ Tasks authority.
154
+
155
+ `variantIds` is the host's full historical key set for that experiment, including
156
+ withdrawn records. A new key at sixteen refuses; an identical existing key can be
157
+ revalidated at the cap. This is a pure cardinality check. T2 still owns storage,
158
+ original-record replay, withdrawal intent, audit history and prevention of later
159
+ probe use. T1 performs none of those effects.
160
+
161
+ ## Pure API and readback ceiling
162
+
163
+ - `parseGuidanceVariantV1(value)` checks closed shape, raw hashes, restricted diff,
164
+ grammar, content id and full size without host context.
165
+ - `validateGuidanceVariantV1(value, context)` adds exact host binding and historical
166
+ cardinality checks. Its actor comparison is not authorization.
167
+ - `guidanceVariantKey(payload)` validates the unsigned closed payload before
168
+ computing its deterministic key.
169
+ - `renderGuidanceVariantV1(value, review)` self-validates and delegates to existing
170
+ `taskRoleText`. Historical rendering is untrusted advisory data, not a claim
171
+ that the experiment is current or that the text may be handed to a model.
172
+
173
+ There is no file read, catalog loader, Board/Tasks construction, memory operation,
174
+ clock, model, subprocess, network, probe or live configuration write in these
175
+ functions. T2/T3 must screen public metadata and enforce source/task privacy before
176
+ exposing ids, counts, rationale or snapshots. A stored historical record cannot
177
+ be activated by parsing or rendering it. Missing/denied source equivalence and
178
+ actual-handoff receipts remain with their owning later boundaries.
179
+
180
+ `test/fixtures/guidance-variant-v1.json` contains independently authored role and
181
+ mutation vectors and one complete wire record/key generated with Python's
182
+ standard-library SHA-256 and compact UTF-8 JSON, without the target validator.
183
+ The companion test also constructs expected keys with Node crypto independently
184
+ of the validator, covers protected-byte differences,
185
+ opaque references, host drift, UTF-8/UTF-16 boundaries, aggregate JSON size and
186
+ inert/frozen containers. These conformance vectors do not claim semantic safety, native consumption or
187
+ measured runtime improvement. The T2 fixtures separately exercise the lifecycle
188
+ and privacy admission described below.
189
+
190
+
191
+ ## Tasks lifecycle and private persistence (T2)
192
+
193
+ Only `Tasks.guidanceVariantCreate`, `guidanceVariantRead` and
194
+ `guidanceVariantWithdraw` admit lifecycle operations. `guidanceVariantApplicable`
195
+ is a fresh read predicate for a later confined probe boundary, not handoff,
196
+ activation or model-consumption evidence. T2 adds no CLI, MCP, console dispatch,
197
+ model route, probe runner, role assignment or effective configuration change.
198
+
199
+ Creation accepts a complete closed V1 record. Its first successful transaction
200
+ freezes the experiment's baseline in `guidance_experiments`; immutable canonical
201
+ variant bytes and their digest live in `guidance_variants`. Both tables are
202
+ private local hub state, separate from `Task`, refs, plan, history, public task
203
+ views, bus notices and memory. The experiment key is the host project key, task
204
+ id, task creation epoch and experiment id. The variant key adds its content id.
205
+ No read interprets an opaque address as a locator, URL or path to resolve.
206
+
207
+ Write authority follows task-role admission: the person or the task's current
208
+ rostered owner with the configured base for its class. An agent cannot write
209
+ under review; every actor is refused on an approved or cancelled task. A
210
+ conductor designation alone grants no write. Creation additionally requires the
211
+ current task role and class-compatible current catalog identity to match the
212
+ record and frozen experiment. A changed baseline requires a new experiment;
213
+ neither a retry nor a catalog reload silently rebases an existing one.
214
+
215
+ Task epoch, flow revision, owner, state, task role, catalog identity, repository,
216
+ current task privacy and authenticated request/session authority are checked
217
+ before reads and again after configured local privacy screening, immediately before
218
+ the synchronous transaction. Known input/admission refusals are pre-effect only;
219
+ unknown storage, wrapped write or readback failures remain ordinary fixed safe
220
+ errors, including a transaction that rolled back. They never authorize an
221
+ adapter to assume safe automatic retry. Existing configured local privacy screening may
222
+ inspect new proposal text; unknown or failed screening refuses. There is no new
223
+ generation or model route. A present-but-unknown native session-generation port
224
+ refuses. The request also fences replacement peer objects, native session and
225
+ current delivered-input identity. These are current-operation fences, not
226
+ persisted session attestations or permanent authority on the immutable record.
227
+ The future probe boundary must capture and revalidate its own runtime/turn facts.
228
+
229
+ Private turns, review-observer input and PII task state refuse all actors before
230
+ experiment identifiers, counts or bodies are read. Reads use the existing task
231
+ visibility boundary, including its staged-task restriction. Missing, denied,
232
+ corrupt and unsupported ordinary reads share `{state: "unavailable"}`. Public
233
+ task views never gain snapshot fields.
234
+
235
+ The lifecycle read result is a closed metadata projection, not the private stored
236
+ record. It contains experiment/variant identity, task epoch/revision, author,
237
+ role id/layer, baseline/candidate SHA-256, changed editable section names,
238
+ baseline/candidate/record byte counts, declaration/withdrawal status, current
239
+ applicability, and canonical evidence digests with declaration availability.
240
+ Neither raw role snapshot, attribution header, body, evidence address nor private
241
+ creation/withdrawal actor/time metadata is returned. An unrelated deny policy
242
+ cannot make a valid shipped role disappear because its protected attribution
243
+ contains a path.
244
+
245
+ Only the two rationale texts and caller-opaque experiment id are field-screened
246
+ on this read path, using existing pure
247
+ nameable/secret/lexical policy behavior. A field that does not clear is the
248
+ literal `withheld`; it does not hide the variant or change applicability. Under
249
+ active path policy, path-shaped rationale without alias proof is withheld as a
250
+ field. Reads do not invoke `publicMetadataText`'s filesystem discovery, a model or
251
+ an address resolver to manufacture that proof. Other closed enum/id/hash metadata does not pass
252
+ through the opaque-address/path heuristic. The experiment id remains its exact
253
+ immutable private identity, not a hash or a renamed key. Its public field is the
254
+ raw id when clear and literal `withheld` otherwise; this does not hide the
255
+ variant or change applicability. The same field projection applies to creation
256
+ and withdrawal receipt echoes, so narrowing privacy never sends an old private
257
+ id back merely because a write succeeded. Raw snapshots remain private local
258
+ state and never become public merely because a field is withheld.
259
+
260
+ Admission precedes duplicate lookup. An unchanged duplicate returns the original
261
+ record and original attribution without writing only while current create
262
+ admission still holds. A stale original create refuses; authorized historical
263
+ readback is separate and can return `applicable: false`. Concurrent identical
264
+ creates converge on one row. Sixteen historical variant ids include withdrawn
265
+ ones; there is no experiment-count cap. No task-list scan is introduced in T2;
266
+ T3 owns bounded experiment-list pagination.
267
+
268
+ Withdrawal accepts a current task epoch/flow wrapper and an exact stored
269
+ experiment/variant id. It records one terminal withdrawal actor/time without
270
+ changing the payload or deleting history. Historical baseline drift does not
271
+ prevent this narrowing operation. An unchanged repeat preserves the first
272
+ withdrawal. Creation replay never clears it, and it always makes the variant
273
+ inapplicable. Closed tasks remain immutable. Withdrawal introduces no free text
274
+ and has no awaited screen between its final authority checks and atomic write.
275
+ It does not re-screen stored raw prose or a newly withheld rationale: it narrows
276
+ intent and returns only the closed receipt. Current task/turn privacy and exact
277
+ scope/revision/authority checks still apply.
278
+
279
+ The immutable declaration and host creation/withdrawal metadata remain in the
280
+ private store; public metadata applicability is evaluated separately against
281
+ current task/catalog context. After source-port reads, the task revision/role
282
+ binding, selected immutable and withdrawal metadata, and task privacy are read
283
+ again. A changed snapshot is unavailable. Current applicability and rationale
284
+ field projection are recomputed only after those fences.
285
+
286
+ Source references are declarations only. Their public keys are the existing
287
+ `executionReferenceDigest`, SHA-256 of the canonical reference, never
288
+ `executionReferenceKey`'s raw canonical JSON or an opaque producer address. An
289
+ exact currently visible local source can be labelled `declared`; missing,
290
+ denied, external and unsupported sources are all `unavailable`. Neither label
291
+ asserts testing, runner provenance, actual handoff, model attention, result
292
+ quality or improvement. Read and applicability paths invoke no model, network
293
+ or external resolver.
294
+
295
+ ## Storage and controlled recovery bounds
296
+
297
+ Each normal read uses one indexed experiment key and at most seventeen variant
298
+ rows. The seventeenth is an overflow sentinel: it refuses corrupt storage rather
299
+ than returning a truncated complete experiment. SQL checks raw JSON byte lengths
300
+ before hydration, then validates canonical payload hashes, experiment bindings,
301
+ host attribution and paired withdrawal fields. First experiment plus variant,
302
+ and a withdrawal plus its status revision, commit atomically; refusals and
303
+ replays change no row, task history or status revision. Restart retains exact
304
+ immutable and terminal metadata.
305
+
306
+ The additive tables do not advance the database schema marker. Retained rows
307
+ require the `guidance_variants` recovery feature. A conditional digest covers
308
+ both tables, including withdrawn history; absent tables' data leave legacy
309
+ empty-state recovery integrity unchanged. Startup verifies canonical retained
310
+ state and a supplied recovery digest before accepting it as current. An unknown
311
+ compatibility or integrity read refuses instead of certifying an empty store.
312
+
313
+ Recovery alone streams ordered experiment keys, followed by each exact-key
314
+ variant page of at most seventeen rows, with bounded per-row/page memory. Its
315
+ total work is O(historical experiments), including the corresponding bounded
316
+ variant pages and orphan detection. This follows the existing full-stream
317
+ integrity convention. If measured recovery time warrants a change, the upgrade
318
+ is keyset pages with a verification budget; a partial scan must never certify
319
+ complete integrity. T2 adds no experiment-count cap, new recovery budget or
320
+ partial-scan success/refusal mode.
321
+
322
+ `test/guidance-variants-lifecycle.test.ts`,
323
+ `test/guidance-variants-privacy.test.ts` and
324
+ `test/guidance-variants-recovery.test.ts` use only scratch state and fake peers.
325
+ Their source assertions cover idempotent creation, atomic rollback, restart,
326
+ withdrawal, currentness/privacy narrowing, malformed stored rows, bounded SQL
327
+ hydration and conditional recovery metadata. These are fixture contracts, not a
328
+ native/live trial or a measured read-cost receipt; T3 and #1226 retain those
329
+ separate obligations.
330
+
331
+
332
+ ## Public surfaces and editable-section diff (T3)
333
+
334
+ The four operations are `guidance create`, `list`, `show` and `withdraw`, and
335
+ `hub_guidance_create`, `hub_guidance_list`, `hub_guidance_show` and
336
+ `hub_guidance_withdraw` on CLI/MCP. The producer console is read-only in T3:
337
+ it agrees on list/show metadata and section diff, and directs mutations to the
338
+ CLI/MCP. All surfaces use the same Tasks admission and closed public reply
339
+ parsers. Creation takes a complete V1 record; the CLI reads an explicitly named
340
+ JSON file of at most 32768 UTF-8 bytes. No surface reconstructs private baseline
341
+ bytes from readback, rewrites an author or grants a proposal trust. Proposal
342
+ generation, activation and actual handoff remain outside this surface.
343
+
344
+ `guidance_views` advertises these operations separately from T2's retained-state
345
+ `guidance_variants` feature. An older daemon or plugin keeps its old behavior;
346
+ new callers refuse unsupported operations with upgrade/restart guidance. Every
347
+ control request with a rid receives a reply. There is no protocol-version or
348
+ schema-marker bump. Old task, role, private snapshot and T2 API records retain
349
+ their existing meaning.
350
+
351
+ ### Selection and current binding
352
+
353
+ Public selection is `{taskId, taskCreated, id}`, using the existing variant
354
+ content id. Public experiment-id text is a label, never a selector: `withheld`
355
+ never becomes an experiment key. After current task/actor/privacy admission,
356
+ an additive task-scope/id index supports one exact lookup with LIMIT 2. Two
357
+ matches are ambiguous and refuse; raw experiment identity is resolved only
358
+ inside Tasks/Board. No new hashed experiment identity, unbounded scan or caller
359
+ actor/authority flag is introduced. Existing explicit experiment selectors
360
+ remain supported by the T2 library API.
361
+
362
+ List/show replies carry `current: {taskId, taskCreated, flowRevision}` separately
363
+ from the record's historical `flowRevision`. Withdrawal requires the current
364
+ wrapper revision, not the old proposal revision. A historical proposal remains
365
+ readable without becoming current or resurrecting a withdrawal. The server
366
+ rechecks this binding and current actor/session/privacy at effects and after
367
+ source-port reads. A displayed label or cursor grants no authority.
368
+
369
+ ### List wire bounds
370
+
371
+ A page contains at most 32 public metadata records and at most 262144 UTF-8 bytes
372
+ of its complete guidance-page JSON payload. Transport wrappers and the shared
373
+ human rendering remain separate surface framing. SQL uses the task-scope/id index, `id > after` and
374
+ LIMIT 33. The extra row is an overflow sentinel, not a truncated complete page;
375
+ raw stored JSON is byte-bounded before hydration. Duplicate variant ids within
376
+ the task scope refuse as ambiguous rather than being lost at a page boundary.
377
+ There is no experiment-count cap, OFFSET scan or whole guidance-history hydration.
378
+ Existing owning-task visibility and source-evidence context reads remain in use.
379
+
380
+ The optional cursor is at most 512 ASCII bytes. Its closed payload carries a
381
+ version, last public variant content id and HMAC signature. The signature binds
382
+ the host project namespace, authenticated actor, task epoch, current flow and
383
+ last id using the existing host-only cursor key. Raw experiment ids and global
384
+ row ids never enter the token. A changed scope, task flow or signing generation
385
+ requires refresh without the cursor. Pages are bounded current reads, not a
386
+ frozen snapshot across concurrent additions; refresh to include newly inserted
387
+ earlier ids. Privacy is applied before any identifier or count is exposed.
388
+
389
+ ### Separate section-diff reply
390
+
391
+ `Tasks.guidanceVariantDiff` returns one public metadata record, its current
392
+ binding, and the three editable section names with baseline/candidate text
393
+ fields. It does not widen the T2 metadata-only read or list projection.
394
+ Only Scope, Deliverables and Evidence bodies may cross this boundary. Each
395
+ whole field first passes current pure nameable/secret/lexical policy, then
396
+ `sanitize()`. A refusing, unknown or oversized field is literal `withheld`;
397
+ it does not hide safe metadata or change applicability. There is no per-line
398
+ screen, partial truncation, model screen or filesystem/address resolution.
399
+ Each section field remains within the existing 8192-byte role ceiling.
400
+
401
+ The same raw-first field guard also covers inherited T2 reads and create/withdraw
402
+ receipt labels: nameable and secret checks examine the original string before
403
+ JSON escaping, then the existing pure lexical policy runs. A pattern spanning
404
+ an actual newline therefore withholds the whole field instead of disappearing
405
+ behind JSON escape characters. Safe metadata and applicability remain available.
406
+
407
+ The protected section names Not in scope, Hub use and Review duties are shown
408
+ as unchanged by T1 construction, with no body. Raw headers, attribution,
409
+ body prefix, protected bodies, full snapshots and opaque evidence addresses
410
+ never enter a public reply. Rendered diff text is untrusted advisory presentation,
411
+ not exact private bytes for a new record or proof of testing/model consumption.
412
+
413
+ ### Surface authority and side effects
414
+
415
+ CLI create/withdraw keep the authenticated peer and refuse delegated
416
+ `--live-test` person promotion. MCP schemas are publication only; Tasks parses
417
+ closed input again. Private/review input, current task PII, read-only mutations,
418
+ recovery and shutdown cannot be bypassed by a peer field or an old connection.
419
+ All four guidance tools exclude arguments and results from capture and do not
420
+ count as owner task progress. Reads start no probe, model, delivery or memory
421
+ write. An unknown write or malformed receipt is unconfirmed, never permission
422
+ for automatic retry.
423
+
424
+ The producer console has its own Guidance panel and dedicated pinned-project
425
+ manager port, separate from the dashboard action whitelist and candidate inbox.
426
+ Its dedicated manager port permits list/show only. No console mutation,
427
+ confirmation, person-metadata adaptation or snapshot token is introduced;
428
+ existing question/person/receipt helpers remain unchanged. A future console
429
+ withdrawal requires its own contract. Fixed CLI instructions do not execute
430
+ anything. Existing dashboard panels and their behavior stay available. The
431
+ panel renders the provider's shared lines as text, not HTML, and late responses
432
+ cannot replace a newly selected project/task view.
433
+
434
+ Source fixtures compare all three ports, field withholding, immutable legacy
435
+ records, SQL/keyset/reply bounds, source callbacks, actor/session/private guards,
436
+ old-feature refusal and capture/progress exclusion. The dogfood row records
437
+ actual source-only variant size/read cost after measurement; native/account
438
+ coverage and actual confined handoff remain separately unverified.