instar 1.3.774 → 1.3.776
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/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +222 -1
- package/dist/commands/server.js.map +1 -1
- package/dist/config/ConfigDefaults.d.ts.map +1 -1
- package/dist/config/ConfigDefaults.js +28 -0
- package/dist/config/ConfigDefaults.js.map +1 -1
- package/dist/core/CoherenceJournal.d.ts +1 -1
- package/dist/core/CoherenceJournal.d.ts.map +1 -1
- package/dist/core/CoherenceJournal.js +9 -2
- package/dist/core/CoherenceJournal.js.map +1 -1
- package/dist/core/OrchestratorActuator.d.ts +90 -0
- package/dist/core/OrchestratorActuator.d.ts.map +1 -0
- package/dist/core/OrchestratorActuator.js +88 -0
- package/dist/core/OrchestratorActuator.js.map +1 -0
- package/dist/core/OscillationBreaker.d.ts +46 -0
- package/dist/core/OscillationBreaker.d.ts.map +1 -0
- package/dist/core/OscillationBreaker.js +52 -0
- package/dist/core/OscillationBreaker.js.map +1 -0
- package/dist/core/PostUpdateMigrator.d.ts +1 -0
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +175 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SeamlessOrchestratorEngine.d.ts +167 -0
- package/dist/core/SeamlessOrchestratorEngine.d.ts.map +1 -0
- package/dist/core/SeamlessOrchestratorEngine.js +251 -0
- package/dist/core/SeamlessOrchestratorEngine.js.map +1 -0
- package/dist/core/WorkingSetArtifactManager.d.ts +104 -0
- package/dist/core/WorkingSetArtifactManager.d.ts.map +1 -0
- package/dist/core/WorkingSetArtifactManager.js +174 -0
- package/dist/core/WorkingSetArtifactManager.js.map +1 -0
- package/dist/core/WorkingSetArtifactReplicatedStore.d.ts +203 -0
- package/dist/core/WorkingSetArtifactReplicatedStore.d.ts.map +1 -0
- package/dist/core/WorkingSetArtifactReplicatedStore.js +384 -0
- package/dist/core/WorkingSetArtifactReplicatedStore.js.map +1 -0
- package/dist/core/WorkingSetManifest.d.ts +5 -0
- package/dist/core/WorkingSetManifest.d.ts.map +1 -1
- package/dist/core/WorkingSetManifest.js +10 -0
- package/dist/core/WorkingSetManifest.js.map +1 -1
- package/dist/core/WorkingSetPull.d.ts +5 -0
- package/dist/core/WorkingSetPull.d.ts.map +1 -1
- package/dist/core/WorkingSetPull.js +1 -0
- package/dist/core/WorkingSetPull.js.map +1 -1
- package/dist/core/WriteDomainRegistry.d.ts.map +1 -1
- package/dist/core/WriteDomainRegistry.js +32 -0
- package/dist/core/WriteDomainRegistry.js.map +1 -1
- package/dist/monitoring/OrchestratorPoller.d.ts +64 -0
- package/dist/monitoring/OrchestratorPoller.d.ts.map +1 -0
- package/dist/monitoring/OrchestratorPoller.js +132 -0
- package/dist/monitoring/OrchestratorPoller.js.map +1 -0
- package/dist/server/AgentServer.d.ts +2 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +2 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +12 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +155 -1
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +65 -65
- package/src/templates/hooks/settings-template.json +10 -0
- package/upgrades/1.3.775.md +44 -0
- package/upgrades/1.3.776.md +44 -0
- package/upgrades/side-effects/intelligent-working-set-lazy-sync.md +220 -0
- package/upgrades/side-effects/llm-seamlessness-orchestrator.md +240 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OrchestratorActuator — the guarded actuation layer for the seamless orchestrator
|
|
3
|
+
* (spec: llm-seamlessness-orchestrator.md, Phase 2 + Phase 3 dry-run gate).
|
|
4
|
+
*
|
|
5
|
+
* The engine (SeamlessOrchestratorEngine) PRODUCES proposals; this layer decides whether
|
|
6
|
+
* each one may act, AUDITS the decision BEFORE acting (so a crash mid-action leaves a
|
|
7
|
+
* trace), and — for the ONE ever-auto action, a side-effect-free `auto-prefetch` — executes
|
|
8
|
+
* it via the working-set fetch. A `placement-signal` NEVER moves anything: it only writes
|
|
9
|
+
* structured evidence into the deterministic planner's policy input (the planner alone
|
|
10
|
+
* decides moves, F3).
|
|
11
|
+
*
|
|
12
|
+
* Actuation guards (Design §Actuation guards), applied to EVERY proposal:
|
|
13
|
+
* - Re-validate at execute (compare-and-act): a stale read is never ground truth — live
|
|
14
|
+
* ownership/pin/episode is re-checked here, not trusted from the engine's read time.
|
|
15
|
+
* - Yield to failure-movement: refuse any proposal for a topic in an active stale-owner-
|
|
16
|
+
* release / lease-handback / lease-flap / splitBrain episode (failure movement wins).
|
|
17
|
+
* - Respect pins + provenance: never actuate for a `pinned` or recently-user-moved topic.
|
|
18
|
+
* - Audit-BEFORE-actuate to `logs/orchestrator-actions.jsonl` (machine-local).
|
|
19
|
+
*
|
|
20
|
+
* `auto-prefetch` side-effect-free contract (Design §invariants): bounded by a per-window
|
|
21
|
+
* disk-byte budget; inherits the coordinator's secretFlagged/tooLarge/oversized refusals;
|
|
22
|
+
* only a local copy lands (no ownership/lease mutation). Enforced here via the budget check
|
|
23
|
+
* + the injected fetch seam (which carries the coordinator's own refusals).
|
|
24
|
+
*
|
|
25
|
+
* dryRun (P3 soak): every admissible proposal is logged as `would-actuate` and actuates
|
|
26
|
+
* NOTHING. The dry-run audit trail IS the soak evidence for the operator-only live flip.
|
|
27
|
+
*/
|
|
28
|
+
import type { OrchestratorAction, OrchestratorAuthority, OrchestratorProposal } from './SeamlessOrchestratorEngine.js';
|
|
29
|
+
/** Live placement facts for a topic, re-read at execute time (compare-and-act). */
|
|
30
|
+
export interface TopicPlacementView {
|
|
31
|
+
pinned: boolean;
|
|
32
|
+
/** the topic was moved by the user recently (provenance) — never override a human move. */
|
|
33
|
+
recentlyUserMoved: boolean;
|
|
34
|
+
/** the topic is in an active stale-owner-release / lease-handback / lease-flap / splitBrain episode. */
|
|
35
|
+
inFailureEpisode: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** The outcome of a real working-set fetch (mirrors the coordinator's FetchOutcome shape, loosely). */
|
|
38
|
+
export interface FetchOutcome {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
skipReason?: string;
|
|
41
|
+
bytes?: number;
|
|
42
|
+
}
|
|
43
|
+
/** One machine-local audit row (logs/orchestrator-actions.jsonl). */
|
|
44
|
+
export interface ActuationAuditEntry {
|
|
45
|
+
ts: string;
|
|
46
|
+
action: OrchestratorAction;
|
|
47
|
+
targetTopic: number;
|
|
48
|
+
detail: string;
|
|
49
|
+
authorityLevel: OrchestratorAuthority;
|
|
50
|
+
decision: ActuationDecision;
|
|
51
|
+
refusalReason?: string;
|
|
52
|
+
dryRun: boolean;
|
|
53
|
+
bytes?: number;
|
|
54
|
+
}
|
|
55
|
+
export type ActuationDecision = 'would-actuate' | 'actuated' | 'refused' | 'signal-recorded' | 'would-signal';
|
|
56
|
+
export interface ActuatorDeps {
|
|
57
|
+
/** re-validate at execute (compare-and-act) — live ownership/pin/episode for the topic. */
|
|
58
|
+
revalidate(topic: number): TopicPlacementView;
|
|
59
|
+
/** remaining per-window disk-byte budget for auto-prefetch. */
|
|
60
|
+
budgetRemainingBytes(): number;
|
|
61
|
+
/** estimated bytes a preload would land (from the working-set record size). */
|
|
62
|
+
estimatedBytes(proposal: OrchestratorProposal): number;
|
|
63
|
+
/** the real fetch — invoked ONLY in live mode for an admitted auto-prefetch. Carries the coordinator's refusals. */
|
|
64
|
+
fetchWorkingSet(topic: number): Promise<FetchOutcome>;
|
|
65
|
+
/** write structured evidence into the deterministic planner's policy input (placement-signal, live mode). */
|
|
66
|
+
recordPlacementSignal(proposal: OrchestratorProposal): void;
|
|
67
|
+
/** audit-BEFORE-actuate (machine-local JSONL append). */
|
|
68
|
+
audit(entry: ActuationAuditEntry): void;
|
|
69
|
+
now?: () => string;
|
|
70
|
+
log?: (msg: string) => void;
|
|
71
|
+
config: {
|
|
72
|
+
dryRun: boolean;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface ActuationResult {
|
|
76
|
+
decision: ActuationDecision;
|
|
77
|
+
refusalReason?: string;
|
|
78
|
+
bytes?: number;
|
|
79
|
+
}
|
|
80
|
+
export declare class OrchestratorActuator {
|
|
81
|
+
private readonly d;
|
|
82
|
+
private readonly now;
|
|
83
|
+
private readonly log;
|
|
84
|
+
constructor(deps: ActuatorDeps);
|
|
85
|
+
/** Actuate a single proposal through the guards. Never throws — a guard failure is a refusal. */
|
|
86
|
+
actuate(proposal: OrchestratorProposal): Promise<ActuationResult>;
|
|
87
|
+
private refuse;
|
|
88
|
+
private entry;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=OrchestratorActuator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrchestratorActuator.d.ts","sourceRoot":"","sources":["../../src/core/OrchestratorActuator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvH,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,2FAA2F;IAC3F,iBAAiB,EAAE,OAAO,CAAC;IAC3B,wGAAwG;IACxG,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EA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O,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IA4DvE,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,KAAK;CAmBd"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export class OrchestratorActuator {
|
|
2
|
+
d;
|
|
3
|
+
now;
|
|
4
|
+
log;
|
|
5
|
+
constructor(deps) {
|
|
6
|
+
this.d = deps;
|
|
7
|
+
this.now = deps.now ?? (() => new Date().toISOString());
|
|
8
|
+
this.log = deps.log ?? (() => { });
|
|
9
|
+
}
|
|
10
|
+
/** Actuate a single proposal through the guards. Never throws — a guard failure is a refusal. */
|
|
11
|
+
async actuate(proposal) {
|
|
12
|
+
const dryRun = this.d.config.dryRun;
|
|
13
|
+
// ── Guard 1-3: re-validate at execute (compare-and-act) ──────────────────
|
|
14
|
+
let live;
|
|
15
|
+
try {
|
|
16
|
+
live = this.d.revalidate(proposal.targetTopic);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
// A failed re-validation is a REFUSAL (fail-closed) — never actuate on an unknown state.
|
|
20
|
+
return this.refuse(proposal, `revalidate-failed:${err instanceof Error ? err.message : String(err)}`, dryRun);
|
|
21
|
+
}
|
|
22
|
+
if (live.inFailureEpisode) {
|
|
23
|
+
return this.refuse(proposal, 'yield-to-failure-movement', dryRun); // failure movement wins
|
|
24
|
+
}
|
|
25
|
+
if (live.pinned) {
|
|
26
|
+
return this.refuse(proposal, 'topic-pinned', dryRun);
|
|
27
|
+
}
|
|
28
|
+
if (live.recentlyUserMoved) {
|
|
29
|
+
return this.refuse(proposal, 'respect-user-provenance', dryRun);
|
|
30
|
+
}
|
|
31
|
+
// ── placement-signal: write structured evidence to the planner; never a move ──
|
|
32
|
+
if (proposal.action === 'placement-signal') {
|
|
33
|
+
const decision = dryRun ? 'would-signal' : 'signal-recorded';
|
|
34
|
+
this.d.audit(this.entry(proposal, decision, dryRun));
|
|
35
|
+
if (!dryRun) {
|
|
36
|
+
try {
|
|
37
|
+
this.d.recordPlacementSignal(proposal);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
this.log(`orchestrator: recordPlacementSignal failed (${err instanceof Error ? err.message : String(err)})`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { decision };
|
|
44
|
+
}
|
|
45
|
+
// ── preload-artifact: the side-effect-free auto-prefetch. Budget-bound first. ──
|
|
46
|
+
const need = Math.max(0, this.d.estimatedBytes(proposal));
|
|
47
|
+
if (need > this.d.budgetRemainingBytes()) {
|
|
48
|
+
return this.refuse(proposal, 'disk-byte-budget-exhausted', dryRun);
|
|
49
|
+
}
|
|
50
|
+
if (dryRun) {
|
|
51
|
+
// P3 soak: log the would-actuate + audit; actuate NOTHING.
|
|
52
|
+
this.d.audit(this.entry(proposal, 'would-actuate', true, need));
|
|
53
|
+
return { decision: 'would-actuate', bytes: need };
|
|
54
|
+
}
|
|
55
|
+
// Live: AUDIT BEFORE the fetch (crash-mid-action leaves a trace), then fetch.
|
|
56
|
+
this.d.audit(this.entry(proposal, 'actuated', false, need));
|
|
57
|
+
try {
|
|
58
|
+
const outcome = await this.d.fetchWorkingSet(proposal.targetTopic);
|
|
59
|
+
if (!outcome.ok) {
|
|
60
|
+
// The coordinator refused (secretFlagged/tooLarge/oversized/rate-limited) — a bounded no-op.
|
|
61
|
+
return { decision: 'refused', refusalReason: `fetch-skip:${outcome.skipReason ?? 'unknown'}` };
|
|
62
|
+
}
|
|
63
|
+
return { decision: 'actuated', bytes: outcome.bytes ?? need };
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
this.log(`orchestrator: fetch failed for topic ${proposal.targetTopic} (${err instanceof Error ? err.message : String(err)})`);
|
|
67
|
+
return { decision: 'refused', refusalReason: 'fetch-error' };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
refuse(proposal, reason, dryRun) {
|
|
71
|
+
this.d.audit(this.entry(proposal, 'refused', dryRun, undefined, reason));
|
|
72
|
+
return { decision: 'refused', refusalReason: reason };
|
|
73
|
+
}
|
|
74
|
+
entry(proposal, decision, dryRun, bytes, refusalReason) {
|
|
75
|
+
return {
|
|
76
|
+
ts: this.now(),
|
|
77
|
+
action: proposal.action,
|
|
78
|
+
targetTopic: proposal.targetTopic,
|
|
79
|
+
detail: proposal.detail,
|
|
80
|
+
authorityLevel: proposal.authorityLevel,
|
|
81
|
+
decision,
|
|
82
|
+
refusalReason,
|
|
83
|
+
dryRun,
|
|
84
|
+
bytes,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=OrchestratorActuator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrchestratorActuator.js","sourceRoot":"","sources":["../../src/core/OrchestratorActuator.ts"],"names":[],"mappings":"AAoFA,MAAM,OAAO,oBAAoB;IACd,CAAC,CAAe;IAChB,GAAG,CAAe;IAClB,GAAG,CAAwB;IAE5C,YAAY,IAAkB;QAC5B,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,iGAAiG;IACjG,KAAK,CAAC,OAAO,CAAC,QAA8B;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QAEpC,4EAA4E;QAC5E,IAAI,IAAwB,CAAC;QAC7B,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,yFAAyF;YAC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CAAwC,QAAQ,CAAC,WAAW,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/H,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,QAA8B,EAAE,MAAc,EAAE,MAAe;QAC5E,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QACzE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IACxD,CAAC;IAEO,KAAK,CACX,QAA8B,EAC9B,QAA2B,EAC3B,MAAe,EACf,KAAc,EACd,aAAsB;QAEtB,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,QAAQ;YACR,aAAa;YACb,MAAM;YACN,KAAK;SACN,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OscillationBreaker — the F6 oscillation brake for the seamless orchestrator
|
|
3
|
+
* (spec: llm-seamlessness-orchestrator.md §F6 + Tier-1 "oscillation breaker blacklists + raises one item").
|
|
4
|
+
*
|
|
5
|
+
* A topic that thrashes — ≥ maxActuationsPerWindow actuations inside oscillationWindowMs — is
|
|
6
|
+
* BLACKLISTED for blacklistTtlMs: the engine suppresses it from proposals (via the injected
|
|
7
|
+
* `isBlacklisted` seam) and stops churning it. The blacklist trip is reported ONCE per episode
|
|
8
|
+
* (`recordActuation` returns true exactly on the transition into blacklisted) so the wiring raises
|
|
9
|
+
* exactly ONE deduped attention item, never a per-tick flood (No-Unbounded-Loops / Bounded
|
|
10
|
+
* Notification Surface).
|
|
11
|
+
*
|
|
12
|
+
* Machine-local for the first (dark/dryRun) ship: in dryRun nothing actuates, so the window is
|
|
13
|
+
* always empty and the breaker is inert — it only becomes load-bearing once the operator flips the
|
|
14
|
+
* P4 auto-prefetch increment live. Replicating this blacklist via the WS2 store (so "don't move
|
|
15
|
+
* topic T again" survives a lease failover, spec line 85) is a TRACKED follow-up gated on that same
|
|
16
|
+
* P4-live flip; a machine-local breaker degrades safely (a failover re-learns the thrash) and never
|
|
17
|
+
* moves anything on its own.
|
|
18
|
+
*/
|
|
19
|
+
export interface OscillationBreakerConfig {
|
|
20
|
+
/** actuations within the window that trip the blacklist. Default 3 (spec F6: "3 moves in a window"). */
|
|
21
|
+
maxActuationsPerWindow: number;
|
|
22
|
+
/** the sliding window (ms) over which actuations are counted. Default 1h. */
|
|
23
|
+
oscillationWindowMs: number;
|
|
24
|
+
/** how long a blacklisted topic stays suppressed (ms). Default 24h. */
|
|
25
|
+
blacklistTtlMs: number;
|
|
26
|
+
}
|
|
27
|
+
export declare const DEFAULT_OSCILLATION_CONFIG: OscillationBreakerConfig;
|
|
28
|
+
export declare class OscillationBreaker {
|
|
29
|
+
private readonly cfg;
|
|
30
|
+
private readonly now;
|
|
31
|
+
/** per-topic actuation timestamps (sliding window; pruned on each record/query). */
|
|
32
|
+
private readonly history;
|
|
33
|
+
/** per-topic blacklist-until timestamp. */
|
|
34
|
+
private readonly blacklistedUntil;
|
|
35
|
+
constructor(config?: Partial<OscillationBreakerConfig>, now?: () => number);
|
|
36
|
+
/**
|
|
37
|
+
* Record an actuation for a topic. Returns TRUE only on the transition INTO blacklisted
|
|
38
|
+
* (so the caller raises exactly one attention item per episode); false otherwise.
|
|
39
|
+
*/
|
|
40
|
+
recordActuation(topic: number, at?: number): boolean;
|
|
41
|
+
/** True while the topic's blacklist window is active (expired entries self-clear). */
|
|
42
|
+
isBlacklisted(topic: number, at?: number): boolean;
|
|
43
|
+
/** The currently-blacklisted topics (for the /audit surface). */
|
|
44
|
+
blacklistedTopics(at?: number): number[];
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=OscillationBreaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OscillationBreaker.d.ts","sourceRoot":"","sources":["../../src/core/OscillationBreaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,wBAAwB;IACvC,wGAAwG;IACxG,sBAAsB,EAAE,MAAM,CAAC;IAC/B,6EAA6E;IAC7E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,0BAA0B,EAAE,wBAIxC,CAAC;AAEF,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA2B;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IACvD,2CAA2C;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;gBAElD,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,MAAM;IAK1E;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAepD,sFAAsF;IACtF,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAQlD,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;CAIzC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const DEFAULT_OSCILLATION_CONFIG = {
|
|
2
|
+
maxActuationsPerWindow: 3,
|
|
3
|
+
oscillationWindowMs: 60 * 60_000,
|
|
4
|
+
blacklistTtlMs: 24 * 60 * 60_000,
|
|
5
|
+
};
|
|
6
|
+
export class OscillationBreaker {
|
|
7
|
+
cfg;
|
|
8
|
+
now;
|
|
9
|
+
/** per-topic actuation timestamps (sliding window; pruned on each record/query). */
|
|
10
|
+
history = new Map();
|
|
11
|
+
/** per-topic blacklist-until timestamp. */
|
|
12
|
+
blacklistedUntil = new Map();
|
|
13
|
+
constructor(config, now) {
|
|
14
|
+
this.cfg = { ...DEFAULT_OSCILLATION_CONFIG, ...config };
|
|
15
|
+
this.now = now ?? (() => Date.now());
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Record an actuation for a topic. Returns TRUE only on the transition INTO blacklisted
|
|
19
|
+
* (so the caller raises exactly one attention item per episode); false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
recordActuation(topic, at) {
|
|
22
|
+
const t = at ?? this.now();
|
|
23
|
+
const cutoff = t - this.cfg.oscillationWindowMs;
|
|
24
|
+
const times = (this.history.get(topic) ?? []).filter((ts) => ts > cutoff);
|
|
25
|
+
times.push(t);
|
|
26
|
+
this.history.set(topic, times);
|
|
27
|
+
const already = this.isBlacklisted(topic, t);
|
|
28
|
+
if (!already && times.length >= this.cfg.maxActuationsPerWindow) {
|
|
29
|
+
this.blacklistedUntil.set(topic, t + this.cfg.blacklistTtlMs);
|
|
30
|
+
return true; // the one-shot trip signal
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
/** True while the topic's blacklist window is active (expired entries self-clear). */
|
|
35
|
+
isBlacklisted(topic, at) {
|
|
36
|
+
const until = this.blacklistedUntil.get(topic);
|
|
37
|
+
if (until === undefined)
|
|
38
|
+
return false;
|
|
39
|
+
const t = at ?? this.now();
|
|
40
|
+
if (t >= until) {
|
|
41
|
+
this.blacklistedUntil.delete(topic);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/** The currently-blacklisted topics (for the /audit surface). */
|
|
47
|
+
blacklistedTopics(at) {
|
|
48
|
+
const t = at ?? this.now();
|
|
49
|
+
return [...this.blacklistedUntil.keys()].filter((topic) => this.isBlacklisted(topic, t));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=OscillationBreaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OscillationBreaker.js","sourceRoot":"","sources":["../../src/core/OscillationBreaker.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,0BAA0B,GAA6B;IAClE,sBAAsB,EAAE,CAAC;IACzB,mBAAmB,EAAE,EAAE,GAAG,MAAM;IAChC,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM;CACjC,CAAC;AAEF,MAAM,OAAO,kBAAkB;IACZ,GAAG,CAA2B;IAC9B,GAAG,CAAe;IACnC,oFAAoF;IACnE,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,2CAA2C;IAC1B,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE9D,YAAY,MAA0C,EAAE,GAAkB;QACxE,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,0BAA0B,EAAE,GAAG,MAAM,EAAE,CAAC;QACxD,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,KAAa,EAAE,EAAW;QACxC,MAAM,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAChD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,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K,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3F,CAAC;CACF"}
|
|
@@ -1064,6 +1064,7 @@ export declare class PostUpdateMigrator {
|
|
|
1064
1064
|
private getPostActionReflectionHook;
|
|
1065
1065
|
private getExternalCommunicationGuardHook;
|
|
1066
1066
|
private getActionClaimFollowthroughHook;
|
|
1067
|
+
private getWorkingSetArtifactRecorderHook;
|
|
1067
1068
|
private getPrHandLeaseGuardHook;
|
|
1068
1069
|
private getDoorwayScanGuardHook;
|
|
1069
1070
|
private getExternalOperationGateHook;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostUpdateMigrator.d.ts","sourceRoot":"","sources":["../../src/core/PostUpdateMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AA0CH,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAUjC;;;;;;GAMG;AACH,wBAAgB,wCAAwC,IAAI,MAAM,CAQjE;AAED,wBAAgB,iCAAiC,IAAI,MAAM,CAO1D;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQjE;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASlE;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQrE;AAED,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUvE;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMrE;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO1E;AAED,wBAAgB,4CAA4C,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAcjF;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,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,CAAC,+BAA+B;IAkFvC,OAAO,CAAC,iCAAiC;IAkFzC,OAAO,CAAC,uBAAuB;IA0F/B,OAAO,CAAC,uBAAuB;IAgL/B,OAAO,CAAC,4BAA4B;IA+MpC;;;;;;;;;;OAUG;IACH;;;;;;;;;;;OAWG;IAEH,gBAAuB,iCAAiC,EAAE,WAAW,CAAC,MAAM,CAAC,CAkD1E;IAEH;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,8BAA8B;IAiHtC,OAAO,CAAC,uBAAuB;IAwD/B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,sBAAsB;IAwC9B,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,8BAA8B;IA6HtC,OAAO,CAAC,+BAA+B;IAuKvC,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,qBAAqB;IAqO7B,OAAO,CAAC,qBAAqB;IAwI7B,OAAO,CAAC,qBAAqB;IA8Q7B,OAAO,CAAC,6BAA6B;IAkLrC,OAAO,CAAC,0BAA0B;IAiClC,OAAO,CAAC,0BAA0B;IA8ElC,OAAO,CAAC,0BAA0B;IA8IlC,OAAO,CAAC,gBAAgB;IAmJxB,OAAO,CAAC,6BAA6B;CAoCtC"}
|
|
@@ -3627,6 +3627,13 @@ export class PostUpdateMigrator {
|
|
|
3627
3627
|
catch (err) {
|
|
3628
3628
|
result.errors.push(`pr-hand-lease-guard.js: ${err instanceof Error ? err.message : String(err)}`);
|
|
3629
3629
|
}
|
|
3630
|
+
try {
|
|
3631
|
+
fs.writeFileSync(path.join(instarHooksDir, 'working-set-artifact-recorder.js'), this.getWorkingSetArtifactRecorderHook(), { mode: 0o755 });
|
|
3632
|
+
result.upgraded.push('hooks/instar/working-set-artifact-recorder.js (interactive working-set artifact recorder, PostToolUse Write/Edit, fire-and-forget, dark by default)');
|
|
3633
|
+
}
|
|
3634
|
+
catch (err) {
|
|
3635
|
+
result.errors.push(`working-set-artifact-recorder.js: ${err instanceof Error ? err.message : String(err)}`);
|
|
3636
|
+
}
|
|
3630
3637
|
try {
|
|
3631
3638
|
fs.writeFileSync(path.join(instarHooksDir, 'doorway-scan-guard.js'), this.getDoorwayScanGuardHook(), { mode: 0o755 });
|
|
3632
3639
|
result.upgraded.push('hooks/instar/doorway-scan-guard.js (doorway-scan command-allowlist guard, PreToolUse Bash, scope-fail-open/match-fail-closed)');
|
|
@@ -8286,6 +8293,32 @@ Two layers keep my machine-to-machine \"ropes\" (Tailscale / LAN / Cloudflare) h
|
|
|
8286
8293
|
else {
|
|
8287
8294
|
result.skipped.push('.claude/settings.json: PreToolUse MCP matcher already present');
|
|
8288
8295
|
}
|
|
8296
|
+
// Add PostToolUse Write/Edit matcher for the working-set artifact recorder
|
|
8297
|
+
// (intelligent-working-set-lazy-sync F8). Fire-and-forget + non-blocking; the
|
|
8298
|
+
// hook itself early-exits fast when the feature is off (dark by default:
|
|
8299
|
+
// coherenceJournal.workingSet.recordInteractive), so a default install pays only
|
|
8300
|
+
// a quick no-op node spawn. Idempotent (keyed on the script name).
|
|
8301
|
+
if (!hooks.PostToolUse) {
|
|
8302
|
+
hooks.PostToolUse = [];
|
|
8303
|
+
}
|
|
8304
|
+
const postToolUseRec = hooks.PostToolUse;
|
|
8305
|
+
this.migrateSettingsHookPaths(postToolUseRec, result);
|
|
8306
|
+
const hasWsRecorder = postToolUseRec.some(e => e.hooks?.some(h => h.command?.includes('working-set-artifact-recorder.js')));
|
|
8307
|
+
if (!hasWsRecorder) {
|
|
8308
|
+
postToolUseRec.push({
|
|
8309
|
+
matcher: 'Write|Edit|MultiEdit',
|
|
8310
|
+
hooks: [{
|
|
8311
|
+
type: 'command',
|
|
8312
|
+
command: 'node ${CLAUDE_PROJECT_DIR}/.instar/hooks/instar/working-set-artifact-recorder.js',
|
|
8313
|
+
timeout: 5000,
|
|
8314
|
+
}],
|
|
8315
|
+
});
|
|
8316
|
+
patched = true;
|
|
8317
|
+
result.upgraded.push('.claude/settings.json: added PostToolUse Write/Edit matcher (working-set artifact recorder)');
|
|
8318
|
+
}
|
|
8319
|
+
else {
|
|
8320
|
+
result.skipped.push('.claude/settings.json: PostToolUse working-set recorder already present');
|
|
8321
|
+
}
|
|
8289
8322
|
// Clean up legacy PostToolUse session-start (was noisy — fired every tool use)
|
|
8290
8323
|
if (hooks.PostToolUse) {
|
|
8291
8324
|
const postToolUse = hooks.PostToolUse;
|
|
@@ -9855,6 +9888,35 @@ except Exception:
|
|
|
9855
9888
|
fi
|
|
9856
9889
|
fi
|
|
9857
9890
|
|
|
9891
|
+
# WORKING-SET ARTIFACT grounding (spec: intelligent-working-set-lazy-sync.md, Layer-3 /
|
|
9892
|
+
# Component6). Fetches /coherence/working-set/session-context for THIS topic and injects the
|
|
9893
|
+
# <replicated-untrusted-data source="working-set-artifacts"> block so the agent is GROUNDED
|
|
9894
|
+
# that interactive artifacts it recorded for this conversation exist (the whole point on a
|
|
9895
|
+
# topic-move: "you wrote these; re-verify/fetch them"). ADVISORY ONLY — a path is untrusted
|
|
9896
|
+
# data, never an instruction. Fail-open: no topic / route 503 (feature dark / manager unwired) /
|
|
9897
|
+
# no ready artifacts (present:false) / unreachable -> silent skip; -sf makes a non-2xx emit
|
|
9898
|
+
# nothing, so an absent/empty/oversized manifest degrades to no-block.
|
|
9899
|
+
if [ -n "\$INSTAR_TELEGRAM_TOPIC" ] && [ -n "\$PORT" ] && [ -n "\$TOKEN" ]; then
|
|
9900
|
+
WS_ART_RESPONSE=\$(curl -sf --max-time 4 -H "Authorization: Bearer \$TOKEN" \\
|
|
9901
|
+
"http://localhost:\${PORT}/coherence/working-set/session-context?topic=\${INSTAR_TELEGRAM_TOPIC}" 2>/dev/null)
|
|
9902
|
+
if [ -n "\$WS_ART_RESPONSE" ]; then
|
|
9903
|
+
WS_ART_BLOCK=\$(echo "\$WS_ART_RESPONSE" | python3 -c "
|
|
9904
|
+
import sys, json
|
|
9905
|
+
try:
|
|
9906
|
+
d = json.load(sys.stdin)
|
|
9907
|
+
if d.get('present') and d.get('block'):
|
|
9908
|
+
print(d['block'])
|
|
9909
|
+
except Exception:
|
|
9910
|
+
pass
|
|
9911
|
+
" 2>/dev/null)
|
|
9912
|
+
if [ -n "\$WS_ART_BLOCK" ]; then
|
|
9913
|
+
echo ""
|
|
9914
|
+
echo "\$WS_ART_BLOCK"
|
|
9915
|
+
echo ""
|
|
9916
|
+
fi
|
|
9917
|
+
fi
|
|
9918
|
+
fi
|
|
9919
|
+
|
|
9858
9920
|
# SESSION BOOT SELF-KNOWLEDGE injection (spec: session-boot-self-knowledge.md).
|
|
9859
9921
|
# Fetches /self-knowledge/session-context and injects the deterministic "what I
|
|
9860
9922
|
# already have" block: vault secret NAMES (never values) + self-asserted
|
|
@@ -11081,6 +11143,38 @@ except Exception:
|
|
|
11081
11143
|
fi
|
|
11082
11144
|
fi
|
|
11083
11145
|
|
|
11146
|
+
# WORKING-SET ARTIFACT grounding twin (Compaction Parity — intelligent-working-set-lazy-sync
|
|
11147
|
+
# Layer-3). Mirrors the session-start injection so after a compaction the agent is RE-grounded
|
|
11148
|
+
# on the interactive artifacts it recorded for this conversation. ADVISORY only (a path is
|
|
11149
|
+
# untrusted data). Fail-open: no topic / 503 (feature dark) / no ready artifacts / unreachable -> skip.
|
|
11150
|
+
if [ -n "\$INSTAR_TELEGRAM_TOPIC" ] && [ -f "$INSTAR_DIR/config.json" ]; then
|
|
11151
|
+
WS_ART_PORT=\${PORT:-\$(grep -oE '"port"[[:space:]]*:[[:space:]]*[0-9]+' "$INSTAR_DIR/config.json" | head -1 | grep -oE '[0-9]+' | head -1)}
|
|
11152
|
+
WS_ART_TOKEN="\${INSTAR_AUTH_TOKEN:-}"
|
|
11153
|
+
if [ -z "\$WS_ART_TOKEN" ]; then
|
|
11154
|
+
WS_ART_TOKEN=\$(python3 -c "import json; v=json.load(open('$INSTAR_DIR/config.json')).get('authToken',''); print(v if isinstance(v, str) else '')" 2>/dev/null)
|
|
11155
|
+
fi
|
|
11156
|
+
if [ -n "\$WS_ART_PORT" ] && [ -n "\$WS_ART_TOKEN" ]; then
|
|
11157
|
+
WS_ART_RESPONSE=\$(curl -sf --max-time 4 --connect-timeout 1 -H "Authorization: Bearer \$WS_ART_TOKEN" \\
|
|
11158
|
+
"http://localhost:\${WS_ART_PORT}/coherence/working-set/session-context?topic=\${INSTAR_TELEGRAM_TOPIC}" 2>/dev/null)
|
|
11159
|
+
if [ -n "\$WS_ART_RESPONSE" ]; then
|
|
11160
|
+
WS_ART_BLOCK=\$(echo "\$WS_ART_RESPONSE" | python3 -c "
|
|
11161
|
+
import sys, json
|
|
11162
|
+
try:
|
|
11163
|
+
d = json.load(sys.stdin)
|
|
11164
|
+
if d.get('present') and d.get('block'):
|
|
11165
|
+
print(d['block'])
|
|
11166
|
+
except Exception:
|
|
11167
|
+
pass
|
|
11168
|
+
" 2>/dev/null)
|
|
11169
|
+
if [ -n "\$WS_ART_BLOCK" ]; then
|
|
11170
|
+
echo ""
|
|
11171
|
+
echo "\$WS_ART_BLOCK"
|
|
11172
|
+
echo ""
|
|
11173
|
+
fi
|
|
11174
|
+
fi
|
|
11175
|
+
fi
|
|
11176
|
+
fi
|
|
11177
|
+
|
|
11084
11178
|
echo "=== END IDENTITY RECOVERY ==="
|
|
11085
11179
|
`;
|
|
11086
11180
|
}
|
|
@@ -11848,6 +11942,87 @@ process.stdin.on('end', async () => {
|
|
|
11848
11942
|
}
|
|
11849
11943
|
process.exit(0); // ALWAYS exit 0 — never block a turn
|
|
11850
11944
|
});
|
|
11945
|
+
`;
|
|
11946
|
+
}
|
|
11947
|
+
getWorkingSetArtifactRecorderHook() {
|
|
11948
|
+
return `#!/usr/bin/env node
|
|
11949
|
+
// Working-Set Artifact Recorder — PostToolUse Write/Edit hook (spec: intelligent-working-set-lazy-sync.md, F8).
|
|
11950
|
+
//
|
|
11951
|
+
// SIGNAL-ONLY / fire-and-forget: on a SUCCESSFUL Write/Edit/MultiEdit under the .instar/ jail,
|
|
11952
|
+
// POSTs {topicId, relPath} to the server's POST /coherence/working-set/record so the INTERACTIVE
|
|
11953
|
+
// artifact (a file the agent wrote conversationally, with NO autonomous run) enters the computed
|
|
11954
|
+
// working-set manifest — the exact case WorkingSetManifest.computeWorkingSet misses. It NEVER
|
|
11955
|
+
// blocks — ALWAYS exit(0), pass or fail. Records NOTHING for a file OUTSIDE the .instar/ jail
|
|
11956
|
+
// (project files are git-synced; F10) or when the feature is off (code-default OFF ⇒ dark:
|
|
11957
|
+
// coherenceJournal.workingSet.recordInteractive). relPath is stateDir-relative + forward-slash
|
|
11958
|
+
// normalized — the exact convention computeWorkingSet Source-3 resolves (path.resolve(stateDir,rel)).
|
|
11959
|
+
//
|
|
11960
|
+
// ESM-safe: node: imports INSIDE the async handler (works in BOTH CJS and ESM host agents); a
|
|
11961
|
+
// bare top-level require(...) crashes an ESM-mode agent — see the 2026-05-27 silent-stall postmortem.
|
|
11962
|
+
|
|
11963
|
+
let data = '';
|
|
11964
|
+
process.stdin.on('data', (chunk) => (data += chunk));
|
|
11965
|
+
process.stdin.on('end', async () => {
|
|
11966
|
+
try {
|
|
11967
|
+
const { readFileSync } = await import('node:fs');
|
|
11968
|
+
const { join, resolve, relative, isAbsolute } = await import('node:path');
|
|
11969
|
+
|
|
11970
|
+
const projectDir = process.env.CLAUDE_PROJECT_DIR || '.';
|
|
11971
|
+
let serverPort = 4040;
|
|
11972
|
+
let authToken = '';
|
|
11973
|
+
let enabled = false;
|
|
11974
|
+
try {
|
|
11975
|
+
const cfg = JSON.parse(readFileSync(join(projectDir, '.instar', 'config.json'), 'utf-8'));
|
|
11976
|
+
serverPort = cfg.port || 4040;
|
|
11977
|
+
authToken = cfg.authToken || '';
|
|
11978
|
+
enabled = !!(cfg.coherenceJournal && cfg.coherenceJournal.workingSet && cfg.coherenceJournal.workingSet.recordInteractive);
|
|
11979
|
+
} catch {}
|
|
11980
|
+
if (!enabled) process.exit(0);
|
|
11981
|
+
|
|
11982
|
+
const input = JSON.parse(data);
|
|
11983
|
+
const tool = input.tool_name || '';
|
|
11984
|
+
if (tool !== 'Write' && tool !== 'Edit' && tool !== 'MultiEdit') process.exit(0);
|
|
11985
|
+
// A failed tool-call records nothing (F8) — deletes are NOT inferred from a write.
|
|
11986
|
+
const resp = input.tool_response;
|
|
11987
|
+
if (resp && (resp.error || resp.success === false)) process.exit(0);
|
|
11988
|
+
|
|
11989
|
+
const filePath = input.tool_input && input.tool_input.file_path;
|
|
11990
|
+
if (!filePath || typeof filePath !== 'string') process.exit(0);
|
|
11991
|
+
|
|
11992
|
+
// Conversation id — key from INSTAR_CONVERSATION_ID ONLY (a shared/lifeline session carries
|
|
11993
|
+
// none → records nothing, a safe miss). Number.isFinite admits a minted-negative (Slack) id.
|
|
11994
|
+
const topicRaw = process.env.INSTAR_CONVERSATION_ID;
|
|
11995
|
+
if (!topicRaw) process.exit(0);
|
|
11996
|
+
const topicId = parseInt(topicRaw, 10);
|
|
11997
|
+
if (!Number.isFinite(topicId)) process.exit(0);
|
|
11998
|
+
|
|
11999
|
+
// Derive relPath vs the .instar/ jail (stateDir-relative). Outside the jail ⇒ skip (F10).
|
|
12000
|
+
const stateDir = resolve(projectDir, '.instar');
|
|
12001
|
+
const rawRel = relative(stateDir, resolve(filePath));
|
|
12002
|
+
if (!rawRel || rawRel.startsWith('..') || isAbsolute(rawRel)) process.exit(0);
|
|
12003
|
+
const segs = rawRel.split(/[/\\\\]+/);
|
|
12004
|
+
if (segs.includes('.git')) process.exit(0); // never a git internal
|
|
12005
|
+
const relPath = segs.join('/'); // forward-slash normalized for cross-machine identity
|
|
12006
|
+
|
|
12007
|
+
const controller = new AbortController();
|
|
12008
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
12009
|
+
try {
|
|
12010
|
+
await fetch('http://127.0.0.1:' + serverPort + '/coherence/working-set/record', {
|
|
12011
|
+
method: 'POST',
|
|
12012
|
+
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + authToken },
|
|
12013
|
+
body: JSON.stringify({ topicId, relPath }),
|
|
12014
|
+
signal: controller.signal,
|
|
12015
|
+
});
|
|
12016
|
+
} catch {
|
|
12017
|
+
// network/timeout — fire-and-forget, ignore
|
|
12018
|
+
} finally {
|
|
12019
|
+
clearTimeout(timeout);
|
|
12020
|
+
}
|
|
12021
|
+
} catch {
|
|
12022
|
+
// bad stdin — ignore
|
|
12023
|
+
}
|
|
12024
|
+
process.exit(0); // ALWAYS exit 0 — never block a tool
|
|
12025
|
+
});
|
|
11851
12026
|
`;
|
|
11852
12027
|
}
|
|
11853
12028
|
getPrHandLeaseGuardHook() {
|