@fractalsynapse/dsh-chapters 0.2.38 → 0.2.40

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.
@@ -567,7 +567,9 @@ not inherit it: `create_goal` requires a direct-human turn, and the child's firs
567
567
  `plugin:dsh-chapters`. Before this, the objective stopped driving the work exactly where the plugin's own
568
568
  promise begins, and AGENTS' rule to "carry the authorized outcome" was left to the model's prose.
569
569
 
570
- **The rule now: carry the goal as text, and state aloud that it is not armed.** One selector
570
+ **The rule now (maintainer decision 2026-11-19 applied): carry the goal as text, AND re-arm a live goal
571
+ at birth through the goal SERVICE — explicitly, documented, and configurable** (`goalRearmOnCarry`, default
572
+ on; off restores the notice-only wording). One selector
571
573
  (`foldGoalFromLog`) folds the parent's durable `goal/change` events — operations `create`, `edit`, `pause`,
572
574
  `resume`, `block`, `complete`, `clear`, with `{id, revision, objective, phase, maxGoalRounds, blockedReason}`
573
575
  — and one renderer (`renderGoalCarriage`) emits the child's `## Goal (carried from the parent session)`
@@ -590,13 +592,18 @@ Invariants this respects:
590
592
  - **`phase` is foldable; `activation` is not.** The host keeps armed/disarmed process-local and the plugin
591
593
  reads it from the live service for its own driver decisions, so the notice says who CAN change the driver
592
594
  and never claims what the driver currently IS. Recovering armedness from history would be a guess in a
593
- record's clothing.
594
-
595
- **Deliberately not done, pending a maintainer decision (#349):** the underlying goal *service* has no
596
- direct-human gate, so the plugin could arm a goal on the child unilaterally. Reaching a seam is not having
597
- authority to use it; silently routing around a gate because the tool wrapper is the only thing enforcing it
598
- is the kind of unexamined authority widening this whole release was a study in. If the answer is yes, it
599
- becomes an explicit, documented, configurable step — not a side effect of the birth path.
595
+ record's clothing. THE RE-ARM RESPECTS THIS: the birth step creates a fresh goal (armed by the service's
596
+ own semantics, revision restarts, round counts start on the child) — it never CLAIMS the parent's
597
+ activation, and the notice wording is true whether the step succeeds or is refused.
598
+
599
+ **The decision, recorded (maintainer, 2026-11-19):** the earlier paragraph reserved plugin-authored goal
600
+ creation as a maintainer call; the call is YES, scoped as this section now states — the ONE predicate
601
+ (`goalRearmDecision`) arms exactly ACTIVE, unfinished goals (a paused/blocked goal stays notice-only:
602
+ the human stopped it; a completed/cleared one stays closed), the service is called on the child's live
603
+ handle AFTER a successful birth, and every failure mode is loud: no goals service or a refused create
604
+ lands in the door's warning channel naming `/goal resume` as the human fallback — never a silence, never
605
+ a rollback of the birth. Reaching a seam was not authority to use it; this paragraph is the authority,
606
+ written before the code that cites it.
600
607
 
601
608
  ## Storage
602
609
 
@@ -772,6 +779,14 @@ warned "N event(s) rendered no output", `planSummarize` counted the oversize cha
772
779
  catch built a full diagnostic — and then the value was discarded. So the rule is not "add checks", it is
773
780
  **deliver what the checks already say**:
774
781
 
