instar 1.3.1980 → 1.3.1982

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 (77) hide show
  1. package/dist/commands/init.d.ts +1 -0
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.js +29 -3
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/commands/machine.d.ts.map +1 -1
  6. package/dist/commands/machine.js +5 -1
  7. package/dist/commands/machine.js.map +1 -1
  8. package/dist/commands/server.d.ts.map +1 -1
  9. package/dist/commands/server.js +9 -0
  10. package/dist/commands/server.js.map +1 -1
  11. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  12. package/dist/core/PostUpdateMigrator.js +28 -2
  13. package/dist/core/PostUpdateMigrator.js.map +1 -1
  14. package/dist/core/UpdateChecker.d.ts.map +1 -1
  15. package/dist/core/UpdateChecker.js +24 -0
  16. package/dist/core/UpdateChecker.js.map +1 -1
  17. package/dist/core/identityBuildFence.d.ts +97 -0
  18. package/dist/core/identityBuildFence.d.ts.map +1 -0
  19. package/dist/core/identityBuildFence.js +198 -0
  20. package/dist/core/identityBuildFence.js.map +1 -0
  21. package/dist/core/ownerRecordStore.d.ts +2 -0
  22. package/dist/core/ownerRecordStore.d.ts.map +1 -1
  23. package/dist/core/ownerRecordStore.js +2 -0
  24. package/dist/core/ownerRecordStore.js.map +1 -1
  25. package/dist/core/ownerRecordSync.d.ts +43 -1
  26. package/dist/core/ownerRecordSync.d.ts.map +1 -1
  27. package/dist/core/ownerRecordSync.js +115 -6
  28. package/dist/core/ownerRecordSync.js.map +1 -1
  29. package/dist/core/ownerRecordWiring.d.ts +19 -1
  30. package/dist/core/ownerRecordWiring.d.ts.map +1 -1
  31. package/dist/core/ownerRecordWiring.js +37 -2
  32. package/dist/core/ownerRecordWiring.js.map +1 -1
  33. package/dist/data/standards-guard-index.json +1 -1
  34. package/dist/data/standards-guard-index.meta.json +2 -2
  35. package/dist/data/standards-registry.meta.json +1 -1
  36. package/dist/monitoring/NativeHookEvents.d.ts +10 -0
  37. package/dist/monitoring/NativeHookEvents.d.ts.map +1 -1
  38. package/dist/monitoring/NativeHookEvents.js +37 -0
  39. package/dist/monitoring/NativeHookEvents.js.map +1 -1
  40. package/dist/monitoring/contextLayers/h3Builder.d.ts +1 -1
  41. package/dist/native/InstarWedgeCanary.app/Contents/MacOS/InstarWedgeCanary +0 -0
  42. package/dist/native/instar-desktop-host +0 -0
  43. package/dist/server/machineRoutes.d.ts.map +1 -1
  44. package/dist/server/machineRoutes.js +13 -0
  45. package/dist/server/machineRoutes.js.map +1 -1
  46. package/dist/server/ownerRecordRoutes.d.ts.map +1 -1
  47. package/dist/server/ownerRecordRoutes.js +2 -0
  48. package/dist/server/ownerRecordRoutes.js.map +1 -1
  49. package/dist/server/phoneSetupRoutes.d.ts.map +1 -1
  50. package/dist/server/phoneSetupRoutes.js +11 -0
  51. package/dist/server/phoneSetupRoutes.js.map +1 -1
  52. package/dist/server/routes.d.ts.map +1 -1
  53. package/dist/server/routes.js +4 -1
  54. package/dist/server/routes.js.map +1 -1
  55. package/dist/server/sameNetworkListener.d.ts +39 -5
  56. package/dist/server/sameNetworkListener.d.ts.map +1 -1
  57. package/dist/server/sameNetworkListener.js +102 -16
  58. package/dist/server/sameNetworkListener.js.map +1 -1
  59. package/dist/server/sameNetworkRefusals.d.ts +59 -0
  60. package/dist/server/sameNetworkRefusals.d.ts.map +1 -0
  61. package/dist/server/sameNetworkRefusals.js +154 -0
  62. package/dist/server/sameNetworkRefusals.js.map +1 -0
  63. package/dist/testing/selfActionRegistry.d.ts.map +1 -1
  64. package/dist/testing/selfActionRegistry.js +27 -0
  65. package/dist/testing/selfActionRegistry.js.map +1 -1
  66. package/package.json +1 -1
  67. package/src/data/awareness/owner-record.md +1 -0
  68. package/src/data/awareness/same-network-first-phone.md +1 -0
  69. package/src/data/builtin-manifest.json +65 -65
  70. package/src/data/standards-guard-index.json +1 -1
  71. package/src/data/standards-guard-index.meta.json +2 -2
  72. package/src/data/standards-registry.meta.json +1 -1
  73. package/upgrades/1.3.1981.md +37 -0
  74. package/upgrades/1.3.1982.md +26 -0
  75. package/upgrades/side-effects/home-listener-phone-limits.md +59 -0
  76. package/upgrades/side-effects/hook-reporter-event-delivery.md +139 -0
  77. package/upgrades/side-effects/identity-security-piece2c-minimum-build-fence.md +120 -0
