instar 1.3.60 → 1.3.62

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 (55) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +44 -2
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/config/ConfigDefaults.d.ts.map +1 -1
  5. package/dist/config/ConfigDefaults.js +26 -0
  6. package/dist/config/ConfigDefaults.js.map +1 -1
  7. package/dist/core/InitiativeTracker.d.ts +10 -0
  8. package/dist/core/InitiativeTracker.d.ts.map +1 -1
  9. package/dist/core/InitiativeTracker.js +18 -0
  10. package/dist/core/InitiativeTracker.js.map +1 -1
  11. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  12. package/dist/core/PostUpdateMigrator.js +23 -0
  13. package/dist/core/PostUpdateMigrator.js.map +1 -1
  14. package/dist/core/SessionRefresh.d.ts +10 -0
  15. package/dist/core/SessionRefresh.d.ts.map +1 -1
  16. package/dist/core/SessionRefresh.js +12 -2
  17. package/dist/core/SessionRefresh.js.map +1 -1
  18. package/dist/core/types.d.ts +62 -0
  19. package/dist/core/types.d.ts.map +1 -1
  20. package/dist/core/types.js.map +1 -1
  21. package/dist/monitoring/CiFailurePoller.d.ts +69 -0
  22. package/dist/monitoring/CiFailurePoller.d.ts.map +1 -0
  23. package/dist/monitoring/CiFailurePoller.js +167 -0
  24. package/dist/monitoring/CiFailurePoller.js.map +1 -0
  25. package/dist/monitoring/ContextWedgeSentinel.d.ts +118 -0
  26. package/dist/monitoring/ContextWedgeSentinel.d.ts.map +1 -0
  27. package/dist/monitoring/ContextWedgeSentinel.js +238 -0
  28. package/dist/monitoring/ContextWedgeSentinel.js.map +1 -0
  29. package/dist/monitoring/FailureAnalyzer.d.ts.map +1 -1
  30. package/dist/monitoring/FailureAnalyzer.js +10 -1
  31. package/dist/monitoring/FailureAnalyzer.js.map +1 -1
  32. package/dist/monitoring/FailureAttributionEngine.d.ts.map +1 -1
  33. package/dist/monitoring/FailureAttributionEngine.js +2 -1
  34. package/dist/monitoring/FailureAttributionEngine.js.map +1 -1
  35. package/dist/monitoring/FailureLedger.d.ts +14 -1
  36. package/dist/monitoring/FailureLedger.d.ts.map +1 -1
  37. package/dist/monitoring/FailureLedger.js +43 -4
  38. package/dist/monitoring/FailureLedger.js.map +1 -1
  39. package/dist/monitoring/SentinelNotifier.d.ts +1 -1
  40. package/dist/monitoring/SentinelNotifier.d.ts.map +1 -1
  41. package/dist/monitoring/SentinelNotifier.js.map +1 -1
  42. package/dist/monitoring/sentinelWiring.d.ts +23 -0
  43. package/dist/monitoring/sentinelWiring.d.ts.map +1 -1
  44. package/dist/monitoring/sentinelWiring.js +36 -0
  45. package/dist/monitoring/sentinelWiring.js.map +1 -1
  46. package/dist/server/AgentServer.d.ts +1 -0
  47. package/dist/server/AgentServer.d.ts.map +1 -1
  48. package/dist/server/AgentServer.js +52 -0
  49. package/dist/server/AgentServer.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/data/builtin-manifest.json +19 -19
  52. package/upgrades/1.3.61.md +32 -0
  53. package/upgrades/1.3.62.md +89 -0
  54. package/upgrades/side-effects/context-wedge-sentinel.md +69 -0
  55. package/upgrades/side-effects/failure-learning-ingestion-sources.md +59 -0
