instar 1.3.154 → 1.3.155
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.
- package/dist/config/ConfigDefaults.d.ts.map +1 -1
- package/dist/config/ConfigDefaults.js +4 -0
- package/dist/config/ConfigDefaults.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +14 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/PreferencesManager.d.ts +19 -0
- package/dist/core/PreferencesManager.d.ts.map +1 -1
- package/dist/core/PreferencesManager.js +26 -8
- package/dist/core/PreferencesManager.js.map +1 -1
- package/dist/core/types.d.ts +10 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/monitoring/SelfViolationDetector.d.ts +61 -0
- package/dist/monitoring/SelfViolationDetector.d.ts.map +1 -0
- package/dist/monitoring/SelfViolationDetector.js +153 -0
- package/dist/monitoring/SelfViolationDetector.js.map +1 -0
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +1 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +89 -1
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +62 -62
- package/src/scaffold/templates.ts +1 -0
- package/upgrades/1.3.142.md +32 -9
- package/upgrades/1.3.155.md +26 -0
- package/upgrades/side-effects/correction-self-violation-signal.md +133 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Side-Effects Review — Correction & Preference Learning: Self-Violation Signal
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `correction-self-violation-signal`
|
|
4
|
+
**Date:** `2026-05-31`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `not required — observe-only + dark by default; the detector holds no blocking authority and cannot alter/delay/block any outbound message`
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
Extends the shipped Correction & Preference Learning Sentinel so a stored-but-violated
|
|
11
|
+
preference becomes a learning signal instead of evaporating. A learned preference can
|
|
12
|
+
carry an OPTIONAL `violationPattern` (regex or keyword set). When the agent sends an
|
|
13
|
+
outbound message that contradicts that pattern, the contradiction is recorded as a
|
|
14
|
+
self-violation in the `CorrectionLedger` (a recurrence-reinforcing `user-preference`
|
|
15
|
+
occurrence keyed on the violated lesson), so the preference's salience grows for the
|
|
16
|
+
next session-start injection.
|
|
17
|
+
|
|
18
|
+
Files: new `src/monitoring/SelfViolationDetector.ts` (pure `detectSelfViolation`);
|
|
19
|
+
`src/core/PreferencesManager.ts` (+optional `violationPattern` on `PreferenceEntry`
|
|
20
|
+
and `RecordPreferencePayload`, persisted/round-tripped, upsert-preserving); the
|
|
21
|
+
outbound seam in `src/server/routes.ts` (a new OBSERVE-ONLY `observeSelfViolation`
|
|
22
|
+
fire-and-forget branch inside `checkOutboundMessage`, structurally independent of the
|
|
23
|
+
tone-gate verdict); config `monitoring.correctionLearning.selfViolationSignal`
|
|
24
|
+
(types.ts + ConfigDefaults.ts); Agent-Awareness (templates.ts) + Migration-Parity
|
|
25
|
+
backfill (PostUpdateMigrator migrateClaudeMd).
|
|
26
|
+
|
|
27
|
+
## Decision-point inventory
|
|
28
|
+
|
|
29
|
+
- `detectSelfViolation(text, prefs)` (new) — add — pure, deterministic, returns the
|
|
30
|
+
list of violated preferences. No authority; precision-biased (lone weak match never
|
|
31
|
+
fires); never throws.
|
|
32
|
+
- `observeSelfViolation` seam branch (new) — add — records a matched violation to the
|
|
33
|
+
ledger + an audit line. Fire-and-forget VOID; cannot influence delivery.
|
|
34
|
+
- `PreferenceEntry.violationPattern` (new optional field) — add — absent ≡ never
|
|
35
|
+
checked (back-compat).
|
|
36
|
+
- Tone-gate / `checkOutboundMessage` block-decision — UNCHANGED — the observe branch
|
|
37
|
+
runs before the gate-availability early-return and never feeds the gate or the
|
|
38
|
+
return value.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 1. Over-block
|
|
43
|
+
|
|
44
|
+
Not applicable. The feature has NO block/allow surface. The observe branch runs as a
|
|
45
|
+
fire-and-forget `void observeSelfViolation(...).catch(...)` that is structurally
|
|
46
|
+
incapable of returning a block verdict, throwing into the delivery frame, or mutating
|
|
47
|
+
the message. The wiring-integrity + E2E tests assert the message is delivered
|
|
48
|
+
byte-for-byte unchanged whether or not a violation is detected.
|
|
49
|
+
|
|
50
|
+
## 2. Under-block
|
|
51
|
+
|
|
52
|
+
There is nothing to under-block — the feature never blocks. The "miss" direction
|
|
53
|
+
(a real self-violation going unrecorded) is the deliberately-chosen safe direction:
|
|
54
|
+
precision over recall. A lone/weak keyword never fires, an unparseable pattern is a
|
|
55
|
+
no-check, and a preference without a `violationPattern` is skipped. A false
|
|
56
|
+
self-violation that nags is the bad direction, so the matcher is conservative. A
|
|
57
|
+
missed recording costs only a slightly weaker recurrence signal next session.
|
|
58
|
+
|
|
59
|
+
## 3. Level-of-abstraction fit
|
|
60
|
+
|
|
61
|
+
Correct. The detector is a pure, exhaustively-tested function (mirrors the
|
|
62
|
+
deterministic `scrubSecrets` / Layer-0 classifier discipline of the same sentinel).
|
|
63
|
+
The recording reuses the shipped `CorrectionLedger.record()` dedupe-upsert and its
|
|
64
|
+
`toApiView()` raw-text-stripping discipline; the occurrence is a `user-preference`
|
|
65
|
+
record at the code-determined `LEARNING_DETERMINISTIC_THRESHOLD` so it feeds the
|
|
66
|
+
existing 3-pronged recurrence gate exactly like any other distilled correction. No
|
|
67
|
+
new persistence layer, no new gate, no new authority.
|
|
68
|
+
|
|
69
|
+
## 4. Signal vs authority compliance
|
|
70
|
+
|
|
71
|
+
**Required reference:** [docs/signal-vs-authority.md](../../docs/signal-vs-authority.md)
|
|
72
|
+
|
|
73
|
+
- [x] Yes — this change produces a SIGNAL (a ledger occurrence + an audit line) and
|
|
74
|
+
holds ZERO authority over any message. The user's explicit hard rule ("we've been
|
|
75
|
+
bitten by guards that block messages having too much power") is honored structurally:
|
|
76
|
+
the observe call is a separate VOID branch that runs regardless of the
|
|
77
|
+
`MessagingToneGate`'s verdict and never influences it. The single authority for
|
|
78
|
+
outbound delivery remains the `MessagingToneGate` (rules B1–B17), entirely unchanged.
|
|
79
|
+
|
|
80
|
+
## 5. Interactions
|
|
81
|
+
|
|
82
|
+
- **Shadowing:** none. The observe branch is additive at the top of
|
|
83
|
+
`checkOutboundMessage`; it does not read or alter the signals, the gate result, or
|
|
84
|
+
the 422 path. With the tone gate null, the observe branch still runs (it precedes
|
|
85
|
+
the gate-availability early-return) and the message still passes through.
|
|
86
|
+
- **Double-fire:** the ledger dedupe-upserts on `kind:normalizedLearningHash`, so
|
|
87
|
+
repeated self-violations of the same preference collapse to ONE record with an
|
|
88
|
+
incrementing `occurrenceCount` (asserted by the integration test) — never a pile.
|
|
89
|
+
- **Races:** the observe call is fire-and-forget and lazy-imports its modules; the
|
|
90
|
+
ledger is the shipped WAL SQLite store (single-writer-safe, fail-open on any error).
|
|
91
|
+
Two concurrent sends recording the same preference are both safely upserted.
|
|
92
|
+
- **Feedback loops:** none. The detector reads `.instar/preferences.json` (written by
|
|
93
|
+
`recordPreference`) and writes the ledger; it never writes preferences, so it cannot
|
|
94
|
+
amplify its own pattern. The CorrectionAnalyzer that consumes the ledger is
|
|
95
|
+
off-hot-path (weekly cron) and only ROUTES via the existing by-construction
|
|
96
|
+
authority-bounded driver.
|
|
97
|
+
|
|
98
|
+
## 6. External surfaces
|
|
99
|
+
|
|
100
|
+
- **Other agents / install base:** pure additive source + a default-OFF config
|
|
101
|
+
sub-flag (auto-applied via ConfigDefaults; code reads `cl?.selfViolationSignal !==
|
|
102
|
+
true` so an agent whose config lacks the field behaves identically — OFF). The
|
|
103
|
+
optional `violationPattern` is fully back-compatible: shipped `.instar/preferences.json`
|
|
104
|
+
files have no such field and are simply never self-violation-checked (unit-tested
|
|
105
|
+
with a legacy-shaped file). Agent-Awareness + Migration-Parity are handled
|
|
106
|
+
(templates.ts bullet for new agents; idempotent content-sniffed migrateClaudeMd
|
|
107
|
+
backfill for existing agents).
|
|
108
|
+
- **External systems:** none. The detector is local + deterministic; no LLM call, no
|
|
109
|
+
network. (Distinct from the capture/distill loop, which is a separate, already-shipped
|
|
110
|
+
surface.)
|
|
111
|
+
- **Persistent state:** existing `correction-ledger.db` only (one extra occurrence
|
|
112
|
+
row per matched violation, bounded by the shipped per-key occurrence cap). Plus a
|
|
113
|
+
best-effort `[self-violation]` stderr audit line. No new files.
|
|
114
|
+
- **Timing:** none. No timers; the observe call is one bounded synchronous detect plus
|
|
115
|
+
one ledger write, off the delivery path.
|
|
116
|
+
|
|
117
|
+
## 7. Rollback cost
|
|
118
|
+
|
|
119
|
+
Pure additive code + a default-off config sub-flag. Revert the commits → the detector,
|
|
120
|
+
the seam branch, the schema field, the config flag, and the awareness text disappear;
|
|
121
|
+
nothing else changes. Any ledger occurrences already recorded are inert and indexed
|
|
122
|
+
exactly like every other correction record (no schema change to the ledger). No
|
|
123
|
+
migration, no state repair, no user-visible behavior change (it never acted on a
|
|
124
|
+
message).
|
|
125
|
+
|
|
126
|
+
## Conclusion
|
|
127
|
+
|
|
128
|
+
This review confirmed the change is observe-only: a tested, precision-biased,
|
|
129
|
+
never-throwing decision function plus a fire-and-forget recording branch that is
|
|
130
|
+
structurally incapable of blocking, delaying, or altering any outbound message. It
|
|
131
|
+
ships dark behind both `correctionLearning.enabled` and the new `selfViolationSignal`
|
|
132
|
+
sub-flag, is fully back-compatible with existing preference files, and reuses the
|
|
133
|
+
shipped ledger's privacy + dedupe discipline. Clear to ship.
|