instar 1.3.830 → 1.3.831

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 (108) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +83 -12
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/AutonomousRealCheckAnnotator.d.ts +105 -0
  5. package/dist/core/AutonomousRealCheckAnnotator.d.ts.map +1 -0
  6. package/dist/core/AutonomousRealCheckAnnotator.js +122 -0
  7. package/dist/core/AutonomousRealCheckAnnotator.js.map +1 -0
  8. package/dist/core/AutonomousRunStore.d.ts +29 -0
  9. package/dist/core/AutonomousRunStore.d.ts.map +1 -1
  10. package/dist/core/AutonomousRunStore.js +38 -0
  11. package/dist/core/AutonomousRunStore.js.map +1 -1
  12. package/dist/core/BackupManager.d.ts.map +1 -1
  13. package/dist/core/BackupManager.js +47 -1
  14. package/dist/core/BackupManager.js.map +1 -1
  15. package/dist/core/CircuitBreakingIntelligenceProvider.d.ts +12 -0
  16. package/dist/core/CircuitBreakingIntelligenceProvider.d.ts.map +1 -1
  17. package/dist/core/CircuitBreakingIntelligenceProvider.js +56 -4
  18. package/dist/core/CircuitBreakingIntelligenceProvider.js.map +1 -1
  19. package/dist/core/CompletionEvaluator.d.ts +62 -2
  20. package/dist/core/CompletionEvaluator.d.ts.map +1 -1
  21. package/dist/core/CompletionEvaluator.js +124 -6
  22. package/dist/core/CompletionEvaluator.js.map +1 -1
  23. package/dist/core/DecisionQualityRecorderImpl.d.ts +192 -0
  24. package/dist/core/DecisionQualityRecorderImpl.d.ts.map +1 -0
  25. package/dist/core/DecisionQualityRecorderImpl.js +363 -0
  26. package/dist/core/DecisionQualityRecorderImpl.js.map +1 -0
  27. package/dist/core/IntelligenceRouter.d.ts +33 -0
  28. package/dist/core/IntelligenceRouter.d.ts.map +1 -1
  29. package/dist/core/IntelligenceRouter.js +240 -54
  30. package/dist/core/IntelligenceRouter.js.map +1 -1
  31. package/dist/core/JudgmentProvenanceLog.d.ts +102 -2
  32. package/dist/core/JudgmentProvenanceLog.d.ts.map +1 -1
  33. package/dist/core/JudgmentProvenanceLog.js +239 -11
  34. package/dist/core/JudgmentProvenanceLog.js.map +1 -1
  35. package/dist/core/PostUpdateMigrator.d.ts +11 -0
  36. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  37. package/dist/core/PostUpdateMigrator.js +32 -0
  38. package/dist/core/PostUpdateMigrator.js.map +1 -1
  39. package/dist/core/WriteDomainRegistry.d.ts.map +1 -1
  40. package/dist/core/WriteDomainRegistry.js +24 -0
  41. package/dist/core/WriteDomainRegistry.js.map +1 -1
  42. package/dist/core/decisionGradingPass.d.ts +69 -0
  43. package/dist/core/decisionGradingPass.d.ts.map +1 -0
  44. package/dist/core/decisionGradingPass.js +151 -0
  45. package/dist/core/decisionGradingPass.js.map +1 -0
  46. package/dist/core/decisionQualityTypes.d.ts +170 -0
  47. package/dist/core/decisionQualityTypes.d.ts.map +1 -0
  48. package/dist/core/decisionQualityTypes.js +85 -0
  49. package/dist/core/decisionQualityTypes.js.map +1 -0
  50. package/dist/core/devGatedFeatures.d.ts.map +1 -1
  51. package/dist/core/devGatedFeatures.js +6 -0
  52. package/dist/core/devGatedFeatures.js.map +1 -1
  53. package/dist/core/machineCoherenceManifest.d.ts.map +1 -1
  54. package/dist/core/machineCoherenceManifest.js +4 -0
  55. package/dist/core/machineCoherenceManifest.js.map +1 -1
  56. package/dist/core/types.d.ts +69 -4
  57. package/dist/core/types.d.ts.map +1 -1
  58. package/dist/core/types.js.map +1 -1
  59. package/dist/data/provenanceCoverage.d.ts +150 -0
  60. package/dist/data/provenanceCoverage.d.ts.map +1 -0
  61. package/dist/data/provenanceCoverage.js +649 -0
  62. package/dist/data/provenanceCoverage.js.map +1 -0
  63. package/dist/monitoring/ExternalHogDecisionStore.d.ts +256 -0
  64. package/dist/monitoring/ExternalHogDecisionStore.d.ts.map +1 -0
  65. package/dist/monitoring/ExternalHogDecisionStore.js +481 -0
  66. package/dist/monitoring/ExternalHogDecisionStore.js.map +1 -0
  67. package/dist/monitoring/ExternalHogRealAdapters.d.ts +6 -2
  68. package/dist/monitoring/ExternalHogRealAdapters.d.ts.map +1 -1
  69. package/dist/monitoring/ExternalHogRealAdapters.js +2 -2
  70. package/dist/monitoring/ExternalHogRealAdapters.js.map +1 -1
  71. package/dist/monitoring/ExternalHogScanTick.d.ts +95 -3
  72. package/dist/monitoring/ExternalHogScanTick.d.ts.map +1 -1
  73. package/dist/monitoring/ExternalHogScanTick.js +102 -9
  74. package/dist/monitoring/ExternalHogScanTick.js.map +1 -1
  75. package/dist/monitoring/ExternalHogSentinel.d.ts +71 -3
  76. package/dist/monitoring/ExternalHogSentinel.d.ts.map +1 -1
  77. package/dist/monitoring/ExternalHogSentinel.js +126 -2
  78. package/dist/monitoring/ExternalHogSentinel.js.map +1 -1
  79. package/dist/monitoring/ExternalHogServerPrimitives.d.ts +10 -2
  80. package/dist/monitoring/ExternalHogServerPrimitives.d.ts.map +1 -1
  81. package/dist/monitoring/ExternalHogServerPrimitives.js +1 -1
  82. package/dist/monitoring/ExternalHogServerPrimitives.js.map +1 -1
  83. package/dist/monitoring/FeatureMetricsLedger.d.ts +304 -0
  84. package/dist/monitoring/FeatureMetricsLedger.d.ts.map +1 -1
  85. package/dist/monitoring/FeatureMetricsLedger.js +731 -0
  86. package/dist/monitoring/FeatureMetricsLedger.js.map +1 -1
  87. package/dist/scaffold/templates.d.ts.map +1 -1
  88. package/dist/scaffold/templates.js +2 -1
  89. package/dist/scaffold/templates.js.map +1 -1
  90. package/dist/server/AgentServer.d.ts.map +1 -1
  91. package/dist/server/AgentServer.js +55 -1
  92. package/dist/server/AgentServer.js.map +1 -1
  93. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  94. package/dist/server/CapabilityIndex.js +15 -1
  95. package/dist/server/CapabilityIndex.js.map +1 -1
  96. package/dist/server/fileRoutes.d.ts.map +1 -1
  97. package/dist/server/fileRoutes.js +9 -0
  98. package/dist/server/fileRoutes.js.map +1 -1
  99. package/dist/server/routes.d.ts.map +1 -1
  100. package/dist/server/routes.js +334 -5
  101. package/dist/server/routes.js.map +1 -1
  102. package/package.json +1 -1
  103. package/src/data/builtin-manifest.json +65 -65
  104. package/src/data/provenanceCoverage.ts +823 -0
  105. package/src/scaffold/templates/jobs/instar/llm-decision-grading.md +32 -0
  106. package/src/scaffold/templates.ts +2 -1
  107. package/upgrades/1.3.831.md +30 -0
  108. package/upgrades/side-effects/llm-decision-quality-meter.md +95 -0