@@ -0,0 +1,59 @@
1
+ # Side-Effects Review — Failure-Learning Ingestion Sources (slice 1)
2
+
3
+ **Slug:** `failure-learning-ingestion-sources`
4
+ **Date:** 2026-05-28
5
+ **Author:** echo
6
+ **Spec:** `docs/specs/FAILURE-LEARNING-INGESTION-SOURCES-SPEC.md` (CONVERGED v3.1, approved: true — Justin, topic 13201)
7
+ **Convergence report:** `docs/specs/reports/failure-learning-ingestion-sources-convergence.md`
8
+
9
+ ## Summary
10
+
11
+ Slice 1 of the ingestion-sources build (per spec §10): the `ci` + `revert` automatic feeds plus the shared substrate they depend on. This artifact is updated per commit as slice 1 lands.
12
+
13
+ ### Commit 1 — shared substrate (this commit)
14
+
15
+ Files:
16
+ - `src/monitoring/FailureLedger.ts`: extend `FailureCategory` enum additively (`build-failure`, `test-failure`, `regression` — were clamped to `unknown`, spec §7); `open()` now (a) prunes `failure_occurrences` to the most-recent N per dedupeKey (bounded forensic log, spec §5 — safe because the analyzer never reads this table) via a new `maxOccurrencesPerKey` option (default 200), and (b) uses an `INSERT … ON CONFLICT(dedupe_key) DO UPDATE … RETURNING id` upsert so a cross-process race increments instead of dropping the record (spec §5).
17
+ - `src/monitoring/FailureAttributionEngine.ts`: `coerceCategory` allow-list extended to the 3 new categories (so they survive instead of clamping to `unknown`).
18
+ - `src/monitoring/FailureAnalyzer.ts`: `RECOMMENDATION_BY_CATEGORY` (a total `Record<FailureCategory,string>`) gains entries for the 3 new categories — **required**, the enum extension fails `tsc` without them (spec §7); and `analyze()` now excludes `status === 'resolved'` records from active clustering (spec §6.1 — implements parent §4.4 M6, specified-but-unbuilt; `reopened` stays IN as it is active again).
19
+
20
+ ## Decision-point inventory
21
+
22
+ - **Enum: extend vs map?** Extend (additive). The dashboard's `CATEGORY_WORDS`/`TYPE_WORDS` already referenced these labels, so the ledger was out of sync; extending aligns them. TEXT column, no CHECK → migration-free for existing rows.
23
+ - **ON CONFLICT vs keep SELECT-then-INSERT?** Kept the in-transaction SELECT-existing fast path (avoids burning a sequence number on the common in-process repeat) AND added `ON CONFLICT … RETURNING id` as the cross-process race belt. `better-sqlite3` transactions are synchronous/serialized intra-process, so the race is cross-process only (rare — machine-scoped DB files); the belt makes it lossless regardless.
24
+ - **Occurrence retention: which table, what cap?** Only `failure_occurrences` (the forensic log) is pruned; `failure_records` is untouched. Default cap 200/dedupeKey, configurable. Safe because the analyzer's diversity is set-counted over deduped `failure_records`, never the occurrence table (confirmed in review — `distinctCounts()`/occurrences are unused by the analyzer; flagged as a separate parent cleanup).
25
+ - **Analyzer status-filter: exclude what?** Only `resolved` (the enum has no `closed`; `reopened` = active-again, kept in).
26
+
27
+ ## Side-effects analysis
28
+
29
+ - **Behavioral:** Additive + a correctness fix. The enum extension + coerce + recommendation entries are purely additive (no existing category changes). The analyzer status-filter changes behavior only for `resolved` records (they no longer drive a recommendation — the intended parent §4.4 behavior, previously unbuilt). The `open()` upsert is behavior-preserving for the common path; on a cross-process conflict it now increments rather than fail-open-dropping (strictly better).
30
+ - **Schema/migration:** No schema migration. `category` is a TEXT column with no CHECK, so the new enum values store fine and existing rows are unaffected. `failure_occurrences` retention only deletes surplus forensic rows.
31
+ - **Security:** No new surface. `coerceCategory` still clamps unknown free text to `unknown`; the new values are server-controlled enum members.
32
+ - **Performance:** The occurrence prune is one indexed DELETE per `open()` (idx_occ_dedupe), bounded; net effect is to STOP unbounded growth. The upsert is one statement vs the prior two (SELECT+INSERT) on the new-record path.
33
+ - **Reversibility:** Fully reversible by revert; the retention prune is the only destructive op and it only removes surplus forensic rows beyond the cap.
34
+
35
+ ### Commit 2 — the `ci` source + reverse-lookup
36
+
37
+ Files:
38
+ - `src/core/InitiativeTracker.ts`: `findByMergeCommit(oid)` / `findByPrNumber(n)` — exact-OID reverse-lookup via `list()` (TaskFlow-safe; no index needed at scale). Net-new (no reverse lookup existed).
39
+ - `src/monitoring/CiFailurePoller.ts` (NEW): the §3.1 `ci` source. `gh run list` arg-array only + `repo` regex-validated; flaky guard (latest run per head SHA; recovered SHAs dropped); per-tick write cap; lease-gated; loop self-exclusion (skip `failure-learning-loop`-origin initiatives); constant `filedBy:'source:ci'`; mapped→automatic(0.9) / unmapped→inferred(0.2)→noFeatureLink; deterministic job-name→category allow-list; `scrubSecrets()` on `detail.full`. Fail-open per-run + per-tick.
40
+ - `src/monitoring/FailureLedger.ts`: `countOccurrences()` observability/test hook for the retention cap.
41
+ - Tests: `tests/unit/CiFailurePoller.test.ts` (12 — category map, flaky guard, scrub, mapped/unmapped/loop-skip/untrusted-repo/fail-open/cap/lease), `tests/unit/FailureLedger-ingestion-substrate.test.ts` (5 — new categories survive, occurrence retention bounded, upsert increments, analyzer status-filter both sides).
42
+
43
+ Decision points: CI attribution is exact-OID (headSha→findByMergeCommit) only — pre-merge PR runs that don't map land in `noFeatureLink` (honest; PR-number mapping is a refinement). `gh` runner injected for tests. Flaky guard is batch-local (latest-run-per-SHA), not a per-run `gh run view` (cheaper; sufficient for slice 1).
44
+
45
+ ### Commit 3 — config + AgentServer wiring (CI source goes LIVE)
46
+
47
+ Files:
48
+ - `src/core/types.ts`: `failureLearning.sources` block (ci/revert/regression/regressionIncludesBackslide/degradation[]/ciPollMinutes/ciMaxRunsPerTick), all off by default.
49
+ - `src/config/ConfigDefaults.ts`: `sources` defaults (all off) under `failureLearning` — `applyDefaults` deep-merges into existing agents existence-checked (migration parity §8, no surprise activation).
50
+ - `src/server/AgentServer.ts`: construct `CiFailurePoller` gated on `failureLearning.enabled && sources.ci` (resolveByMergeCommit via `tracker.findByMergeCommit`, resolveRepo via `git remote get-url origin` → regex; interval/cap from config); start it in the post-listen callback; stop it on shutdown. Loop-origin exclusion is inert in slice 1 (Initiative gains `origin` in slice 2) — noted in-code.
51
+ - Test: `tests/unit/CiFailurePoller-wiring.test.ts` (3) — the poller is constructed iff `enabled && sources.ci` (not dead code, not always-on), the silently-stopped-trio wiring-integrity lesson.
52
+
53
+ ## Evidence
54
+
55
+ - `tsc --noEmit`: clean (confirms the `RECOMMENDATION_BY_CATEGORY` totality is satisfied).
56
+ - Slice-1 tests green: 12 CiFailurePoller + 5 substrate + 3 wiring-integrity = 20; existing failure-learning tests unaffected.
57
+ - Remaining for slice 1: revert source + tests, agent-awareness, integration/E2E (feature-alive over HTTP + seeded-failure-surfaces), then PR.
58
+ - Existing failure-learning tests green after the substrate change: `FailureLedger` (11), `FailureAttributionEngine` (10), `FailureLoop` — 28 passing, no regressions.
59
+ - Dedicated slice-1 substrate tests (occurrence retention bounded; ON CONFLICT count=2-not-dropped; analyzer status-filter both sides) land with the test commit.