@@ -0,0 +1,26 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ The built-in command hook reporter (`hook-event-reporter.js`, the default on every agent) read the event name from
9
+ `hook_event`, but Claude Code sends `hook_event_name`. Every turn-end (`Stop`), helper start and stop, task completion,
10
+ session end and pre-compaction event was stored as `Unknown`, and the reporter never put the instar session id in the
11
+ payload, so the features that listen for those events (subagent tracking, compaction Trigger 1, the context-budget
12
+ practice-fold trigger) never heard them on agents without the native reporter. Both copies of the script now read
13
+ `hook_event_name` first (the old spelling still works), validate the session id once, add `instar_session_id` and
14
+ `instar_session`, and forward the native reporter's short identifying fields, bounded in the script. No message text is
15
+ sent from the script. The `/hooks/events` route applies the native path's bounds to those fields and uses one validated
16
+ session id for storage and dispatch. Spec: `docs/specs/hook-reporter-event-delivery.md`.
17
+
18
+ ## What to Tell Your User
19
+
20
+ - **Background features now see what sessions are doing**: "Some of my background checks, like noticing a stuck helper or a session about to compact its memory, were not receiving the signals they were built on. They receive them now, so those checks actually run."
21
+
22
+ ## Summary of New Capabilities
23
+
24
+ | Capability | How to Use |
25
+ |-----------|-----------|
26
+ | Command-path hook events carry real names and the session id | Automatic after update; read them with `GET /hooks/events/:sessionId` |
@@ -0,0 +1,59 @@
1
+ # Side effects: home listener limits sized for a real phone, and a bounded refusal log
2
+
3
+ In plain words: the agent's home (same-network) listener now lets a phone open as many connections as a real app screen does, gives the Windows pass-through's single address the whole door where every phone arrives through it, and writes a short, bounded note of every refusal so a phone's 403 or connection error can be explained afterwards.
4
+
5
+ Tier 1 (a revert fully undoes it; no config, no migration, no new authority). Size: 3 source files (`src/server/sameNetworkListener.ts`, new `src/server/sameNetworkRefusals.ts`, `src/server/phoneSetupRoutes.ts` one read route), 1 awareness line, 1 dated note in the A4 spec, 2 new test files, 2 test files extended. Effort: one build pass, one commit attempt planned.
6
+
7
+ Why now: builder #62 paired a real iPhone app over home Wi-Fi with a Windows-made test agent. Messages never got through. Through the Windows pass-through 8 parallel TLS connections went 6/8, straight to the agent 8/8; the app log showed "refused (limit)" exactly in the phone's failure windows. The pass-through is fixed in the Windows app (24/240/64 per address, same numbers); this change makes the agent's own limits agree.
8
+
9
+ Also in this change (it blocks it): main's `tests/unit/no-silent-fallbacks.test.ts` fails (495 > baseline 494) since #3603 added a designed probe catch in `src/core/UpdateChecker.ts` `findBundledNpmCli` (`catch { /* not this layout */ }`, line 820). Bisected on a clean main worktree: 494 two commits back, 495 from #3603. That catch now carries the `@silent-fallback-ok` marker with its reason (comment only, no behaviour change); the count is 494 again.
10
+
11
+ ## What changes for running agents
12
+ - `SAME_NETWORK_MAX_CONNECTIONS` 32 -> 64; `SAME_NETWORK_PER_ADDRESS_OPEN` 6 -> 24; `SAME_NETWORK_PER_ADDRESS_PER_MIN` 40 -> 240. Applies where the agent listens directly (macOS/Linux on the LAN address) and in WSL mirrored mode. WSL NAT mode is unchanged in shape: no per-address limit here (the pass-through owns it), the total is now 64, equal to the pass-through's total.
13
+ - WSL mirrored mode: the bind is loopback and every caller (the pass-through, carrying every phone) arrives as 127.0.0.1, so the old per-address bucket was one shared 6-place bucket for all phones (the spec itself noted "enough for one phone's setup"). That address (and its IPv4-mapped form) now gets `SAME_NETWORK_FORWARDER_OPEN` = 64 open and `SAME_NETWORK_FORWARDER_PER_MIN` = 960 a minute. Decided with the bind from the plan's mode, never from the caller. Any other address in mirrored mode keeps the per-phone limit. A direct (non-WSL) listener never gives loopback this bucket.
14
+ - New `SameNetworkRefusalLog`: records (a) a connection refused by a per-address limit (`address-open`, `address-per-minute`) or by the total (`total-open`, Node's `drop` event), (b) a failed TLS handshake (`tls-<code>`; a socket the listener itself closed for a limit is not recorded twice), (c) every request answered with status >= 400, by the gate or any route behind it, with the answer's own `error` code when it is a plain code (else `http-<status>`). Fields: time, kind, method, route (query dropped, id-like segments `:id`, odd characters `:x`, 120 chars max), status, first 8 characters of `X-Instar-Device` when it has an id's shape, caller's real address. Never a header value, body, query, signature, token, setup id or full device id. Bounded: 300 entries, an identical repeat of the newest only bumps its count; written as one JSON file (0600, atomic rename) at most once per 2 s and on stop; unreadable file starts empty; write errors keep entries in memory.
15
+ - `GET /mobile/same-network/refusals?limit=N` on the main listener, behind the existing `localOnly` (bearer + from this computer + no forwarding header + pairing on); not on the home listener (the gate only lets device-allowlisted routes through). Newest first, default 100, max 300.
16
+ - To read the answer's error code, the listener wraps `res.end` for that response only and keeps at most the first 512 characters of an error body in memory until the response finishes; nothing of it is stored except a matching plain code.
17
+
18
+ ## 1. Over-block
19
+ Fewer refusals than before. Remaining over-block: a household where more than 64 connections are open at once through one door, or one device opening more than 240 a minute (four a second sustained). Neither matches normal phone use (ten screen loads a minute is 120).
20
+
21
+ ## 2. Under-block
22
+ A misbehaving LAN device can now hold 24 sockets and open 4 a second instead of 6 and 40 a minute; the total 64, the 10 s handshake timeout and header/request timeouts still bound resources. In mirrored mode a local Windows program can use the whole 64 (it could already exhaust the old shared 6, starving every phone; a program already on the PC is outside the threat this limit addresses). The refusal log does not record successful requests (by design) nor refusals on the main listener.
23
+
24
+ Dependency named: the mirrored-mode door-sized bucket relies on the Windows pass-through limiting each real caller (24 open, 240 a minute). That is the Windows app's `LanForward` (instar-desktop-apps, commit raising its limits to 24/240/64, with tests on both sides of each limit in that repo); a Windows app older than that still refuses at 6/40 before the agent. How it is verified: the next live home-Wi-Fi phone run through the Windows app checks both hops with the refusal log and the app log.
25
+
26
+ ## 3. Level of abstraction
27
+ The limits stay where A4 put them (the listener's connection handler and the pass-through). The log sits in the listener, the one place that sees connection-level, TLS-level and HTTP-level refusals of that listener; routes are unchanged. No smarter gate exists for this; the log feeds people and agents, not a gate.
28
+
29
+ ## 4. Signal vs authority (docs/signal-vs-authority.md)
30
+ The log is a pure signal: it never refuses, delays or changes an answer. The limit change only moves existing numeric limits; the decision structure (deterministic resource bounds, not judgment calls) is unchanged, which is the right kind of logic for a resource bound.
31
+
32
+ ## 5. Interactions
33
+ - `markSameNetworkSocket` rewrites the socket's `remoteAddress` to `sn:<addr>`; the log takes the real address from that function's return value, so `isLoopbackPeer` and arrival checks are untouched.
34
+ - Wrapping `res.end` calls the original with the same arguments; the gate's bare `/health` answer, `writeContinue` and express responses behave as before (existing integration/e2e suites pass).
35
+ - The Windows pass-through ships 24/240/64 in the same change set (separate repo), so the two hops agree; an older Windows app with 6/40/32 still refuses before the agent and is fixed by its own update.
36
+ - The wsl-listener test "per-address limit stays on in mirrored mode" now asserts the door-sized bucket.
37
+
38
+ ## 6. External surfaces
39
+ One new local-only read route; a new state file in the agent's state folder (not synced). Phones see fewer refusals. No change to what the listener serves.
40
+
41
+ ## 7. Multi-machine posture
42
+ Machine-local by design: each machine's home listener serves only phones on that machine's network, and its refusals are about that machine's door. The file is in `state/` and is not part of git-sync; reading another machine's refusals goes through that machine (not proxied), which matches the other `/mobile/same-network*` routes.
43
+
44
+ ## 8. Rollback
45
+ Revert the commit. The state file is left behind harmlessly (nothing reads it after a revert); no migration.
46
+
47
+ ## Tests
48
+ - `tests/unit/same-network-home-limits.test.ts` (new, 19): the literal numbers; a busy phone (ten 12-connection loads in a minute, then 24 open); 24/25 open and 240/241 a minute with the 59 s/60 s edges; mirrored loopback 64/65 and 960/961, IPv4-mapped form, two busy phones, another address still 24, a direct listener's loopback still 24; refusal-log route reduction, codes, device prefix, bound and coalescing, private file and restart, unreadable file; a real TLS listener records gate and route refusals (no secrets in the file), a limit refusal and a failed handshake once each. Negative control: with 6/40/32 put back, 9 of 19 fail (the limit tests; the log tests do not depend on the numbers).
49
+ - `tests/integration/same-network-refusals.test.ts` (new, 2): a stand-in phone over real TLS; refusals read back through the route without setup id, PIN, signature, pairing code or full device id; 401 without a token, 403 when forwarded.
50
+ - `tests/e2e/same-network-first-phone-alive.test.ts`: the route is alive on the production start path, and the log survives a restart.
51
+ - `tests/unit/same-network-wsl-listener.test.ts`: mirrored bucket assertion updated.
52
+
53
+ ## Second-pass review
54
+
55
+ **Reviewer:** independent reviewer subagent (general-purpose, fresh context, given the diff, the artifact and the A4 spec), 2026-11-21. Verdict: concur, nothing blocking. It traced that the forwarder bucket is set only from a mirrored bind plan (always 127.0.0.1) and never in NAT, direct or test-override binds; that nothing secret is kept and a flood writes at most once per 2 s; that the `res.end` wrap passes everything through and records once; and that the route is reachable only with the bearer from this computer (the home listener's gate answers 404 first). Non-blocking findings, handled: an error body over 512 characters lost its code (a leading `"error"` field is now read without a full parse); a request whose connection closed before any answer went unrecorded (now `closed-before-answer`); the caller address cannot tell phones apart behind the pass-through and a flood can push old entries out (said in the awareness text); the pass-through dependency is named above. Accepted: a short all-letter token-like path segment would be kept as written (no current home-listener route carries one). Test gaps closed: NAT never gets the door-sized bucket, a burst writes the file once, a clipped error body keeps its code, a hung-up request is recorded.
56
+
57
+ ## Current-main repair, 2026-11-22
58
+
59
+ Fresh helper-created worktree based on JKHeadley/main 9b61d6286, version 1.3.1978. The only merge conflict was two equivalent explanatory comments on UpdateChecker.findBundledNpmCli; retained current main verbatim. No runtime source differs from the previously reviewed candidate except the already-current main. All eight side-effects answers above remain unchanged. Targeted validation: 35 unit, 2 HTTP integration, and 3 production lifecycle tests pass; TypeScript noEmit passes. Full current-tree verification is required before merge. Independent reviewer /root/review_3625_repair concurred: listener, log, route and tests byte-for-byte unchanged from c3f9c466; local-only authentication and forwarder bounds intact. One repair review, one commit attempt planned.
@@ -0,0 +1,139 @@
1
+ # Side-Effects Review — Hook reporter event delivery (real event names and the session id)
2
+
3
+ **Version / slug:** `hook-reporter-event-delivery`
4
+ **Date:** `2026-11-21`
5
+ **Author:** `echo`
6
+ **Second-pass reviewer:** `codex-cli:gpt-6.2-astra (independent, see the section at the end)`
7
+
8
+ ## Summary of the change
9
+
10
+ The built-in command hook reporter read the event name from `hook_event` (Claude Code sends `hook_event_name`) and never
11
+ put the instar session id in the payload, so every Stop, SubagentStart, SubagentStop, TaskCompleted, SessionEnd and
12
+ PreCompact event was stored as `Unknown` and their consumers never ran on the default path. Both copies of the script
13
+ (update path in `PostUpdateMigrator.ts`, new agents in `init.ts`) now read `hook_event_name` first, validate the session
14
+ id once (an invalid id sends nothing), add `instar_session_id` and `instar_session`, and forward six short identifying
15
+ fields bounded in the script. No message text is sent. The `/hooks/events` route applies the native path's bounds to
16
+ those fields with `boundCommandReporterPayload` (new, `NativeHookEvents.ts`) and uses one validated session id for both
17
+ storage and the dispatcher. Spec: `docs/specs/hook-reporter-event-delivery.md`.
18
+
19
+ ## Decision-point inventory
20
+
21
+ - Which events a consumer receives — invariant (Claude Code's own field).
22
+ - Field bounds on the command path — invariant (native bounds reused for the listed fields).
23
+ - Session id sent by the script — invariant (matches the id pattern or is sent nowhere).
24
+
25
+ ## 1. Over-block
26
+
27
+ An agent whose `INSTAR_SESSION_ID` does not match `^[A-Za-z0-9._:-]{1,128}$` now sends no hook events at all (before:
28
+ events were sent with that id). Instar mints ids that match (UUIDs and tmux-safe names), so no real agent is expected to
29
+ hit this; such an id could not be attributed by the route anyway. Fields failing their bound are dropped from the
30
+ payload while the event still arrives: a malformed `agent_id` or `task_id`, an `agent_type` or `instar_session` over
31
+ 128 characters, a relative or over-1024-character `agent_transcript_path`, a `reason` or `trigger` over 64. The route
32
+ now overwrites a caller-supplied `instar_session_id` with its own validated value, or removes it. Consequence for a direct caller that
33
+ supplies the id only in the body (no scoped session and no valid `instar_sid` query): the event is still stored, but
34
+ without a session id, so consumers that require one (Compaction Trigger 1, the practice-fold trigger) do not act on
35
+ it. This is deliberate (the route speaks only for the session it can attribute); the built-in scripts always send the
36
+ query value. No other caller of this route is known in the source tree.
37
+
38
+ ## 2. Under-block
39
+
40
+ Codex bodies without `hook_event_name` and without `tool_name` still arrive as `Unknown` (unchanged). The session
41
+ summary's last-message field and the HelperWatchdog's failure markers from a subagent's final text are not fed by the
42
+ built-in command scripts (they send no message text); they are fed by the native reporter, or by a direct caller of
43
+ `/hooks/events` that posts the text (redacted and cut to its last 200 characters by the route). The practice-fold runner still
44
+ cannot read a handoff reply from the hook; that is a separate spec, and practice folds stay off on Echo until it ships.
45
+
46
+ ## 3. Level-of-abstraction fit
47
+
48
+ Right layer: the defect is in the reporter that every agent runs; the server-side bounds sit beside the native
49
+ projection they mirror. The native reporter (docs/specs/native-hook-events.md) is the long-term path and is unchanged.
50
+
51
+ ## 4. Signal vs authority compliance
52
+
53
+ No authority added. The reporter and route carry events; they decide nothing. They do become new inputs to existing
54
+ consumers that act, exactly as the native path already feeds them: the compaction sentinel (can inject recovery input
55
+ into the compacting session), the pre-compaction flush where enabled (writes durable facts), and the HelperWatchdog
56
+ (alerts behind their own default-off gate). Those consumers' own gates and scopes are unchanged.
57
+
58
+ ## 4b. Judgment-point check
59
+
60
+ No competing-signals decision point is touched; no static heuristic is added.
61
+
62
+ ## 5. Interactions
63
+
64
+ Consumers that start receiving events on the command path, as they already do on the native path: `SubagentTracker`
65
+ (start/stop/session end), Compaction Trigger 1 (scoped to the emitting session; Triggers 2 and 3 already cover
66
+ compaction, and the sentinel dedupes across triggers), the per-instar-session index in `HookEventReceiver` (now
67
+ includes command-path rows), the practice-fold runner's Stop trigger (dev-gated; off on Echo; off on the fleet), and the pre-compaction memory flush
68
+ (`wirePreCompactionFlush`, `PreCompact`): off by default (`preCompactionFlush.enabled`), but ON on Echo, where it has
69
+ been blind on the command path. Where it is on, each delivered `PreCompact` now reaches its flush, which (given an intelligence provider, a
70
+ session id and a readable, non-empty transcript) makes one bounded model call over the transcript
71
+ (`transcriptCharBudget`) and writes at most `maxFactsPerFlush` durable facts when extraction yields any; every delivered `PreCompact` also
72
+ writes an audit entry (including when the flush skips, finds no facts, or the provider errors). Compaction
73
+ Trigger 1 feeds the compaction sentinel, which can inject recovery input into the compacting session (scoped to that
74
+ session; the sentinel already dedupes across its three triggers). Subagent events start the HelperWatchdog's stall
75
+ tracking and logging; its injected alerts stay behind their own default-off gate.
76
+ Codex: `PostToolUse` rows already carried `tool_name` (981 of 981 sampled), so their naming is unchanged; what changes
77
+ is that the dispatcher receives the validated id and the stored row gains session attribution, so per-session
78
+ summaries count these rows;
79
+ its `UserPromptSubmit` rows are named only where Codex sends `hook_event_name` (the test supplies the field; on Echo
80
+ 32 Codex prompt rows were stored named after the local patch, evidence that it does), and no consumer listens for that
81
+ name. The existing wiring test pinning that
82
+ both routes call the shared dispatch function was updated for the validated id variable.
83
+
84
+ ## 6. External surfaces
85
+
86
+ Observable effects beyond storage, where the consuming feature is on: recovery input injected into a compacting
87
+ session, durable memory facts from the pre-compaction flush, and HelperWatchdog alerts (default off). The scripts post
88
+ to `INSTAR_SERVER_URL`, unchanged.
89
+
90
+
91
+ Stored hook-event rows gain names and fields; dashboard session telemetry (`GET /sessions`, summaries) can now show
92
+ command-path subagent and task data. Where the pre-compaction flush is on, durable memory facts are written at
93
+ compaction (bounded, audited). No messages to users, no new routes, no new config. New for direct callers of
94
+ `/hooks/events`: `last_assistant_message` and `task_subject` are now redacted and cut to their last 200 characters
95
+ before storage and dispatch (before this change a direct caller's text was stored as received); the built-in scripts
96
+ send none. Unchanged: a scoped caller's `transcript_path`, `agent_transcript_path` and `cwd` are removed before
97
+ dispatch, so consumers receive no paths from scoped requests.
98
+
99
+ ## 7. Multi-machine posture (Cross-Machine Coherence)
100
+
101
+ Machine-local by design (unchanged): a hook fired by a Claude Code process is delivered over loopback to the server on
102
+ the same host and stored in that machine's `hook-events/`. No user-facing notices, no durable state that moves with a
103
+ topic, no generated URLs. Status surfaces: none new or changed.
104
+
105
+ ## 8. Rollback cost
106
+
107
+ Pure code change. Revert and ship a patch; built-in hooks are overwritten on the next update, so agents return to the
108
+ old script automatically. Stored rows written meanwhile stay valid (extra fields are ignored by older readers). Effects
109
+ of consumers that ran meanwhile are not undone by a revert: durable facts written by an enabled pre-compaction flush stay
110
+ in memory (they are ordinary, audited, removable memory entries), and recovery input already injected stays in those
111
+ sessions' history, as do any HelperWatchdog alerts injected where that gate is on.
112
+
113
+ ## Conclusion
114
+
115
+ Ship. The change restores events that existing consumers were designed for, sends no message text, and is covered by
116
+ an integration test that runs both real script copies against the real server (fails on the old code), plus unit tests:
117
+ `tests/integration/command-hook-reporter.test.ts` (10 tests), `tests/unit/command-hook-reporter-fields.test.ts` (5),
118
+ and the updated wiring assertion in `tests/unit/native-hook-events-consumers.test.ts`. Limits: the init copy is
119
+ compared with the update copy at the wire (byte-identical) rather than also sent through the server, and the
120
+ consumers' own effects (recovery injection, flush writes) are covered by their existing native-path tests, not
121
+ re-exercised end to end here.
122
+
123
+ ## Second-pass review (independent, codex-cli:gpt-6.2-astra, 2026-11-22)
124
+
125
+ Concur with the review.
126
+
127
+ "Both reporters restore event names and attach the instar session ID without forwarding message text. The route uses
128
+ its validated session ID for storage and dispatch, and bounds the new fields before either. The artifact accounts for
129
+ the restored consumer effects, their existing gates, and the changes for direct callers."
130
+
131
+ Earlier runs of the same reviewer raised concerns, each corrected in this artifact before the concurring run: the
132
+ pre-compaction flush consumer and its durable writes and audit entries; recovery injection and watchdog effects that a
133
+ revert cannot undo; direct-caller text redaction being new; scoped callers losing paths; body-only session ids being
134
+ dropped; and a spurious "deleted test suite" that came from comparing against a newer main (the branch was then
135
+ fast-forwarded and the diff taken against the merge base).
136
+
137
+ ## Full-gate metadata correction — 2026-11-22
138
+
139
+ The retained full-gate failure at `000b49408029` was the ladder registry assertion: this spec used `none` for a flagless defect fix, while the established contract requires `not applicable:` followed by a reason. The spec now uses that contract and preserves the rollout sequence. No registry entry is invented and no assertion or runtime behavior changes. This follow-up is Tier 1, two documentation files and no runtime edits. Full-gate requalification remains required.
@@ -0,0 +1,120 @@
1
+ # Side-Effects Review — The minimum-build fence
2
+
3
+ **Version / slug:** `identity-security-piece2c-minimum-build-fence`
4
+ **Date:** `2026-11-18`
5
+ **Author:** `Echo`
6
+ **Second-pass reviewer:** `independent reviewer subagent (see below)`
7
+
8
+ ## Summary of the change
9
+
10
+ Piece 2c of the approved identity and security design (topic 144636): machines too old to follow the identity rules are waited for before enrolment, then refused after it.
11
+
12
+ - `src/core/identityBuildFence.ts` contains:
13
+ - the per-level floor table (Basic has no fence);
14
+ - `PeerBuildLedger`: each peer's signed build statement, per registration, saved under the key-material path `state/owner-record/`, with four states (confirmed, below, unconfirmed, retired);
15
+ - `fenceInForce`: the record's `minimumBuild` or the last verified fence; a bad value never relaxes it; an owner's lowering to Basic clears it;
16
+ - `fenceStatus` (readiness) and `belowFence`.
17
+ - `ownerRecordSync.ts`:
18
+ - pulls carry `build` and `guards`, and replies carry the replier's build and guards, recorded before judging;
19
+ - after enrolment, only confirmed peers get or give owner-record data;
20
+ - one aggregated notice from the lease holder, at most daily;
21
+ - a `fence` section in status.
22
+ - `ownerRecordStore.gate()` holds with `fence-unusable` when enrolled with no usable fence.
23
+ - `machineRoutes.ts` (`POST /api/pair`) refuses a joiner below the fence after enrolment. The joiner (`commands/machine.ts`) now sends its build.
24
+ - `UpdateChecker.rollback()` refuses a rollback below the fence.
25
+ - `ownerRecordWiring.ts` adds `ownerRecordGate()` (piece 2b's one gate function, now exported for later pieces) and `ownerRecordFence()`, and wires the ledger, build and notice. `server.ts` passes the notice through `notify('SUMMARY', 'mesh-alert', …)`.
26
+ - The route `GET /owner-record` gains `fence`, and the awareness entry gains a line.
27
+
28
+ ## Decision-point inventory
29
+
30
+ - **Sharing the owner record while enrolled:** confirmed peers only.
31
+ - **A join after enrolment:** refused below the fence.
32
+ - **A rollback after enrolment:** refused below the fence.
33
+ - **The gate:** holds when enrolled with no usable fence.
34
+
35
+ ## 1. Over-block
36
+
37
+ - **Before enrolment nothing is refused,** and no agent is enrolled until piece 3.
38
+ - **After enrolment, missing evidence refuses nothing except the record itself.** A sleeping or restarting peer reads "unconfirmed": it gets no record entries until it pulls again, but liveness, lease and work traffic are untouched.
39
+ - **A join at or above the fence pairs normally.**
40
+
41
+ ## 2. Under-block
42
+
43
+ A hand-installed older build still acts on its own direct inbound. That is the stated residual. Refusing it the lease and routing is piece 2d, and Phone-level enrolment waits for 2d.
44
+
45
+ ## 3. Level-of-abstraction fit
46
+
47
+ - **The fence lives beside the owner record.**
48
+ - **Join and rollback refusals sit at their existing choke points:** the join route, and `UpdateChecker.rollback`, next to the existing Codex downgrade floor.
49
+
50
+ ## 4. Signal vs authority compliance
51
+
52
+ **Required reference:** [docs/signal-vs-authority.md](../../docs/signal-vs-authority.md)
53
+
54
+ - [ ] No — this change produces a signal consumed by an existing smart gate.
55
+ - [x] No — the decisions are deterministic comparisons over enumerable inputs (version strings, signed statements, enrolment state); no judgment over meaning.
56
+ - [ ] Yes — but the logic is a smart gate with full conversational context.
57
+ - [ ] ⚠️ Yes, with brittle logic — STOP.
58
+
59
+ ## 4b. Judgment-point check
60
+
61
+ The 24-hour freshness window is four full backoff cycles of a pulling peer (spec §2). The notice is at most daily per unchanged list.
62
+
63
+ ## 5. Interactions
64
+
65
+ - **Pulls gain two fields,** and older builds ignore unknown fields.
66
+ - **The join body gains `instarVersion`;** an older inviter ignores it.
67
+ - **Rollback** gains one more refusal, beside the existing Codex floor.
68
+
69
+ ## 6. Rollback
70
+
71
+ Revert the commit. The ledger file can stay; nothing else reads it.
72
+
73
+ ## 7. Evidence
74
+
75
+ - **Unit:** `tests/unit/identity-piece2c-build-fence.test.ts` covers:
76
+ - the ledger's states, ordering, restart and per-key observations;
77
+ - the fence in force, including a bad value and lowering;
78
+ - readiness;
79
+ - `belowFence`;
80
+ - sync refusal only after enrolment;
81
+ - the single notice and the status;
82
+ - rollback refusal.
83
+ - **Integration:** `tests/integration/identity-piece2c-join-fence.test.ts`, run by Local Verify, covers a join before enrolment, a refused join (no build and an older build), and an accepted join.
84
+ - **E2E lifecycle:** the 2b lifecycle file gains one case: the production sync sends its build in every pull, and the route reports `fence`.
85
+
86
+ ## Second-pass review
87
+
88
+ An independent reviewer subagent read the code against the spec and probed it over three rounds. All 11 defects it found are fixed, each with a regression test:
89
+ - **Round 1 (8):**
90
+ - a lost or contested record relaxed or lowered the fence;
91
+ - unsigned reply builds counted as evidence, stamped with mixed clocks;
92
+ - the notice was filtered out by the hub;
93
+ - a new machine was reported as silent "for a day";
94
+ - this machine was left out of readiness;
95
+ - no report of a bad value;
96
+ - explicit installs were not fenced;
97
+ - the joiner hid the server's message.
98
+ - **Round 2 (2, plus 1 partial):**
99
+ - an unusable fence refused the owner's correction;
100
+ - a raise was never reported;
101
+ - a pairing-time judgement was still needed for new machines.
102
+ - **Round 3 (1):** a development install was compared against the installer's version instead of the agent's.
103
+
104
+ Round 4 concurred. Review: `.instar/state/identity-build-144636/reviews/p2c-second-pass.md` in the agent home.
105
+
106
+ E2E-PAIRING: EXEMPT — the join refusal is covered by the integration test over the real /api/pair route; no device pairing flow changes.
107
+
108
+ ## Class-Closure Declaration
109
+
110
+ - **defectClass:** `unbounded-self-action`
111
+ - **closure:** `guard` (tests/unit/self-action-convergence.test.ts, entry owner-record-fence-notice)
112
+ - **reason:** the only self-triggered action is the aggregated notice: once per distinct list (never repeated for an unchanged one), from the lease holder only, closed when the list empties; registered in the self-action registry.
113
+
114
+ ## Current-main merge repair, 2026-11-22
115
+
116
+ Tier 2 security maintenance under the existing approved spec; no new authority or policy. The normal merge from main 9b61d628656b5782e39c0ad57d6fb108b8ad3ad7 retains both new server imports. Semantic review found that the earlier merge had removed the unrelated stall-reconfirmation feature. Its source, types, tests, awareness and review artifacts are restored exactly from current main, including the server wiring. No paths are deleted relative to main. The minimum-build fence additions remain intact.
117
+
118
+ The independent parent reviewer inspected the actual candidate and concurred: the restored feature is byte-identical to main, and server initialization retains both the stall guard and fence wiring. No material merge concern remained, conditional on verification. Focused verification passed: 89 unit tests in five files, eight HTTP integration tests in two files, and TypeScript checking. Full verification remains assigned to the throughput coordinator. Dependency order 3445 then 3450 then 3453 and all queue holds remain unchanged.
119
+
120
+ The rollback is a normal revert of this merge repair, with the known cost that the prior branch accidentally omitted a main safety feature. There is no new persistence format, cross-machine behavior, external authority, or enrollment behavior in the repair. Existing signal-versus-authority analysis above continues to apply. One independent review pass and one commit attempt planned; no new design review rounds.