@@ -0,0 +1,192 @@
1
+ /**
2
+ * DecisionQualityRecorderImpl — the concrete decision-quality substrate behind
3
+ * the router's settlement seam (llm-decision-quality-meter §5.2/§5.4/§5.5).
4
+ *
5
+ * Two write paths live here, both observe-only (never gate, never throw into
6
+ * the path they observe):
7
+ *
8
+ * 1. `recordSettlement` (the DecisionQualityRecorder contract, §5.1.5/FD7):
9
+ * consumes the router's write-once DecisionSettlement. For every ENROLLED
10
+ * settled decision it ALWAYS writes the ~250-byte content-free
11
+ * `decision_quality` row (regardless of volume class — outcome rows always
12
+ * have parents, counts are complete), validates the decision point against
13
+ * the census (unknown → counted, row still written with the raw point id),
14
+ * and writes the provenance JSONL row under the census VOLUME VALVE
15
+ * (`full` always / `sampled:<rate>` deterministic FNV-1a on the correlation
16
+ * id / `budget:<rows/day>` indexed COUNT since UTC-day start with a loud
17
+ * droppedByBudget counter).
18
+ *
19
+ * 2. `annotateOutcome` (the §5.4 write-integrity CHOKEPOINT): the ONE path an
20
+ * outcome annotation takes into the substrate. Keyed on the correlation id;
21
+ * rung + evidence strength are DERIVED from the registered evidence rule —
22
+ * never caller-supplied — and the chokepoint REJECTS + COUNTS: an invalid
23
+ * grade enum, a rung mismatch (incl. an unregistered ruleId — DC r7), an
24
+ * owner mismatch (gradedBy.component ≠ the rule's registered owning
25
+ * component — ADV r5), and an unknown decision point. Accepted outcomes
26
+ * land via `ledger.upsertOutcome` (idempotent on correlationId × gradedBy)
27
+ * plus a JPL outcome trail row. The evidence RULES themselves (what grade a
28
+ * respawn/realcheck proves) belong to their owning components — this module
29
+ * only enforces the write-integrity contract.
30
+ *
31
+ * Gating (§5.7/FD6): `provenance.uniformSeam.enabled` resolves via
32
+ * `resolveDevAgentGate` (LIVE on a development agent, DARK on the fleet;
33
+ * omit-required — never seeded). `dryRun` defaults TRUE: metadata-only
34
+ * would-write log lines (component, decisionPoint, byte sizes — NEVER context
35
+ * content), with BOTH durable writes suppressed (§5.2).
36
+ */
37
+ import type { DecisionSettlement, DecisionQualityRecorder } from './decisionQualityTypes.js';
38
+ import type { FeatureMetricsLedger } from '../monitoring/FeatureMetricsLedger.js';
39
+ import type { JudgmentProvenanceLog } from './JudgmentProvenanceLog.js';
40
+ import { getCensusEntry, getVolumeClass, getRule } from '../data/provenanceCoverage.js';
41
+ /** Outcome evidence-note hard bound (§5.2/§5.5 — clamped at annotate time, before storage). */
42
+ export declare const EVIDENCE_NOTE_CLAMP = 500;
43
+ export interface DecisionAnnotationRejectionCounters {
44
+ /** Annotations whose grade failed the FD3 enum (right|wrong|unknown). */
45
+ enumInvalid: number;
46
+ /** Unregistered ruleId, or a claimed rung disagreeing with the registry (§5.4.2). */
47
+ rungMismatch: number;
48
+ /** gradedBy.component ≠ the ruleId's registered owning component (ADV r5). */
49
+ ownerMismatch: number;
50
+ /** Census misses: settlement writes for undeclared points + annotations claiming one (§5.1.4/DC r7). */
51
+ unknownDecisionPoint: number;
52
+ }
53
+ /** The four §5.5 rejection-class counters (P10's route surface). */
54
+ export declare function getDecisionAnnotationRejectionCounters(): Readonly<DecisionAnnotationRejectionCounters>;
55
+ /** Test-only seam (the _resetDecisionQualityForTest precedent). */
56
+ export declare function _resetDecisionAnnotationRejectionCountersForTest(): void;
57
+ export type AnnotationRejectionClass = 'enum-invalid' | 'rung-mismatch' | 'owner-mismatch' | 'unknown-decision-point';
58
+ export interface DecisionOutcomeAnnotationInput {
59
+ /** The §5.1 correlation id the outcome joins its decision on (§5.4.1). */
60
+ correlationId: string;
61
+ /** Registered, immutable, versioned evidence-rule id (§5.4.5). */
62
+ ruleId: string;
63
+ /** The grading component — MUST be the ruleId's registered owner (ADV r5). */
64
+ gradedBy: {
65
+ component: string;
66
+ };
67
+ /** FD3 grade — validated against the closed enum at the chokepoint. */
68
+ grade: string;
69
+ /**
70
+ * Optional rung CLAIM. The effective rung is ALWAYS derived from the
71
+ * registry; a supplied claim that disagrees is rejected (§5.4.2 — "an
72
+ * annotation claiming a ruleId whose registered rung disagrees").
73
+ */
74
+ claimedRung?: string;
75
+ /** ≤500 scrubbed chars, pointer-disciplined; NEVER served by /decision-quality. */
76
+ evidenceNote?: string;
77
+ /** Structured evidence (ids/hashes/enums) for the JPL outcome trail row. */
78
+ evidence?: Record<string, unknown>;
79
+ /**
80
+ * Orphan-attribution hint (FD10) — the census decision point this outcome
81
+ * belongs to. If supplied it must exist in the census (unknown → rejected
82
+ * + counted).
83
+ */
84
+ decisionPoint?: string;
85
+ /** Defaults to the recorder clock. */
86
+ ts?: number;
87
+ }
88
+ export interface DecisionOutcomeAnnotationResult {
89
+ /** True = the outcome row landed durably (orphan or not). */
90
+ applied: boolean;
91
+ rejected?: AnnotationRejectionClass;
92
+ /** True = no decision_quality parent on this machine (FD10 — counted, never an error). */
93
+ orphan?: boolean;
94
+ /** True = validated clean but suppressed by the §5.2 dry-run stage. */
95
+ dryRun?: boolean;
96
+ /** True = the seam resolves DARK on this agent (nothing counted, nothing written). */
97
+ disabled?: boolean;
98
+ }
99
+ /** The config slice the recorder resolves its gates from (§5.7). */
100
+ export interface DecisionQualityRecorderConfig {
101
+ developmentAgent?: boolean;
102
+ provenance?: {
103
+ uniformSeam?: {
104
+ enabled?: boolean;
105
+ dryRun?: boolean;
106
+ };
107
+ };
108
+ }
109
+ /** The census lookups the recorder consumes (§5.6 — defaults to the real PROVENANCE_COVERAGE module). */
110
+ export interface DecisionQualityCensus {
111
+ getCensusEntry: typeof getCensusEntry;
112
+ getVolumeClass: typeof getVolumeClass;
113
+ }
114
+ /** The evidence-rule registry lookup the annotate chokepoint consumes (§5.4.2 — defaults to RULE_REGISTRY). */
115
+ export interface DecisionQualityRules {
116
+ getRule: typeof getRule;
117
+ }
118
+ export interface DecisionQualityRecorderImplOptions {
119
+ /** The quality substrate (decision_quality/decision_outcomes/rollup). Null = degraded (no SQLite writes). */
120
+ ledger: FeatureMetricsLedger | null;
121
+ /** The provenance JSONL store (FD9 — constructed unconditionally). Null = degraded (no JSONL rows). */
122
+ judgmentProvenance?: JudgmentProvenanceLog | null;
123
+ config: DecisionQualityRecorderConfig;
124
+ /** Census lookups — the typed PROVENANCE_COVERAGE module by default (test seam). */
125
+ census?: DecisionQualityCensus;
126
+ /** Rule-registry lookup — RULE_REGISTRY by default (test seam). */
127
+ rules?: DecisionQualityRules;
128
+ log?: (msg: string) => void;
129
+ now?: () => number;
130
+ }
131
+ export declare class DecisionQualityRecorderImpl implements DecisionQualityRecorder {
132
+ private readonly ledger;
133
+ private readonly jpl;
134
+ private readonly census;
135
+ private readonly rules;
136
+ private readonly enabled;
137
+ private readonly dryRun;
138
+ private readonly log;
139
+ private readonly nowFn;
140
+ constructor(opts: DecisionQualityRecorderImplOptions);
141
+ /** The resolved gate state (wiring-integrity/status surface). */
142
+ gateState(): {
143
+ enabled: boolean;
144
+ dryRun: boolean;
145
+ };
146
+ /**
147
+ * The router-settlement write (§5.1.5/FD7 — exactly one call per settled
148
+ * decision, isolated by the router; this method additionally never throws).
149
+ */
150
+ recordSettlement(s: DecisionSettlement): void;
151
+ /**
152
+ * Volume-class disposition for the provenance JSONL row (§5.6):
153
+ * - `full` → always write (the FD4 always-write reservation);
154
+ * - `sampled:<rate>` → deterministic FNV-1a bucket on the CORRELATION id
155
+ * (the log's own sampling convention — a decision samples identically on
156
+ * replay); malformed rate → write (the ratchet owns format; the seam
157
+ * fails toward observability);
158
+ * - `budget:<rows/day>` → indexed COUNT of decision_quality rows since
159
+ * UTC-day start (restart-safe, no new state). An unverifiable count
160
+ * (substrate degraded) → write, honestly logged by the ledger's own
161
+ * degradation — never a fabricated drop;
162
+ * - no class (unknown/pending/exempt point) → no JSONL row (an undeclared
163
+ * point gets counts, never a provenance archive the census hasn't valved).
164
+ */
165
+ private resolveJsonlDisposition;
166
+ /**
167
+ * The §5.4 outcome-annotation write-integrity chokepoint. Callsites (the
168
+ * hog sentinel's grade-on-supersede/scan-tick rules, the completion
169
+ * realcheck arm, the grading endpoint) reach it via
170
+ * `annotateDecisionOutcome()` below — never `ledger.upsertOutcome` directly.
171
+ */
172
+ annotateOutcome(a: DecisionOutcomeAnnotationInput): DecisionOutcomeAnnotationResult;
173
+ }
174
+ /**
175
+ * Install the recorder at AgentServer construction: registers it as BOTH the
176
+ * router's settlement recorder (P2's `setDecisionQualityRecorder` singleton)
177
+ * AND the module-level annotate-chokepoint target. Pass null to uninstall.
178
+ */
179
+ export declare function installDecisionQualityRecorder(impl: DecisionQualityRecorderImpl | null): void;
180
+ /**
181
+ * The module-level annotate entry (§5.4) — what the hog/completion wiring and
182
+ * the grading endpoint call. No recorder installed (CLI without a server) →
183
+ * a clean no-op result.
184
+ */
185
+ export declare function annotateDecisionOutcome(a: DecisionOutcomeAnnotationInput): DecisionOutcomeAnnotationResult;
186
+ /**
187
+ * Parse the machineId segment out of a §5.1 correlation id
188
+ * (`d-<machineId8>-<uuid>` / `d-<uuid>`): the id itself is the carrier the
189
+ * FD10 routing follow-up reads. A bare-uuid id (single-machine mint) → null.
190
+ */
191
+ export declare function machineIdSegmentOf(correlationId: string): string | null;
192
+ //# sourceMappingURL=DecisionQualityRecorderImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecisionQualityRecorderImpl.d.ts","sourceRoot":"","sources":["../../src/core/DecisionQualityRecorderImpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAA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ACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;IAC5C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAEzB,IAAI,EAAE,kCAAkC;IAapD,iEAAiE;IACjE,SAAS,IAAI;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE;IAIlD;;;OAGG;IACH,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAqG7C;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,uBAAuB;IA0B/B;;;;;OAKG;IACH,eAAe,CAAC,CAAC,EAAE,8BAA8B,GAAG,+BAA+B;CAiFpF;AAMD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,2BAA2B,GAAG,IAAI,GAAG,IAAI,CAG7F;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,8BAA8B,GAAG,+BAA+B,CAG1G;AAmBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASvE"}
@@ -0,0 +1,363 @@
1
+ /**
2
+ * DecisionQualityRecorderImpl — the concrete decision-quality substrate behind
3
+ * the router's settlement seam (llm-decision-quality-meter §5.2/§5.4/§5.5).
4
+ *
5
+ * Two write paths live here, both observe-only (never gate, never throw into
6
+ * the path they observe):
7
+ *
8
+ * 1. `recordSettlement` (the DecisionQualityRecorder contract, §5.1.5/FD7):
9
+ * consumes the router's write-once DecisionSettlement. For every ENROLLED
10
+ * settled decision it ALWAYS writes the ~250-byte content-free
11
+ * `decision_quality` row (regardless of volume class — outcome rows always
12
+ * have parents, counts are complete), validates the decision point against
13
+ * the census (unknown → counted, row still written with the raw point id),
14
+ * and writes the provenance JSONL row under the census VOLUME VALVE
15
+ * (`full` always / `sampled:<rate>` deterministic FNV-1a on the correlation
16
+ * id / `budget:<rows/day>` indexed COUNT since UTC-day start with a loud
17
+ * droppedByBudget counter).
18
+ *
19
+ * 2. `annotateOutcome` (the §5.4 write-integrity CHOKEPOINT): the ONE path an
20
+ * outcome annotation takes into the substrate. Keyed on the correlation id;
21
+ * rung + evidence strength are DERIVED from the registered evidence rule —
22
+ * never caller-supplied — and the chokepoint REJECTS + COUNTS: an invalid
23
+ * grade enum, a rung mismatch (incl. an unregistered ruleId — DC r7), an
24
+ * owner mismatch (gradedBy.component ≠ the rule's registered owning
25
+ * component — ADV r5), and an unknown decision point. Accepted outcomes
26
+ * land via `ledger.upsertOutcome` (idempotent on correlationId × gradedBy)
27
+ * plus a JPL outcome trail row. The evidence RULES themselves (what grade a
28
+ * respawn/realcheck proves) belong to their owning components — this module
29
+ * only enforces the write-integrity contract.
30
+ *
31
+ * Gating (§5.7/FD6): `provenance.uniformSeam.enabled` resolves via
32
+ * `resolveDevAgentGate` (LIVE on a development agent, DARK on the fleet;
33
+ * omit-required — never seeded). `dryRun` defaults TRUE: metadata-only
34
+ * would-write log lines (component, decisionPoint, byte sizes — NEVER context
35
+ * content), with BOTH durable writes suppressed (§5.2).
36
+ */
37
+ import { setDecisionQualityRecorder } from './decisionQualityTypes.js';
38
+ import { clampServedVerdictClass, clampServedPromptId, fnv1aSampleBucket, CONTEXT_HEAD_CLAMP, } from './JudgmentProvenanceLog.js';
39
+ import { getCensusEntry, getVolumeClass, getRule } from '../data/provenanceCoverage.js';
40
+ import { resolveDevAgentGate } from './devAgentGate.js';
41
+ import { scrubString } from './CredentialAuditEmit.js';
42
+ /** Outcome evidence-note hard bound (§5.2/§5.5 — clamped at annotate time, before storage). */
43
+ export const EVIDENCE_NOTE_CLAMP = 500;
44
+ const _rejectionCounters = {
45
+ enumInvalid: 0,
46
+ rungMismatch: 0,
47
+ ownerMismatch: 0,
48
+ unknownDecisionPoint: 0,
49
+ };
50
+ /** The four §5.5 rejection-class counters (P10's route surface). */
51
+ export function getDecisionAnnotationRejectionCounters() {
52
+ return { ..._rejectionCounters };
53
+ }
54
+ /** Test-only seam (the _resetDecisionQualityForTest precedent). */
55
+ export function _resetDecisionAnnotationRejectionCountersForTest() {
56
+ _rejectionCounters.enumInvalid = 0;
57
+ _rejectionCounters.rungMismatch = 0;
58
+ _rejectionCounters.ownerMismatch = 0;
59
+ _rejectionCounters.unknownDecisionPoint = 0;
60
+ }
61
+ export class DecisionQualityRecorderImpl {
62
+ ledger;
63
+ jpl;
64
+ census;
65
+ rules;
66
+ enabled;
67
+ dryRun;
68
+ log;
69
+ nowFn;
70
+ constructor(opts) {
71
+ this.ledger = opts.ledger ?? null;
72
+ this.jpl = opts.judgmentProvenance ?? null;
73
+ this.census = opts.census ?? { getCensusEntry, getVolumeClass };
74
+ this.rules = opts.rules ?? { getRule };
75
+ // §5.7/FD6: omit-required dev gate — LIVE on a development agent, DARK on
76
+ // the fleet; an explicit config value always wins. dryRun defaults TRUE.
77
+ this.enabled = resolveDevAgentGate(opts.config.provenance?.uniformSeam?.enabled, opts.config);
78
+ this.dryRun = opts.config.provenance?.uniformSeam?.dryRun !== false;
79
+ this.log = opts.log ?? (() => { });
80
+ this.nowFn = opts.now ?? (() => Date.now());
81
+ }
82
+ /** The resolved gate state (wiring-integrity/status surface). */
83
+ gateState() {
84
+ return { enabled: this.enabled, dryRun: this.dryRun };
85
+ }
86
+ /**
87
+ * The router-settlement write (§5.1.5/FD7 — exactly one call per settled
88
+ * decision, isolated by the router; this method additionally never throws).
89
+ */
90
+ recordSettlement(s) {
91
+ try {
92
+ if (!this.enabled)
93
+ return;
94
+ if (!s.enrolled || !s.provenance)
95
+ return; // Layer A only — nothing enrolled to write
96
+ const decisionPoint = typeof s.provenance.decisionPoint === 'string' ? s.provenance.decisionPoint : '';
97
+ if (!decisionPoint)
98
+ return; // keyless enrollment = unjoinable noise
99
+ const entry = this.census.getCensusEntry(decisionPoint);
100
+ // §5.1.4: validate decisionPoint ∈ census; unknowns are COUNTED but the
101
+ // decision_quality row is still written with the raw point id — counts
102
+ // must be complete (DC2-M3).
103
+ if (!entry)
104
+ _rejectionCounters.unknownDecisionPoint++;
105
+ const volumeClass = this.census.getVolumeClass(decisionPoint); // undefined unless census-wired
106
+ // Bounded served labels (§5.2) — the SAME clamp helpers the JPL envelope
107
+ // applies, so the SQLite row and the JSONL row can never disagree.
108
+ const verdict = clampServedVerdictClass(s.verdictClass);
109
+ const prompt = clampServedPromptId(s.provenance.promptId);
110
+ const qualityRecord = {
111
+ correlationId: s.correlationId,
112
+ decisionPoint,
113
+ feature: entry?.component,
114
+ verdictClass: verdict.value,
115
+ mintedBy: s.mintedBy,
116
+ volumeClass,
117
+ contentClass: entry?.contentClass,
118
+ machineId: machineIdSegmentOf(s.correlationId) ?? undefined,
119
+ model: s.settledAttempt.model,
120
+ framework: s.settledAttempt.framework,
121
+ promptId: prompt.value,
122
+ ts: s.settledAtMs,
123
+ };
124
+ // Context assembly (§5.1.3/§5.1.5): callerRef relocates INSIDE context
125
+ // (FD8); a raw-response head enters SCRUBBED + 300-clamped — never the
126
+ // served decision field; an errored settlement carries its error class.
127
+ const context = {
128
+ ...(s.provenance.context ?? {}),
129
+ ...(s.callerRef !== undefined ? { callerRef: scrubString(String(s.callerRef)).slice(0, 128) } : {}),
130
+ ...(s.rawResponseHead !== undefined
131
+ ? { rawResponseHead: scrubString(s.rawResponseHead).slice(0, CONTEXT_HEAD_CLAMP) }
132
+ : {}),
133
+ ...(s.errorClass !== undefined ? { errorClass: String(s.errorClass).slice(0, 128) } : {}),
134
+ };
135
+ const jplInput = {
136
+ component: entry?.component ?? 'unlabeled',
137
+ decisionPoint,
138
+ context,
139
+ optionsPresented: s.provenance.optionsPresented ?? [],
140
+ decision: s.verdictClass, // JPL applies the §5.2 clamp on seam rows
141
+ reason: 'router-settlement',
142
+ floor: 'observe-only settlement seam',
143
+ fallbackRung: 'llm',
144
+ // FD4: the always-write (arbiter-bypass) invariant is RESERVED for
145
+ // full-class points. (Seam rows bypass the JPL's global sampling knob
146
+ // regardless — the census volume valve below is their ONE valve.)
147
+ arbiter: volumeClass === 'full',
148
+ model: s.settledAttempt.model,
149
+ tokensIn: s.settledAttempt.usage?.inputTokens,
150
+ tokensOut: s.settledAttempt.usage?.outputTokens,
151
+ latencyMs: Math.max(0, s.settledAtMs - s.mintedAtMs),
152
+ correlationId: s.correlationId,
153
+ promptId: s.provenance.promptId, // JPL applies the §5.2 clamp
154
+ contentClass: entry?.contentClass,
155
+ mintedBy: s.mintedBy,
156
+ };
157
+ if (this.dryRun) {
158
+ // §5.2 dry-run stage: metadata-only would-write lines — component,
159
+ // decisionPoint, byte sizes, volume-class disposition. NEVER context
160
+ // content (that would violate the very posture the 0700/0600 store
161
+ // exists to contain). BOTH durable writes are suppressed.
162
+ const disposition = this.resolveJsonlDisposition(volumeClass, s, { selfAlreadyCounted: false });
163
+ this.log(`[decision-quality] dryRun would-write: decisionPoint=${safeLabel(decisionPoint)} ` +
164
+ `component=${safeLabel(entry?.component ?? 'unknown')} census=${entry ? entry.status : 'unknown'} ` +
165
+ `volumeClass=${volumeClass ?? 'none'} verdictClass=${safeLabel(verdict.value)} jsonl=${disposition} ` +
166
+ `qualityRowBytes=${byteLength(qualityRecord)} provenanceRowBytes=${byteLength(jplInput)}`);
167
+ return;
168
+ }
169
+ // 1. The content-free decision_quality row — EVERY enrolled settlement,
170
+ // REGARDLESS of volume class (§5.5/DC2-M3).
171
+ this.ledger?.recordDecision(qualityRecord);
172
+ // 2. The provenance JSONL row — governed by the census volume valve (§5.6).
173
+ const disposition = this.resolveJsonlDisposition(volumeClass, s, { selfAlreadyCounted: true });
174
+ if (disposition === 'write') {
175
+ this.jpl?.recordDecision(jplInput);
176
+ }
177
+ else if (disposition === 'budget-dropped') {
178
+ // Loud, never silent (§5.6/FD4).
179
+ this.ledger?.bumpQualityCounter(decisionPoint, 'droppedByBudget', { ts: s.settledAtMs });
180
+ }
181
+ }
182
+ catch (err) {
183
+ // @silent-fallback-ok: observability must never break the decision path
184
+ // it observes (§5.1.7) — the router additionally isolates this call.
185
+ this.log(`[decision-quality] settlement write failed (observability only): ${err.message}`);
186
+ }
187
+ }
188
+ /**
189
+ * Volume-class disposition for the provenance JSONL row (§5.6):
190
+ * - `full` → always write (the FD4 always-write reservation);
191
+ * - `sampled:<rate>` → deterministic FNV-1a bucket on the CORRELATION id
192
+ * (the log's own sampling convention — a decision samples identically on
193
+ * replay); malformed rate → write (the ratchet owns format; the seam
194
+ * fails toward observability);
195
+ * - `budget:<rows/day>` → indexed COUNT of decision_quality rows since
196
+ * UTC-day start (restart-safe, no new state). An unverifiable count
197
+ * (substrate degraded) → write, honestly logged by the ledger's own
198
+ * degradation — never a fabricated drop;
199
+ * - no class (unknown/pending/exempt point) → no JSONL row (an undeclared
200
+ * point gets counts, never a provenance archive the census hasn't valved).
201
+ */
202
+ resolveJsonlDisposition(volumeClass, s, opts) {
203
+ if (!volumeClass)
204
+ return 'no-volume-class';
205
+ if (volumeClass === 'full')
206
+ return 'write';
207
+ if (volumeClass.startsWith('sampled:')) {
208
+ const rate = Number(volumeClass.slice('sampled:'.length));
209
+ if (!Number.isFinite(rate))
210
+ return 'write';
211
+ const clamped = Math.min(1, Math.max(0, rate));
212
+ return fnv1aSampleBucket(s.correlationId) < clamped ? 'write' : 'sampled-out';
213
+ }
214
+ if (volumeClass.startsWith('budget:')) {
215
+ const budget = Number.parseInt(volumeClass.slice('budget:'.length), 10);
216
+ if (!Number.isFinite(budget) || budget <= 0)
217
+ return 'write';
218
+ const d = new Date(s.settledAtMs);
219
+ const utcDayStart = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
220
+ const counted = this.ledger?.countDecisionsSince(s.provenance?.decisionPoint ?? '', utcDayStart) ?? null;
221
+ if (counted === null)
222
+ return 'write'; // budget unverifiable — fail toward observability
223
+ const todayIncludingSelf = counted + (opts.selfAlreadyCounted ? 0 : 1);
224
+ return todayIncludingSelf <= budget ? 'write' : 'budget-dropped';
225
+ }
226
+ return 'write';
227
+ }
228
+ /**
229
+ * The §5.4 outcome-annotation write-integrity chokepoint. Callsites (the
230
+ * hog sentinel's grade-on-supersede/scan-tick rules, the completion
231
+ * realcheck arm, the grading endpoint) reach it via
232
+ * `annotateDecisionOutcome()` below — never `ledger.upsertOutcome` directly.
233
+ */
234
+ annotateOutcome(a) {
235
+ try {
236
+ if (!this.enabled)
237
+ return { applied: false, disabled: true };
238
+ // FD3 grade enum — validated first (§5.4.4).
239
+ if (a.grade !== 'right' && a.grade !== 'wrong' && a.grade !== 'unknown') {
240
+ _rejectionCounters.enumInvalid++;
241
+ return { applied: false, rejected: 'enum-invalid' };
242
+ }
243
+ // Rung is DERIVED from the registry, never caller-supplied (§5.4.2). An
244
+ // unregistered ruleId buckets under rung-mismatch (DC r7).
245
+ const rule = this.rules.getRule(a.ruleId);
246
+ if (!rule) {
247
+ _rejectionCounters.rungMismatch++;
248
+ return { applied: false, rejected: 'rung-mismatch' };
249
+ }
250
+ if (a.claimedRung !== undefined && a.claimedRung !== rule.rung) {
251
+ _rejectionCounters.rungMismatch++;
252
+ return { applied: false, rejected: 'rung-mismatch' };
253
+ }
254
+ // Owner check (ADV r5): a confused in-process annotator cannot inherit
255
+ // another rule's rung/precedence by claiming its id.
256
+ if (a.gradedBy?.component !== rule.owningComponent) {
257
+ _rejectionCounters.ownerMismatch++;
258
+ return { applied: false, rejected: 'owner-mismatch' };
259
+ }
260
+ // A supplied decision-point hint must exist in the census (§5.1.4/DC r7).
261
+ if (a.decisionPoint !== undefined && !this.census.getCensusEntry(a.decisionPoint)) {
262
+ _rejectionCounters.unknownDecisionPoint++;
263
+ return { applied: false, rejected: 'unknown-decision-point' };
264
+ }
265
+ const ts = a.ts ?? this.nowFn();
266
+ // Evidence note: scrubbed + ≤500-clamped BEFORE storage (§5.2/§5.5);
267
+ // never served by /decision-quality.
268
+ const evidenceNote = a.evidenceNote !== undefined ? scrubString(String(a.evidenceNote)).slice(0, EVIDENCE_NOTE_CLAMP) : undefined;
269
+ if (this.dryRun) {
270
+ // §5.2: while dryRun holds, the SQLite outcome write is suppressed too.
271
+ this.log(`[decision-quality] dryRun would-annotate: correlationId=${safeLabel(a.correlationId)} ` +
272
+ `ruleId=${safeLabel(a.ruleId)} rung=${rule.rung} grade=${a.grade} gradedBy=${safeLabel(a.gradedBy.component)}` +
273
+ (evidenceNote !== undefined ? ` evidenceNoteBytes=${Buffer.byteLength(evidenceNote, 'utf8')}` : ''));
274
+ return { applied: false, dryRun: true };
275
+ }
276
+ const res = this.ledger?.upsertOutcome({
277
+ correlationId: a.correlationId,
278
+ gradedBy: a.gradedBy.component,
279
+ ruleId: a.ruleId,
280
+ rung: rule.rung,
281
+ evidenceStrength: rule.evidenceStrength,
282
+ grade: a.grade,
283
+ effectiveWindowMs: rule.windowMs,
284
+ evidenceNote,
285
+ decisionPoint: a.decisionPoint,
286
+ ts,
287
+ });
288
+ if (!res?.applied)
289
+ return { applied: false };
290
+ // The JPL outcome trail row (§5.4.1 correlation keying) — structured
291
+ // evidence + the effective window (§5.4.5); grade re-validated at the
292
+ // JPL write by its own FD3 enum guard.
293
+ this.jpl?.annotateOutcome(a.correlationId, a.gradedBy.component, {
294
+ ...(a.evidence ?? {}),
295
+ ...(rule.windowMs !== undefined ? { windowMs: rule.windowMs } : {}),
296
+ ...(evidenceNote !== undefined ? { note: evidenceNote } : {}),
297
+ evidenceStrength: rule.evidenceStrength,
298
+ }, { grade: a.grade, gradedBy: a.gradedBy.component, ruleId: a.ruleId });
299
+ return { applied: true, orphan: res.orphan };
300
+ }
301
+ catch (err) {
302
+ // @silent-fallback-ok: annotation is observability — a failed write is
303
+ // repaired by idempotent re-runs (upserts converge), never a throw.
304
+ this.log(`[decision-quality] outcome annotation failed (observability only): ${err.message}`);
305
+ return { applied: false };
306
+ }
307
+ }
308
+ }
309
+ /* ── Module singleton wiring (the setFeatureMetricsRecorder pattern) ──────── */
310
+ let _activeAnnotator = null;
311
+ /**
312
+ * Install the recorder at AgentServer construction: registers it as BOTH the
313
+ * router's settlement recorder (P2's `setDecisionQualityRecorder` singleton)
314
+ * AND the module-level annotate-chokepoint target. Pass null to uninstall.
315
+ */
316
+ export function installDecisionQualityRecorder(impl) {
317
+ setDecisionQualityRecorder(impl);
318
+ _activeAnnotator = impl;
319
+ }
320
+ /**
321
+ * The module-level annotate entry (§5.4) — what the hog/completion wiring and
322
+ * the grading endpoint call. No recorder installed (CLI without a server) →
323
+ * a clean no-op result.
324
+ */
325
+ export function annotateDecisionOutcome(a) {
326
+ if (!_activeAnnotator)
327
+ return { applied: false, disabled: true };
328
+ return _activeAnnotator.annotateOutcome(a);
329
+ }
330
+ /* ── Small helpers ──────────────────────────────────────────────────────── */
331
+ /** Log-hygiene clamp for identifiers interpolated into would-write lines. */
332
+ function safeLabel(v) {
333
+ return String(v).replace(/[^\w./:<>-]/g, '_').slice(0, 64);
334
+ }
335
+ function byteLength(v) {
336
+ try {
337
+ return Buffer.byteLength(JSON.stringify(v) ?? '', 'utf8');
338
+ }
339
+ catch {
340
+ // @silent-fallback-ok: byte sizing feeds a dry-run log line only — an
341
+ // unserializable payload reports -1 rather than failing the settlement.
342
+ return -1;
343
+ }
344
+ }
345
+ /**
346
+ * Parse the machineId segment out of a §5.1 correlation id
347
+ * (`d-<machineId8>-<uuid>` / `d-<uuid>`): the id itself is the carrier the
348
+ * FD10 routing follow-up reads. A bare-uuid id (single-machine mint) → null.
349
+ */
350
+ export function machineIdSegmentOf(correlationId) {
351
+ const m = /^[db]-(.+)$/.exec(correlationId);
352
+ if (!m)
353
+ return null;
354
+ const rest = m[1];
355
+ // A plain uuid (8-4-4-4-12 hex) means no machine segment.
356
+ if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(rest))
357
+ return null;
358
+ const dash = rest.indexOf('-');
359
+ if (dash <= 0)
360
+ return null;
361
+ return rest.slice(0, dash);
362
+ }
363
+ //# sourceMappingURL=DecisionQualityRecorderImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecisionQualityRecorderImpl.js","sourceRoot":"","sources":["../../src/core/DecisionQualityRecorderImpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAmBvC,MAAM,kBAAkB,GAAwC;IAC9D,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,CAAC;IAChB,oBAAoB,EAAE,CAAC;CACxB,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,sCAAsC;IACpD,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAC;AACnC,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,gDAAgD;IAC9D,kBAAkB,CAAC,WAAW,GAAG,CAAC,CAAC;IACnC,kBAAkB,CAAC,YAAY,GAAG,CAAC,CAAC;IACpC,kBAAkB,CAAC,aAAa,GAAG,CAAC,CAAC;IACrC,kBAAkB,CAAC,oBAAoB,GAAG,CAAC,CAAC;AAC9C,CAAC;AAwFD,MAAM,OAAO,2BAA2B;IACrB,MAAM,CAA8B;IACpC,GAAG,CAA+B;IAClC,MAAM,CAAw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
498
  evaluate(prompt: string, options?: IntelligenceOptions): Promise<string>;