782
+ - **Client visibility follows the command plane (#372).** The two door buttons are realm-scoped
783
+ affordances, so the client renders them ONLY when the host's own per-session projection
784
+ (`SessionSummary.projectionValues.agentPreset` — the fact the host's preset label reads, measured
785
+ in `dsh-client-ui-agent-preset` client bytes) says the session composes `chapters`. An unreadable
786
+ projection keeps the buttons and the click answers with the preset-specific refusal — fail-open
787
+ visibly, never silently dead. One id source: `CHAPTERS_PRESET_ID` lives in `src/preset-id.ts`
788
+ (client-safe, cordis-free); `src/preset.ts` re-exports it, and the client predicate is
789
+ `doorActionsVisibleFor` — one predicate per decision, per the hard rules.
775
790
  - **The diagnostics sink defaults ON.** `DSH_CHAPTERS_ENGINE_ERRORS` unset now means
776
791
  `<store-root>/diagnostics.log`, not "nowhere". All three SAIP compaction finalization failures left
777
792
  zero trace on disk, and door 5 logged `saved` to a logger nobody reads for three days. The env var
package/docs/contract.md CHANGED
@@ -367,6 +367,28 @@ documentation-first step: the code change shipped with tests and no contract, an
367
367
  behaviour was described was the install page's sample output — a sample that, at the time, was itself the
368
368
  symptom. Recorded here so the omission is closed rather than inherited, and noted in #355's process findings.
369
369
 
370
+ ## Goal budgets without the model — the seam, and the two things it does NOT include (#138, measured against the pinned host bytes 2026-11-19)
371
+
372
+ The question #138 asked is how a deterministic journey can bound goal rounds when a round is itself
373
+ a turn and every turn ends (so the count at any click moment is machine latency). The measured answer:
374
+
375
+ - **The seam exists, service-level**: `dsh-goal`'s `create(agent, { objective, maxGoalRounds })`
376
+ carries the budget directly — no model involved. Our plugin uses it at birth (`#349` re-arm:
377
+ `goalRearmDecision` → `ctx.get('goals').create(agent, { objective, maxGoalRounds })`; the live
378
+ witness is the continuation child whose durable `goal/change` row carries `cap 256`, and the
379
+ deterministic witness is the tools row pinning the cap on the captured call).
380
+ - **The `/goal` COMMAND does not have it**: `dsh-command-goal` calls `ctx.goals.create(invocation.agent,
381
+ { objective })` — full stop (`lib/index.js:131,138`). A rounds argument on the slash command is a
382
+ host-side feature; recording it here is the whole of what our side can ship.
383
+ - **`maxGoalRounds: 1` via a config pin is not a bound, it is a disappearance**: exhaustion puts the
384
+ phase at `blocked`, and the host GoalBar renders NOTHING for blocked/complete
385
+ (`GoalBar.tsx:85-86`) — the armed-but-resting state #138's title names does not exist host-side.
386
+ Budget 2 is the smallest count that can be *observed* at all (one round executes, the strip still
387
+ shows phase `active` between rounds), and "between" is where the race lives, so no tape may depend
388
+ on it — which is why every goal claim in this repo runs live-only under a wall-clock bound
389
+ (`prompt-goal-live`), never against a tape. The acceptance that "an armed goal has no rest state"
390
+ stands as a host-side gap, recorded, not ours to fix.
391
+
370
392
  ## Lineage: Kernel Fields We Must Not Lean On
371
393
 
372
394
  `SessionHeader` (`packages/core/session/src/types.ts:93-122`) carries `version`, `id`, `createdAt`,
@@ -374,9 +396,16 @@ symptom. Recorded here so the omission is closed rather than inherited, and note
374
396
  schemas**.
375
397
 
376
398
  - `isSeeded` means "contains a fork-inherited event prefix"; our one-event synthetic seed is not that.
377
- - `parentSession` is documented as *seed lineage*. Setting it to fake a relationship would be a misuse.
378
- - Therefore **our storage-domain registry is the sole authority on ancestry**, and the web UI's branch
379
- graph will show our child as an unrelated root. A chain/manifest view is this plugin's job.
399
+ - `parentSession` is documented upstream as *seed lineage*. **DSH amendment (maintainer decision
400
+ 2026-11-19, #397): our birth seam sets it to the TRUE parent on every child it creates** —
401
+ `chapters_continue`/`chapters_fork` name the caller session; `chapters-restore` names the TARGET it
402
+ was born from. The relationship is real, so naming it in the kernel header is durable lineage the
403
+ child can read without our registry. The prohibition stands for every other writer: never claim a
404
+ parent that did not birth you.
405
+ - The storage-domain registry REMAINS the ancestry authority for children born before the amendment
406
+ (they carry no header field), and the seventh archive moment reads header-first with registry
407
+ fallback (`shouldForceChildArchive`). A header-parented child may appear differently in the web
408
+ UI's branch graph (host-scope, unmeasured here); the chain/manifest view stays this plugin's job.
380
409
  - The header being composed per request from the preset plus plugin contributions is *why* invariant 3
381
410
  holds, and why cache validity is per-process-generation: a restart or config edit recomposes it for
382
411
  everyone.
@@ -575,7 +604,7 @@ Rows are renamed and dropped between host versions, so re-anchor `src/preset.ts`
575
604
  host's own `@deepseek-ai/dsh-web-app/presets/standard.patch.yml` after an upgrade. Measured drift across
576
605
  the five published versions (rc.1, rc.2, alpha.1, alpha.2, alpha.4): alpha.1 ADDS `dsh-time-context` +
577
606
  `dsh-tool-schedule` + `toolFilter.deny[schedule_*]`; alpha.2 DROPS the persona `suffix` (with its
578
- `{{cwd}}`), `backgroundMode`, and the codex/claude-code/ralph rows; alpha.4 rewrites the plan-mode
607
+ `{{cwd}}`), `backgroundMode`, and the other subagent-provider rows (named in `cordis.patch.yml`, which stays the source of truth for what the host actually ships); alpha.4 rewrites the plan-mode
579
608
  sentence, drops `toolFilter`, adds `dsh-plugin-market`. rc.1 and rc.2 are byte-identical.
580
609
  `tests/unit/preset-declaration.test.ts` is what turns the next rename into a red row instead of a broken
581
610
  user session — and it pins that `dsh.bundle.patch` is still a string.
@@ -1100,3 +1100,26 @@ artifact never contained the booted home's session logs. `scripts/chain-replay.s
1100
1100
  `session.v4.jsonl.zstd` files and registry into `var/e2e-session-logs/<leg>-<port>` (six files, under 4 MB each) so
1101
1101
  the runner's own history sits next to the tape diffs and the misses. When a miss claims "the conversation had
1102
1102
  already taken a different shape", the answer is in that transcript — read it, don't theorize about it.
1103
+
1104
+ ### The rig-band ephemeral collision (CORRECTED same day — the teardown theory was WRONG)
1105
+
1106
+ `plans` (0.2.37 cut), `enrich` (0.2.38 cut), `fanout` twice (0.2.39 cut): `listen EADDRINUSE` on the
1107
+ leg's own port, boot dying at the 120s readiness ceiling, different leg each time. The first theory
1108
+ here (and in two ship records) said "previous host child outlives its wrapper" — a bind test disproved
1109
+ it on the spot: **`bind(41736)` refused while `ss -tln` and `/proc/net/tcp` showed NO LISTENER** —
1110
+ `lsof` named the holder: an ESTABLISHED outbound socket of the developer's own tooling using the rig
1111
+ port as its EPHEMERAL SOURCE. The machine's `ip_local_port_range` (32768-60999) swallows the entire
1112
+ rig band (41731-41746), so ANY local connection can squat any leg port at any time — which is also why
1113
+ the rerun-gave-green pattern: ephemeral allocation is luck, not drift. Wrong-theory trail kept
1114
+ deliberately: the first guard shipped minutes ago polled CONNECT-REFUSED, the wrong predicate
1115
+ (free-to-connect ≠ free-to-bind); it now asks for a real `listen()` per leg port, holds up to 90s,
1116
+ and fails the leg by name rather than booting into a refusal the ceiling will call a mystery.
1117
+
1118
+ **The real fix, for the maintainer's machine (needs root or a re-distill, so it is recorded not
1119
+ done here):** either reserve the band for the rig — `sysctl net.ipv4.ip_local_reserved_ports=41731-41746`
1120
+ (zero bytes moved, zero tapes touched) — or relocate the band entirely (needs a FULL corpus
1121
+ re-distill, because every tape's regime, homes and header paths are port-keyed; NOT free, not
1122
+ tonight). Until one lands, the honest release sentence stays: first-attempt collisions are named,
1123
+ the recorded rerun is green, and the guard now measures the right thing. The wrong-teardown theory
1124
+ in the 0.2.37/0.2.38 ship records stands corrected here rather than silently rewritten — immutable
1125
+ tags, mutable understanding, one line in the right place.
@@ -1169,3 +1169,84 @@ locally (every leg under its own boot, compose included), then `npm run corpus:s
1169
1169
  debt · #349 remainder (browser rig) · #372 (unbuilt) · #397 (contract.md § Lineage decision) ·
1170
1170
  #411 residual (record-time regeneration pattern) · host option-(d) todo row · five
1171
1171
  credential-gated TreeDX live rows.
1172
+
1173
+
1174
+ **fd7e7e6..69729f7 SHIPPED — 0.2.38, published and registry-proven.** PR #424 merged to main at
1175
+ `69729f7`, all four CI jobs green at the head (coverage gate, preset-rows probe, env parity, and the
1176
+ acceptance chain now replaying compose on the runner); annotated tag `0.2.38` at the merge commit;
1177
+ release run `44479863717` success. Registry proof: `latest` = **0.2.38**; unpacked tarball answers
1178
+ manifest `0.2.38` AND bundled `PLUGIN_VERSION = '0.2.38'`; provenance attestation present
1179
+ (`slsa.dev/provenance/v1`). Candidate evidence per the record above: twelve-leg replay chain green
1180
+ locally at the release head (the one `enrich` boot that died on `EADDRINUSE :41734` was the transient
1181
+ teardown race, port verified free, rerun fully green), stamp `lib=a2d63947fa0e8da7` moved only on the
1182
+ version literal with `promptAnchor` unchanged — and the stamp's own first commit message got amended
1183
+ before merge for saying "lib unchanged" when the honest reading is "lib changed ONLY by the version
1184
+ string": the amend is disclosed here because the bytes that moved are exactly what the release
1185
+ verifies.
1186
+
1187
+ C3 is retired. The oldest open verification debt in this file's history became a replay leg.
1188
+
1189
+ ## 2026-11-19 — 0.2.39: the release that carried the objective across
1190
+
1191
+ **Candidate = staging at `70fb605`.** The range `0.2.38..staging` is one arc in three issues: **#397**
1192
+ (durable birth lineage in the kernel header, contract amended first — merged `PR #425`), **#372**
1193
+ (the dock reads the host's preset projection; resolved-foreign hides the realm-scoped buttons, unknown
1194
+ refuses by name — merged `PR #426` after a six-run browser-measurement chain, one wrong premise killed
1195
+ per run), **#349** (the maintainer authority decision implemented: ACTIVE carried goals re-arm at birth
1196
+ through the goal service, one predicate, warning-never-refusal, `goalRearmOnCarry`; five-run live chain
1197
+ including two stale-lib lessons and the cordis inject-gate discovery — merged `PR #427`). C3's
1198
+ successor facts are now regression corpus: the compose leg replays the composed path model-free (0.2.38)
1199
+ and the goal/lineage claims carry live-host witnesses in their legs.
1200
+
1201
+ **Open-list corrections this cut makes:** #411 was already closed at 0.2.36 (its 'residual' line here
1202
+ was stale prose); #349, #372, #397, C3 all now closed/retired. Open after this cut: #349's sibling from
1203
+ #138 (an armed goal has no rest state — unchanged) · #372's host-side sibling: the gateway session-list
1204
+ shape warning (`attach:gatewayList`, pre-existing, non-fatal, observed while measuring) is NOT yet
1205
+ filed — it is recorded here so the next audit does not re-derive it · #349 remainder: none ·
1206
+ #397 remainder: none · host option-(d) todo row · five credential-gated TreeDX live rows.
1207
+
1208
+ **Ship gate at the candidate before stamp:** full unit+integration ledger baseline shape
1209
+ (1,696/1,702 — 5 credential-gated `live:` + 1 todo); typecheck clean; ratchet 58=58; the TWELVE-leg
1210
+ replay chain run locally green at this head; `corpus:stamp` on green with `promptAnchor` unchanged.
1211
+
1212
+
1213
+ **70fb605..290b4ae SHIPPED — 0.2.39, published and registry-proven, with the chain-runner saga fully
1214
+ disclosed.** PR #428 merged at `290b4ae`; all four CI gates green at the head (acceptance after ONE
1215
+ failure + one re-run — the disclosure trail: attempt #1 was MY port-guard's inverted polarity, twelve
1216
+ false 'STILL HELD' lines on a runner nothing held, caught by CI and fixed with the contract written in
1217
+ the script and its truth table run against both real cases; attempt #2 failed only the pre-existing
1218
+ `prompt-revival` mount-pull race, observed at the same rate on BOTH machines, sampled 2-pass/2-fail,
1219
+ filed as **#429** with the #372-boot-ordering correlation candidate named to rule out first; attempt
1220
+ #3: 13/13 green). Annotated tag `0.2.39` at the merge commit; release run `44557329033` success.
1221
+ Registry proof: `latest` = 0.2.39; tarball manifest `0.2.39` AND bundled `PLUGIN_VERSION = '0.2.39'`;
1222
+ `slsa.dev/provenance/v1` attestation present. Local chain at the candidate: 11/12 green, `fanout`
1223
+ boot-REFUSED locally by the machine-level ephemeral squat (bind-refused, no listener, `lsof` names the
1224
+ session tooling's own socket; proven, documented, machine-fix recorded in docs/development.md:
1225
+ `ip_local_reserved_ports` or a re-distilled band — NOT silently worked around). Stamp
1226
+ `lib=c011dbe6d5e2c2d5`, `promptAnchor b40304ee3e35a94f` unchanged — six releases.
1227
+
1228
+ **Open after 0.2.39:** #429 (mount-pull race, two-machine samples) · the rig-band reservation
1229
+ (maintainer's sysctl, needs root) · #138 goal rest-state · gatewayList shape (observed, recorded) ·
1230
+ host option-(d) · five credential-gated TreeDX live rows. **Closed by this cut:** #397, #372, #349
1231
+ (each's issue carries its evidence trail), and the stale #411 line retired from this file's open-list.
1232
+
1233
+ ## 2026-11-19 — 0.2.40: prose promises, measured seams
1234
+
1235
+ **Candidate = staging at `a092c5a`.** Range `0.2.39..staging`: **#138** (contract § Goal budgets —
1236
+ the no-model service seam recorded with file:line witnesses, the /goal argument named as a host gap,
1237
+ budget-1 disappearance explained, our boundary pinned) and **#429** (the first-pull retry finally as
1238
+ code: ONE predicate, 8x2s bounded, loud ceiling, wiring pin; post-fix 10/10 leg + full twelve-leg
1239
+ chain green locally and CI acceptance green on runner hardware — the loaded contexts that produced
1240
+ the flakes now produce the passes). Both issues closed at their merges.
1241
+
1242
+ **Ship gate at the candidate before stamp:** ledger baseline shape; build + symbol check before any
1243
+ boot (the #421 law, applied); the TWELVE-leg replay chain locally green at this head (the first
1244
+ attempt of the verification chain died on MY shell PATH — node 22 without strip-types — and the
1245
+ runner's fail-loud refusal at 'could not read the project list' is the designed behavior; the
1246
+ v24.22.0 rerun is the counted evidence, disclosed not deleted). `corpus:stamp` on green;
1247
+ `promptAnchor` must read unchanged.
1248
+
1249
+ **Open after this cut:** the rig-band sysctl (one line for the maintainer's hand, docs/development.md)
1250
+ · gatewayList shape (observed, recorded) · host option-(d) todo row · five credential-gated TreeDX
1251
+ live rows. #138's rest-state half is now a CONTRACT fact, not an open question; #429 is closed with
1252
+ its fix measured in both failure contexts.
package/lib/client.js CHANGED
@@ -231,6 +231,20 @@ window.__ModuleLoader__.load({
231
231
  const n = streak === void 0 || streak < 1 ? 0 : Math.min(streak, 3);
232
232
  return n === 0 ? ACTIVE_POLL_MS : n === 1 ? 2e4 : n === 2 ? 4e4 : 6e4;
233
233
  }
234
+ const FIRST_PULL_RETRY_SPACING_MS = 2e3;
235
+ /**
236
+ * THE ONE first-pull retry predicate (#429). The dock's mount pull no-ops silently while the host
237
+ * has not yet handed `exec` — before #429 the retry lived only in two comments (the ceiling promise
238
+ * above execWithTimeout, and 'retry until SOMETHING answers' in the mount effect) with no code
239
+ * behind it, which is how the revival leg's mount pull could starve under boot load while solo
240
+ * boots passed 10/10. The loop is due ONLY while no reply has arrived — any parseable answer, an
241
+ * honest `off` included (#304's seam claim is THAT the wire answered, never that the feature is
242
+ * on), the feature plane is present, and the ceiling has room.
243
+ */
244
+ function firstPullRetryDue(c) {
245
+ if (c.answered || c.featureAbsent) return false;
246
+ return c.attempts < 8;
247
+ }
234
248
  function pollSpacingFor(s) {
235
249
  if (s.turnEndPulse === true) return ACTIVE_POLL_MS;
236
250
  if (s.edges) {
@@ -839,8 +853,30 @@ window.__ModuleLoader__.load({
839
853
  if (typeof document !== "undefined" && !document.hidden && duePull()) kick.current?.();
840
854
  };
841
855
  if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVisible);
842
- tick({ mount: true });
856
+ let firstPullRetries = 0;
857
+ let firstPullTimer = void 0;
858
+ const retryFirstPull = () => {
859
+ if (!firstPullRetryDue({
860
+ answered: answered.current,
861
+ featureAbsent,
862
+ attempts: firstPullRetries
863
+ })) {
864
+ if (!answered.current && !featureAbsent && firstPullRetries >= 8) console.warn(`[client:prompt] first-pull retry ceiling (${String(8)} x ${String(FIRST_PULL_RETRY_SPACING_MS)}ms) reached with NO wire answer — the mount pull remains owed; edges are the recovery path (#429)`);
865
+ return;
866
+ }
867
+ firstPullRetries += 1;
868
+ firstPullTimer = setTimeout(() => {
869
+ firstPullTimer = void 0;
870
+ refresh().then(() => {
871
+ retryFirstPull();
872
+ });
873
+ }, FIRST_PULL_RETRY_SPACING_MS);
874
+ };
875
+ tick({ mount: true }).then(() => {
876
+ retryFirstPull();
877
+ });
843
878
  return () => {
879
+ if (firstPullTimer !== void 0) clearTimeout(firstPullTimer);
844
880
  if (timer !== void 0) clearTimeout(timer);
845
881
  if (edgeTimer.current !== void 0) {
846
882
  clearTimeout(edgeTimer.current);
@@ -1046,6 +1082,54 @@ window.__ModuleLoader__.load({
1046
1082
  }))));
1047
1083
  }
1048
1084
  // src/client/doors.ts
1085
+ /**
1086
+ * The client door runner: the two deterministic archive doors, executed over
1087
+ * `remote.commands` and followed by a SWITCH to the fresh child.
1088
+ *
1089
+ * ONE runner, two rows. The server side keeps the same discipline — both doors
1090
+ * come from `deterministicCommand(door)` in src/tools.ts, and a unit row pins
1091
+ * that they archive identically. Copy-pasting this body is how the two would
1092
+ * drift apart, so there is exactly one implementation and a table of rows.
1093
+ *
1094
+ * `chapters-continue` ships only as a composer command; without a button here
1095
+ * the child is created correctly and the UI shows nothing, which reads as
1096
+ * "nothing happened". The row is the missing affordance, not new logic.
1097
+ *
1098
+ * React-free on purpose: the primitives package pulls CSS modules the node
1099
+ * test runner cannot load, so the testable half lives here and index.ts is the
1100
+ * thin chrome that renders these rows as buttons (tests/unit/client-doors.test.ts).
1101
+ *
1102
+ * @module dsh-chapters/src/client/doors
1103
+ */
1104
+ /** Structural slice of the aggregated remote service (@deepseek-ai/dsh-api-remotes).
1105
+ * `remote.commands` must ALSO appear in inject — the federation gates each
1106
+ * sub-service individually (the live feedback package declares
1107
+ * remote.messageFeedback beside remote for exactly this reason). */
1108
+ /**
1109
+ * #372 — the host's OWN per-session preset fact. The shape is measured, not invented:
1110
+ * `dsh-client-ui-agent-preset/lib/client.js` resolves its label through
1111
+ * `session?.projectionValues?.agentPreset`, and `dsh-api-session-controller` documents the field as
1112
+ * "current host-computed projection values retained by the object layer". We read the SAME row the
1113
+ * list store already gives us (rosterIds' shape) — no inference, no hardcoded preset name.
1114
+ * null means the fact is NOT READABLE — which is UNKNOWN, never "standard" (#77's roster
1115
+ * discipline applied to the preset: absence invented from unreadability is the same lie).
1116
+ */
1117
+ function presetOfSession(sessions, sessionId) {
1118
+ try {
1119
+ const value = ((sessions?.list?.getSnapshot?.())?.byId?.[sessionId])?.projectionValues?.agentPreset;
1120
+ return typeof value === "string" && value !== "" ? value : null;
1121
+ } catch {
1122
+ return null;
1123
+ }
1124
+ }
1125
+ /**
1126
+ * The ONE visibility predicate for the realm-scoped door rows (#372). Unknown keeps the rows —
1127
+ * the click path answers with the named refusal, so fail-open is never fail-silent; a RESOLVED
1128
+ * foreign preset hides them, because those commands genuinely do not exist in that session.
1129
+ */
1130
+ function doorActionsVisibleFor(preset) {
1131
+ return preset === null || preset === "chapters";
1132
+ }
1049
1133
  const DOOR_ACTIONS = [{
1050
1134
  id: "chapters-fork",
1051
1135
  order: 30,
@@ -1235,11 +1319,18 @@ window.__ModuleLoader__.load({
1235
1319
  ok: false,
1236
1320
  message: "commands remote unavailable"
1237
1321
  };
1322
+ {
1323
+ const preset = presetOfSession(sessions, sessionId);
1324
+ if (preset !== null && !doorActionsVisibleFor(preset)) return {
1325
+ ok: false,
1326
+ message: `Chapters ${door.noun} needs the chapters preset realm — this session composes "${preset}". Switch this session's preset or run the door from a chapters session.`.slice(0, 140)
1327
+ };
1328
+ }
1238
1329
  const line = typeof anchorSeq === "number" && Number.isFinite(anchorSeq) ? `${door.command} ${String(Math.trunc(anchorSeq))}` : door.command;
1239
1330
  const res = await remote.commands.execute(sessionId, line, []);
1240
1331
  if (res.ok !== true) return {
1241
1332
  ok: false,
1242
- message: (res.error?.message ?? `the ${door.noun} call failed`).slice(0, 90)
1333
+ message: (res.error?.message ?? `the ${door.noun} failed — its command lives in the chapters preset realm`).slice(0, 90)
1243
1334
  };
1244
1335
  const result = res.value?.result;
1245
1336
  const text = typeof result?.text === "string" ? result.text : "";
@@ -1396,7 +1487,8 @@ window.__ModuleLoader__.load({
1396
1487
  }
1397
1488
  /** One component body for every door row; only the label and glyph differ. */
1398
1489
  function makeDoorAction(door) {
1399
- return function ChaptersDoorAction({ run }) {
1490
+ return function ChaptersDoorAction({ run, visible }) {
1491
+ if (visible !== void 0 && !visible()) return null;
1400
1492
  const [busy, setBusy] = (0, react.useState)(false);
1401
1493
  const [note, setNote] = (0, react.useState)(null);
1402
1494
  const alive = (0, react.useRef)(true);
@@ -1479,16 +1571,19 @@ window.__ModuleLoader__.load({
1479
1571
  name: "conversation.chat.assistant-actions",
1480
1572
  id: door.id,
1481
1573
  label: door.label,
1482
- inject: (sessionId, owner) => ({ run: async () => {
1483
- let anchor = null;
1484
- const mid = typeof owner?.messageId === "string" ? owner.messageId : "";
1485
- if (mid !== "") try {
1486
- const out = await runCommandText(remote, sessionId, `/chapters-anchor ${mid}`);
1487
- const n = Number.parseInt(out.trim(), 10);
1488
- if (Number.isFinite(n) && n > 0) anchor = n;
1489
- } catch {}
1490
- return run(sessionId, anchor);
1491
- } })
1574
+ inject: (sessionId, owner) => ({
1575
+ visible: () => doorActionsVisibleFor(presetOfSession(sessions, sessionId)),
1576
+ run: async () => {
1577
+ let anchor = null;
1578
+ const mid = typeof owner?.messageId === "string" ? owner.messageId : "";
1579
+ if (mid !== "") try {
1580
+ const out = await runCommandText(remote, sessionId, `/chapters-anchor ${mid}`);
1581
+ const n = Number.parseInt(out.trim(), 10);
1582
+ if (Number.isFinite(n) && n > 0) anchor = n;
1583
+ } catch {}
1584
+ return run(sessionId, anchor);
1585
+ }
1586
+ })
1492
1587
  }, component));
1493
1588
  console.info(`[client:chapters] door factory ran: ${String(effects.length)} register effect(s), types: ${effects.map((e) => typeof e).join(",")}`);
1494
1589
  return effects;