instar 1.3.837 → 1.3.839

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.
@@ -0,0 +1,25 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ Apprenticeship cycle recording now verifies the referenced instance against the live registry and accepts cycles only for active instances. Pending instances can be retired into a retained terminal abandoned state. A read-only integrity report enumerates legacy cycle rows whose instance IDs no longer exist.
9
+
10
+ ## What to Tell Your User
11
+
12
+ Apprenticeship history is now tied to the real instance registry. New cycles cannot be filed against phantom or inactive instances, mistaken pending records can be abandoned without erasing them, and older dangling rows can be inspected without silently changing history.
13
+
14
+ ## Summary of New Capabilities
15
+
16
+ - Active-only referential integrity at cycle-record time
17
+ - Retained pending-to-abandoned disposal path
18
+ - Read-only reporting for legacy dangling cycle rows
19
+ - Existing-agent migration awareness and fresh-scaffold guidance
20
+
21
+ ## Evidence
22
+
23
+ - Unit coverage for lifecycle transitions, terminal retention, capability discovery, and migration idempotency
24
+ - Integration coverage for unknown and inactive references plus legacy dangling-row reporting
25
+ - End-to-end coverage through the real AgentServer initialization path
@@ -0,0 +1,84 @@
1
+ # Side-Effects Review — Apprenticeship registry integrity
2
+
3
+ **Version / slug:** `apprenticeship-registry-integrity`
4
+ **Date:** `2026-07-15`
5
+ **Author:** `Instar-codey`
6
+ **Second-pass reviewer:** `not required`
7
+
8
+ ## Summary of the change
9
+
10
+ Cycle writes in `src/server/routes.ts` now resolve their `instanceId` through `ApprenticeshipProgram` and require an active instance. `ApprenticeshipProgram` adds retained terminal `abandoned`, reachable only from pending. A bounded read-only integrity route reports historical dangling cycle rows. Capability discovery, fresh scaffolds, existing-agent migration, and all three test tiers carry the same semantics.
11
+
12
+ ## Decision-point inventory
13
+
14
+ - Cycle-record referential integrity — modify — deterministic invariant: evidence of live work must name an existing active registry instance.
15
+ - Pending-instance disposal — add — deterministic lifecycle transition from pending to retained terminal abandoned.
16
+ - Historical integrity read — add — observation only; it never repairs or deletes rows.
17
+
18
+ ## 1. Over-block
19
+
20
+ The active-only rule intentionally rejects cycles for blocked instances. A caller that previously treated blocked as “active but paused” must resume the instance before recording more work. This is intended because a cycle is evidence that work occurred; accepting it while paused would contradict the registry. Pending, complete, and abandoned rejection is similarly intentional.
21
+
22
+ ## 2. Under-block
23
+
24
+ The check guarantees existence and current active status at record time, but it does not add a cross-store transaction. A concurrent status transition could theoretically occur between the registry read and SQLite cycle insert. The server is currently single-process and both operations are synchronous, so there is no await/yield point in that interval. Multi-process writers remain outside the stores' existing guarantees.
25
+
26
+ The integrity report scans the public 500-row read ceiling. Its `truncated` flag explicitly warns when the ceiling is reached; callers may need direct store inspection for a larger legacy population.
27
+
28
+ ## 3. Level-of-abstraction fit
29
+
30
+ The registry owns lifecycle truth, while the cycle HTTP route owns the composition between registry and cycle store. Validation belongs at that composition boundary rather than inside the cycle store, which remains usable for loading and honestly auditing legacy rows. The transition table remains the single owner of lifecycle legality.
31
+
32
+ ## 4. Signal vs authority compliance
33
+
34
+ **Required reference:** [docs/signal-vs-authority.md](../../docs/signal-vs-authority.md)
35
+
36
+ - [x] No — this is hard-invariant validation over an enumerable state machine, one of the principle's explicit exceptions.
37
+
38
+ The rule does not infer conversational meaning or weigh competing signals. Registry membership and the five statuses are complete structured facts, so deterministic rejection is the appropriate authority.
39
+
40
+ ## 4b. Judgment-point check
41
+
42
+ No new static heuristic exists at a competing-signals decision point. “Cycle evidence requires active lifecycle state” and “abandoned is pending-only and terminal” are enumerable invariants, not judgment candidates.
43
+
44
+ ## 5. Interactions
45
+
46
+ - **Shadowing:** registry validation runs after the existing request-shape and transcript-audit checks but before persistence. Existing anti-fabrication errors remain observable for otherwise valid active instances.
47
+ - **Double-fire:** no second component repairs or deletes dangling rows; the new report is read-only.
48
+ - **Races:** no asynchronous boundary exists between the synchronous registry lookup and synchronous record call.
49
+ - **Feedback loops:** none; reports do not actuate lifecycle or cycle state.
50
+
51
+ ## 6. External surfaces
52
+
53
+ API callers now receive a 400 for unknown or inactive instance references. The transition API accepts `abandoned` and returns the retained record. Capability discovery exposes the integrity endpoint. Fresh and migrated agent instructions teach all three behaviors. Persistent instance state may now contain `abandoned`; existing readers use the shared status type or return opaque JSON. No external service is contacted and no operator-facing dashboard action is added.
54
+
55
+ ## 6b. Operator-surface quality
56
+
57
+ No dashboard, approval page, or operator form is changed — not applicable.
58
+
59
+ ## 7. Multi-machine posture
60
+
61
+ **Machine-local by existing store design:** both the apprenticeship instance registry and cycle SQLite store live in the agent's local state directory today; this PR preserves that established scope and makes their local relationship coherent. It does not introduce notices, URLs, replication, or topic-transfer behavior. On multiple machines, each machine validates against its own co-located registry/store pair; no new cross-machine divergence is created by this change.
62
+
63
+ ## 8. Rollback cost
64
+
65
+ Code can be reverted in a hot-fix release. Existing `abandoned` records must not be deleted; a rollback reader that predates the status will still load the JSON record but cannot transition it, which is safe because it is terminal. No cycle rows are mutated by the report, so no cycle-data migration or repair is required.
66
+
67
+ ## Conclusion
68
+
69
+ The stricter rule closes the phantom-reference path at the correct composition boundary, preserves audit history through retained abandonment, and exposes legacy damage without inventing repairs. The principal compatibility cost—callers must activate instances before recording cycles—is the intended lifecycle contract. Clear to ship.
70
+
71
+ ## Second-pass review
72
+
73
+ Not required: this does not touch messaging, session lifecycle, dispatch, recovery, trust, coherence, or heuristic guard/sentinel authority.
74
+
75
+ ## Evidence pointers
76
+
77
+ - `tests/unit/apprenticeship-program.test.ts`
78
+ - `tests/unit/PostUpdateMigrator-apprenticeshipRegistryIntegrity.test.ts`
79
+ - `tests/integration/apprenticeship-routes.test.ts`
80
+ - `tests/e2e/apprenticeship-lifecycle.test.ts`
81
+
82
+ ## Class-Closure Declaration (display-only mirror)
83
+
84
+ No agent-authored-artifact defect and no self-triggered controller — not applicable.