499
+ /**
500
+ * Mint the per-decision correlation id on a router-INTERNAL clone (§5.1.1).
501
+ * The caller's options object is NEVER mutated; `options.provenance` is
502
+ * consumed here (stripped before any per-attempt spread can carry it down —
503
+ * §5.1.6); `onCorrelationId` fires synchronously at mint, exactly once per
504
+ * `evaluate()` invocation INCLUDING calls that later throw, never after
505
+ * settlement — and a throwing callback is caught + counted, never propagated
506
+ * (the decision call is never failed by its audit trail, §5.1.4).
507
+ */
508
+ private mintDecision;
509
+ /**
510
+ * Run ONE attempt of the current decision (§5.1.5 — per-attempt capture
511
+ * scoping). Every attempt gets a FRESH options object: a spread of the
512
+ * internal clone (the symbol-keyed correlation id + mint marker ride the
513
+ * spread; the breaker consumes each copy's marker single-use) with fresh
514
+ * capture wrappers composed over the caller's callbacks and any attempt
515
+ * extras. Only the attempt whose promise the router actually returns
516
+ * contributes its capture to the settlement: a rejected attempt's callbacks
517
+ * land in its own unread capture, and any callback firing AFTER settlement
518
+ * (a withSwapTimeout-abandoned attempt) is discarded by the settled latch.
519
+ */
520
+ private runAttempt;
521
+ /** Write-once settlement on a SUCCESSFUL exit (FD7). */
522
+ private settleDecision;
523
+ /**
524
+ * Write-once settlement on ANY throwing exit (FD7): the decision still yields
525
+ * exactly one row — `'<errored>'` + the error class — so failure-swap-ladder
526
+ * quality is itself gradeable, without N phantom decisions.
527
+ */
528
+ private settleDecisionErrored;
529
+ /** The single settlement write — isolated so a recorder throw can never reach the decision path (§5.1.7). */
530
+ private recordSettlement;
531
+ private evaluateRouted;
499
532
  /**
500
533
  * NON-GATING bounded failure-swap (docs/specs/nongating-failure-swap.md). Invoked ONLY from
501
534
  * the non-gating branch of evaluate() after the PRIMARY suffered an INVOCATION-level failure