my-frontend-observer 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ import type { StaticCandidateKind, StaticEvidenceProducerIdentity, RuntimeStaticCorrelationRecord, OmissionRecord, TruncationRecord, BoundedAgentContextArtifact } from './boundedAgentContext.js';
2
+ import type { EvidenceReference } from './relationships.js';
3
+ /** One authoritative static candidate as supplied by the caller (e.g. an application-layer adapter that already ran my-dev-kit retrieval). `candidateId`/`kind` are preserved exactly - never re-minted here. */
4
+ export interface StaticCandidateEvidenceInput {
5
+ candidateId: string;
6
+ kind: StaticCandidateKind;
7
+ evidenceRefs: EvidenceReference[];
8
+ }
9
+ /**
10
+ * One runtime target's correlation input. `required` mirrors the same
11
+ * required/optional/context classification the rest of the bounded-context
12
+ * artifact family already uses (see `boundedAgentContextProjection.ts`) -
13
+ * it drives required-before-optional allocation and CONTRACT-002 adequacy
14
+ * consequences, but is not itself part of the frozen public
15
+ * `RuntimeStaticCorrelationRecord` shape.
16
+ */
17
+ export interface CorrelationTargetInput {
18
+ runtimeTargetId: string;
19
+ required: boolean;
20
+ runtimeEvidenceRefs: EvidenceReference[];
21
+ /** Authoritative static candidates already selected/ranked by caller criteria. Empty means "correlation attempted, no responsible candidate available" (=> `unavailable`), which is distinct from omitting this target from `targets` entirely (=> not attempted, no record at all). */
22
+ candidates: StaticCandidateEvidenceInput[];
23
+ evidenceBasis?: string;
24
+ }
25
+ export interface DeriveRuntimeStaticCorrelationsInput {
26
+ /** Authoritative static producer/index identity, preserved exactly. Never derived from a local path, worktree, output directory, or timestamp. */
27
+ staticProducer: StaticEvidenceProducerIdentity;
28
+ /** Provenance timestamp for every derived record's `provenance.correlatedAt`. Supplied by the caller (pure function - no internal `Date.now()`), matching the existing `generatedAt`-as-input convention in `boundedAgentContextProjection.ts`. */
29
+ correlatedAt: string;
30
+ targets: CorrelationTargetInput[];
31
+ }
32
+ export interface DeriveRuntimeStaticCorrelationsOutput {
33
+ records: RuntimeStaticCorrelationRecord[];
34
+ omissions: OmissionRecord[];
35
+ truncations: TruncationRecord[];
36
+ }
37
+ export type DeriveRuntimeStaticCorrelationsResult = ({
38
+ ok: true;
39
+ } & DeriveRuntimeStaticCorrelationsOutput) | {
40
+ ok: false;
41
+ reason: string;
42
+ };
43
+ /**
44
+ * Derives zero or more bounded `RuntimeStaticCorrelationRecord`s (one per
45
+ * supplied target) from authoritative runtime + static evidence. Pure,
46
+ * deterministic, immutable over its inputs, and terminating for arbitrarily
47
+ * large valid input (bounded by `MAX_CORRELATION_RECORDS`,
48
+ * `MAX_STATIC_CANDIDATES_PER_TARGET`, `MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD`).
49
+ *
50
+ * Does not itself attach the result to a `BoundedAgentContextArtifact` - see
51
+ * `attachRuntimeStaticCorrelations` for that (separate, explicit step, so
52
+ * this function stays usable standalone and testable in isolation).
53
+ */
54
+ export declare function deriveRuntimeStaticCorrelations(input: DeriveRuntimeStaticCorrelationsInput): DeriveRuntimeStaticCorrelationsResult;
55
+ export type AttachRuntimeStaticCorrelationsResult = {
56
+ ok: true;
57
+ artifact: BoundedAgentContextArtifact;
58
+ } | {
59
+ ok: false;
60
+ reason: string;
61
+ };
62
+ /**
63
+ * Attaches a previously-derived correlation result to an existing
64
+ * `BoundedAgentContextArtifact`, immutably (returns a new artifact; never
65
+ * mutates the input). Enforces cross-artifact coherence (every correlation
66
+ * record's `runtimeTargetId` must reference a target already present in
67
+ * `artifact.targets`), re-applies the aggregate `MAX_CORRELATION_RECORDS`/
68
+ * `MAX_OMISSIONS`/`MAX_TRUNCATIONS` caps to the merged collections, and
69
+ * recomputes `adequacy` per the frozen CONTRACT-002 rule: any known required
70
+ * correlation loss or required correlation unavailability forces
71
+ * `inadequate`; optional-only correlation loss may downgrade an otherwise
72
+ * `adequate` artifact to `partial`, never to `inadequate`.
73
+ */
74
+ export declare function attachRuntimeStaticCorrelations(artifact: BoundedAgentContextArtifact, correlation: DeriveRuntimeStaticCorrelationsOutput): AttachRuntimeStaticCorrelationsResult;
@@ -0,0 +1,441 @@
1
+ /**
2
+ * v0.6 Batch 3: runtime/static correlation derivation + attachment/export
3
+ * against the existing frozen contract in `boundedAgentContext.ts`
4
+ * (`RuntimeStaticCorrelationRecord`, `StaticCandidateReference`,
5
+ * `StaticEvidenceProducerIdentity`, `BoundedAgentContextArtifact.correlations`).
6
+ *
7
+ * This module does not invent a new correlation schema, does not rename or
8
+ * redefine any frozen type/constant, and does not bump the package or
9
+ * `BoundedAgentContextArtifact` schema version. It implements the bounded,
10
+ * deterministic, pure derivation behavior the frozen contract already
11
+ * anticipated but never had an implementation for.
12
+ *
13
+ * Pure and synchronous: no my-dev-kit invocation, no repository indexing, no
14
+ * filesystem access, no re-observation, no recomputation of unrelated
15
+ * artifacts. Consumes only authoritative supplied evidence (runtime target
16
+ * identity/evidence and externally supplied static candidate evidence +
17
+ * static producer/index identity). Mutates none of its inputs.
18
+ *
19
+ * my-dev-kit product boundary: this module has no dependency on, import of,
20
+ * or awareness of `@dailephd/my-dev-kit` at runtime. It accepts neutral,
21
+ * already-retrieved static evidence through `StaticCandidateEvidenceInput`
22
+ * and `DeriveRuntimeStaticCorrelationsInput.staticProducer` - both plain
23
+ * data shapes, never a live my-dev-kit client/process. Static
24
+ * retrieval/indexing remains my-dev-kit's responsibility outside this
25
+ * package; this module never re-derives it.
26
+ *
27
+ * No source-owner/causality/edit-authorization fabrication: `evidenceBasis`
28
+ * is passed through (bounded/truncated) from caller-supplied text only,
29
+ * never synthesized from candidate identity, and candidate/record shape
30
+ * carries no owner/causedBy-style field (the frozen contract already
31
+ * excludes one - see the doc comment on `RuntimeStaticCorrelationRecord`).
32
+ */
33
+ import { STATIC_CANDIDATE_KINDS, MAX_STATIC_CANDIDATES_PER_TARGET, MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD, MAX_TEXT_SUMMARY_CHARS, MAX_CORRELATION_RECORDS, MAX_OMISSIONS, MAX_TRUNCATIONS, isValidStaticEvidenceProducerIdentity, isValidStaticCandidateReference, isValidRuntimeStaticCorrelationRecord, isValidOmissionRecord, isValidTruncationRecord, isValidAdequacy, isValidBoundedAgentContextArtifact, } from './boundedAgentContext.js';
34
+ import { isValidEvidenceReference } from './relationships.js';
35
+ function isPlainObject(value) {
36
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
37
+ }
38
+ function isNonEmptyString(value) {
39
+ return typeof value === 'string' && value.length > 0;
40
+ }
41
+ function isEvidenceReferenceArray(value) {
42
+ return Array.isArray(value) && value.every((entry) => isValidEvidenceReference(entry));
43
+ }
44
+ // ---------------------------------------------------------------------------
45
+ // Boundary validation (fail closed on malformed input rather than silently
46
+ // producing a plausible-looking artifact)
47
+ // ---------------------------------------------------------------------------
48
+ function isValidStaticCandidateEvidenceInput(value) {
49
+ if (!isPlainObject(value))
50
+ return false;
51
+ if (!isNonEmptyString(value.candidateId))
52
+ return false;
53
+ if (typeof value.kind !== 'string' || !STATIC_CANDIDATE_KINDS.includes(value.kind))
54
+ return false;
55
+ if (value.kind === 'file' && !value.candidateId.startsWith('file:'))
56
+ return false;
57
+ if (value.kind === 'symbol' && !value.candidateId.startsWith('symbol:'))
58
+ return false;
59
+ return isEvidenceReferenceArray(value.evidenceRefs);
60
+ }
61
+ function isValidCorrelationTargetInput(value) {
62
+ if (!isPlainObject(value))
63
+ return false;
64
+ if (!isNonEmptyString(value.runtimeTargetId))
65
+ return false;
66
+ if (typeof value.required !== 'boolean')
67
+ return false;
68
+ if (!isEvidenceReferenceArray(value.runtimeEvidenceRefs))
69
+ return false;
70
+ if (!Array.isArray(value.candidates) || !value.candidates.every(isValidStaticCandidateEvidenceInput))
71
+ return false;
72
+ if (value.evidenceBasis !== undefined && typeof value.evidenceBasis !== 'string')
73
+ return false;
74
+ return true;
75
+ }
76
+ function validateDeriveInput(input) {
77
+ if (!isPlainObject(input))
78
+ return 'input must be an object';
79
+ if (!isValidStaticEvidenceProducerIdentity(input.staticProducer))
80
+ return 'staticProducer must be a valid StaticEvidenceProducerIdentity { name, version, indexId }';
81
+ if (!isNonEmptyString(input.correlatedAt))
82
+ return 'correlatedAt must be a non-empty string';
83
+ if (!Array.isArray(input.targets) || !input.targets.every(isValidCorrelationTargetInput)) {
84
+ return 'targets must be an array of valid correlation target inputs';
85
+ }
86
+ const seen = new Set();
87
+ for (const target of input.targets) {
88
+ if (seen.has(target.runtimeTargetId))
89
+ return `duplicate runtimeTargetId in correlation input: ${target.runtimeTargetId}`;
90
+ seen.add(target.runtimeTargetId);
91
+ }
92
+ return undefined;
93
+ }
94
+ // ---------------------------------------------------------------------------
95
+ // Deterministic ordering / bounded-collection helpers (duplicated per the
96
+ // established per-module convention - see `canonicalize` in
97
+ // `boundedAgentContextIdentity.ts` and `capOmissions`/`capTruncations` in
98
+ // `boundedAgentContextProjection.ts` - rather than importing private
99
+ // module-internal helpers cross-file)
100
+ // ---------------------------------------------------------------------------
101
+ function byPathAscending(a, b) {
102
+ return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
103
+ }
104
+ /** Dedupe by `path` and sort ascending so evidence-ref order never depends on retrieval/input order (order is not semantically significant here). */
105
+ function canonicalEvidenceRefs(refs) {
106
+ const byPath = new Map();
107
+ for (const ref of refs)
108
+ byPath.set(ref.path, ref);
109
+ return [...byPath.values()].sort(byPathAscending);
110
+ }
111
+ /**
112
+ * Rescue fix for C-B3-001 (B3-P004): merges two or more supplied candidates
113
+ * that share the same authoritative `candidateId` into a single surviving
114
+ * candidate, unioning their `evidenceRefs` (deduped/ordered later by the
115
+ * existing `canonicalEvidenceRefs` pass in `deriveOneTarget`). Mirrors the
116
+ * repository's established nested-collection duplicate-identity precedent -
117
+ * `boundedEvidenceForTarget` in `boundedAgentContextProjection.ts` (itself a
118
+ * prior "IMP-B-003" rescue for the same class of permutation-dependent
119
+ * duplicate-identity problem) - rather than the top-level container-key
120
+ * reject-on-duplicate precedent used for `runtimeTargetId` in
121
+ * `validateDeriveInput`: a `candidateId` duplicate is a nested per-target
122
+ * collection entry, not a top-level record-identity key, so silent
123
+ * structural rejection is not the matching precedent here.
124
+ *
125
+ * `candidateId`/`kind` are never rewritten - the frozen contract's exact
126
+ * candidate identity is preserved verbatim from whichever supplied entry
127
+ * matched (identical for every duplicate, since `isValidStaticCandidateEvidenceInput`
128
+ * already forces `kind` to agree with the `candidateId` prefix). Because
129
+ * `EvidenceReference` carries only a `path` field, the merge is
130
+ * content-safe and independent of which duplicate the Map last saw - final
131
+ * output is fully determined by set union, never by input/duplicate order.
132
+ */
133
+ function canonicalCandidates(candidates) {
134
+ const byId = new Map();
135
+ for (const candidate of candidates) {
136
+ const existing = byId.get(candidate.candidateId);
137
+ if (existing === undefined) {
138
+ byId.set(candidate.candidateId, candidate);
139
+ }
140
+ else {
141
+ byId.set(candidate.candidateId, {
142
+ candidateId: candidate.candidateId,
143
+ kind: candidate.kind,
144
+ evidenceRefs: [...existing.evidenceRefs, ...candidate.evidenceRefs],
145
+ });
146
+ }
147
+ }
148
+ return [...byId.values()];
149
+ }
150
+ /** Aggregate-cap enforcement for the merged `omissions` collection, same policy as `boundedAgentContextProjection.ts#capOmissions`: required-loss records are preserved preferentially and a single truthful summary record replaces whatever had to be dropped. */
151
+ function capOmissions(records, max) {
152
+ if (records.length <= max)
153
+ return [...records];
154
+ const ranked = [...records].sort((a, b) => Number(b.required) - Number(a.required));
155
+ const kept = ranked.slice(0, max - 1);
156
+ const dropped = ranked.slice(max - 1);
157
+ const anyRequired = dropped.some((d) => d.required);
158
+ const summary = {
159
+ subject: 'correlation-omissions-summary',
160
+ reason: 'omitted-by-bound',
161
+ required: anyRequired,
162
+ detail: `${dropped.length} additional omission record(s) omitted by the aggregate ${max}-omission cap`,
163
+ };
164
+ return [...kept, summary];
165
+ }
166
+ /** Aggregate-cap enforcement for the merged `truncations` collection, same policy as `capOmissions`. */
167
+ function capTruncations(records, max) {
168
+ if (records.length <= max)
169
+ return [...records];
170
+ const ranked = [...records].sort((a, b) => Number(b.required) - Number(a.required));
171
+ const kept = ranked.slice(0, max - 1);
172
+ const dropped = ranked.slice(max - 1);
173
+ const anyRequired = dropped.some((d) => d.required);
174
+ const summary = {
175
+ subject: 'correlation-truncations-summary',
176
+ limit: max,
177
+ actualCount: records.length,
178
+ required: anyRequired,
179
+ };
180
+ return [...kept, summary];
181
+ }
182
+ function deriveOneTarget(target, staticProducer, correlatedAt, omissions, truncations) {
183
+ // Rescue fix for C-B3-001: distinct-candidate identity, not raw entry
184
+ // count, drives ambiguity - merge duplicate candidateIds before ordering
185
+ // so a duplicate-inflated entry count can never survive into `status`.
186
+ const distinctCandidateInputs = canonicalCandidates(target.candidates);
187
+ // Canonical deterministic candidate ordering: sort by candidateId, never
188
+ // by input/retrieval order, so ambiguity never picks a "first" winner.
189
+ const orderedCandidates = [...distinctCandidateInputs].sort((a, b) => (a.candidateId < b.candidateId ? -1 : a.candidateId > b.candidateId ? 1 : 0));
190
+ let boundedCandidateInputs = orderedCandidates;
191
+ if (orderedCandidates.length > MAX_STATIC_CANDIDATES_PER_TARGET) {
192
+ boundedCandidateInputs = orderedCandidates.slice(0, MAX_STATIC_CANDIDATES_PER_TARGET);
193
+ truncations.push({
194
+ subject: `correlation:${target.runtimeTargetId}.candidates`,
195
+ limit: MAX_STATIC_CANDIDATES_PER_TARGET,
196
+ actualCount: orderedCandidates.length,
197
+ required: target.required,
198
+ });
199
+ }
200
+ const candidates = boundedCandidateInputs.map((candidate) => {
201
+ const canonicalRefs = canonicalEvidenceRefs(candidate.evidenceRefs);
202
+ let boundedRefs = canonicalRefs;
203
+ if (canonicalRefs.length > MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD) {
204
+ boundedRefs = canonicalRefs.slice(0, MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD);
205
+ truncations.push({
206
+ subject: `correlation:${target.runtimeTargetId}.candidate:${candidate.candidateId}.evidenceRefs`,
207
+ limit: MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD,
208
+ actualCount: canonicalRefs.length,
209
+ required: target.required,
210
+ });
211
+ }
212
+ return { candidateId: candidate.candidateId, kind: candidate.kind, evidenceRefs: boundedRefs };
213
+ });
214
+ // Status/candidate-count invariant, computed here (never accepted from the
215
+ // caller as a separate field) so it can never drift from the actual
216
+ // candidate count the frozen validator enforces.
217
+ const status = candidates.length === 0 ? 'unavailable' : candidates.length === 1 ? 'correlated' : 'ambiguous';
218
+ if (status === 'unavailable' && target.required) {
219
+ omissions.push({
220
+ subject: `correlation:${target.runtimeTargetId}`,
221
+ reason: 'unsupported-or-unavailable',
222
+ required: true,
223
+ detail: 'required runtime target had no responsible static candidate available for correlation',
224
+ });
225
+ }
226
+ const canonicalRuntimeRefs = canonicalEvidenceRefs(target.runtimeEvidenceRefs);
227
+ let runtimeEvidenceRefs = canonicalRuntimeRefs;
228
+ if (canonicalRuntimeRefs.length > MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD) {
229
+ runtimeEvidenceRefs = canonicalRuntimeRefs.slice(0, MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD);
230
+ truncations.push({
231
+ subject: `correlation:${target.runtimeTargetId}.runtimeEvidenceRefs`,
232
+ limit: MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD,
233
+ actualCount: canonicalRuntimeRefs.length,
234
+ required: target.required,
235
+ });
236
+ }
237
+ let evidenceBasis;
238
+ if (target.evidenceBasis !== undefined) {
239
+ if (target.evidenceBasis.length > MAX_TEXT_SUMMARY_CHARS) {
240
+ evidenceBasis = target.evidenceBasis.slice(0, MAX_TEXT_SUMMARY_CHARS);
241
+ truncations.push({
242
+ subject: `correlation:${target.runtimeTargetId}.evidenceBasis`,
243
+ limit: MAX_TEXT_SUMMARY_CHARS,
244
+ actualCount: target.evidenceBasis.length,
245
+ required: target.required,
246
+ });
247
+ }
248
+ else {
249
+ evidenceBasis = target.evidenceBasis;
250
+ }
251
+ }
252
+ const record = {
253
+ runtimeTargetId: target.runtimeTargetId,
254
+ runtimeEvidenceRefs,
255
+ staticProducer,
256
+ status,
257
+ candidates,
258
+ ...(evidenceBasis !== undefined ? { evidenceBasis } : {}),
259
+ provenance: { correlatedAt },
260
+ };
261
+ return record;
262
+ }
263
+ // ---------------------------------------------------------------------------
264
+ // Public derivation entry point
265
+ // ---------------------------------------------------------------------------
266
+ /**
267
+ * Derives zero or more bounded `RuntimeStaticCorrelationRecord`s (one per
268
+ * supplied target) from authoritative runtime + static evidence. Pure,
269
+ * deterministic, immutable over its inputs, and terminating for arbitrarily
270
+ * large valid input (bounded by `MAX_CORRELATION_RECORDS`,
271
+ * `MAX_STATIC_CANDIDATES_PER_TARGET`, `MAX_EVIDENCE_REFS_PER_CORRELATION_FIELD`).
272
+ *
273
+ * Does not itself attach the result to a `BoundedAgentContextArtifact` - see
274
+ * `attachRuntimeStaticCorrelations` for that (separate, explicit step, so
275
+ * this function stays usable standalone and testable in isolation).
276
+ */
277
+ export function deriveRuntimeStaticCorrelations(input) {
278
+ const invalidReason = validateDeriveInput(input);
279
+ if (invalidReason !== undefined)
280
+ return { ok: false, reason: invalidReason };
281
+ const omissions = [];
282
+ const truncations = [];
283
+ // Canonical deterministic target ordering: sort by runtimeTargetId, never
284
+ // by input order, so equivalent input sets always produce the same
285
+ // logical record ordering regardless of how the caller assembled `targets`.
286
+ const orderedTargets = [...input.targets].sort((a, b) => (a.runtimeTargetId < b.runtimeTargetId ? -1 : a.runtimeTargetId > b.runtimeTargetId ? 1 : 0));
287
+ const entries = orderedTargets.map((target) => ({
288
+ record: deriveOneTarget(target, input.staticProducer, input.correlatedAt, omissions, truncations),
289
+ required: target.required,
290
+ }));
291
+ // Required-before-optional allocation at the MAX_CORRELATION_RECORDS
292
+ // aggregate bound: required entries are kept first, then optional ones,
293
+ // in each case ordered by runtimeTargetId for determinism. Overflow beyond
294
+ // the cap becomes an explicit omission rather than a silently-dropped
295
+ // record; overflow of a *required* entry is a known required loss.
296
+ const requiredEntries = entries.filter((e) => e.required);
297
+ const optionalEntries = entries.filter((e) => !e.required);
298
+ const orderedEntries = [...requiredEntries, ...optionalEntries];
299
+ const allowedEntries = orderedEntries.slice(0, MAX_CORRELATION_RECORDS);
300
+ const droppedEntries = orderedEntries.slice(MAX_CORRELATION_RECORDS);
301
+ for (const dropped of droppedEntries) {
302
+ omissions.push({
303
+ subject: `correlation-record:${dropped.record.runtimeTargetId}`,
304
+ reason: dropped.required ? 'required-evidence-lost-by-bound' : 'omitted-by-bound',
305
+ required: dropped.required,
306
+ detail: `dropped by the aggregate ${MAX_CORRELATION_RECORDS}-correlation-record cap`,
307
+ });
308
+ }
309
+ const records = allowedEntries.map((e) => e.record).sort((a, b) => (a.runtimeTargetId < b.runtimeTargetId ? -1 : a.runtimeTargetId > b.runtimeTargetId ? 1 : 0));
310
+ // Self-check against the frozen structural validator before returning -
311
+ // fail closed rather than emit a record this module itself would reject.
312
+ for (const record of records) {
313
+ const targetId = record.runtimeTargetId;
314
+ for (const candidate of record.candidates) {
315
+ if (!isValidStaticCandidateReference(candidate)) {
316
+ return { ok: false, reason: `internal derivation produced an invalid StaticCandidateReference for target ${targetId}` };
317
+ }
318
+ }
319
+ if (!isValidRuntimeStaticCorrelationRecord(record)) {
320
+ return { ok: false, reason: `internal derivation produced an invalid RuntimeStaticCorrelationRecord for target ${targetId}` };
321
+ }
322
+ }
323
+ for (const omission of omissions) {
324
+ if (!isValidOmissionRecord(omission))
325
+ return { ok: false, reason: 'internal derivation produced an invalid OmissionRecord' };
326
+ }
327
+ for (const truncation of truncations) {
328
+ if (!isValidTruncationRecord(truncation))
329
+ return { ok: false, reason: 'internal derivation produced an invalid TruncationRecord' };
330
+ }
331
+ return { ok: true, records, omissions, truncations };
332
+ }
333
+ // ---------------------------------------------------------------------------
334
+ // Attachment / export boundary (extends the existing
335
+ // BoundedAgentContextArtifact family in place - no new persistence family)
336
+ // ---------------------------------------------------------------------------
337
+ const REQUIRED_CANDIDATE_TRUNCATION_ADEQUACY_REASON = 'static-correlation-ambiguous';
338
+ const REQUIRED_UNAVAILABLE_ADEQUACY_REASON = 'static-evidence-unavailable';
339
+ const REQUIRED_EVIDENCE_TRUNCATION_ADEQUACY_REASON = 'required-source-evidence-truncated';
340
+ const REQUIRED_RECORD_BOUND_LOSS_ADEQUACY_REASON = 'required-evidence-omitted-by-bound';
341
+ function classifyRequiredAdequacyReason(subject, isOmission) {
342
+ if (subject.startsWith('correlation-record:'))
343
+ return REQUIRED_RECORD_BOUND_LOSS_ADEQUACY_REASON;
344
+ if (subject.includes('.candidates'))
345
+ return REQUIRED_CANDIDATE_TRUNCATION_ADEQUACY_REASON;
346
+ if (isOmission)
347
+ return REQUIRED_UNAVAILABLE_ADEQUACY_REASON;
348
+ return REQUIRED_EVIDENCE_TRUNCATION_ADEQUACY_REASON;
349
+ }
350
+ /**
351
+ * Attaches a previously-derived correlation result to an existing
352
+ * `BoundedAgentContextArtifact`, immutably (returns a new artifact; never
353
+ * mutates the input). Enforces cross-artifact coherence (every correlation
354
+ * record's `runtimeTargetId` must reference a target already present in
355
+ * `artifact.targets`), re-applies the aggregate `MAX_CORRELATION_RECORDS`/
356
+ * `MAX_OMISSIONS`/`MAX_TRUNCATIONS` caps to the merged collections, and
357
+ * recomputes `adequacy` per the frozen CONTRACT-002 rule: any known required
358
+ * correlation loss or required correlation unavailability forces
359
+ * `inadequate`; optional-only correlation loss may downgrade an otherwise
360
+ * `adequate` artifact to `partial`, never to `inadequate`.
361
+ */
362
+ export function attachRuntimeStaticCorrelations(artifact, correlation) {
363
+ const artifactValidation = isValidBoundedAgentContextArtifact(artifact);
364
+ if (!artifactValidation.valid)
365
+ return { ok: false, reason: `artifact is invalid: ${artifactValidation.reason}` };
366
+ if (!Array.isArray(correlation.records) || !correlation.records.every(isValidRuntimeStaticCorrelationRecord)) {
367
+ return { ok: false, reason: 'correlation.records must be an array of valid runtime/static correlation records' };
368
+ }
369
+ if (!Array.isArray(correlation.omissions) || !correlation.omissions.every(isValidOmissionRecord)) {
370
+ return { ok: false, reason: 'correlation.omissions must be an array of valid omission records' };
371
+ }
372
+ if (!Array.isArray(correlation.truncations) || !correlation.truncations.every(isValidTruncationRecord)) {
373
+ return { ok: false, reason: 'correlation.truncations must be an array of valid truncation records' };
374
+ }
375
+ if (artifact.correlations !== undefined && artifact.correlations.length > 0) {
376
+ return { ok: false, reason: 'artifact already carries correlations; attaching twice is not supported (avoids silent overwrite/merge ambiguity)' };
377
+ }
378
+ const knownTargetIds = new Set(artifact.targets.map((t) => t.targetId));
379
+ for (const record of correlation.records) {
380
+ if (!knownTargetIds.has(record.runtimeTargetId)) {
381
+ return { ok: false, reason: `correlation record runtimeTargetId "${record.runtimeTargetId}" does not reference any target in artifact.targets (cross-artifact coherence violation)` };
382
+ }
383
+ }
384
+ const mergedOmissionsRaw = [...artifact.omissions, ...correlation.omissions];
385
+ const mergedTruncationsRaw = [...artifact.truncations, ...correlation.truncations];
386
+ const mergedOmissions = capOmissions(mergedOmissionsRaw, MAX_OMISSIONS);
387
+ const mergedTruncations = capTruncations(mergedTruncationsRaw, MAX_TRUNCATIONS);
388
+ const records = [...correlation.records].sort((a, b) => (a.runtimeTargetId < b.runtimeTargetId ? -1 : a.runtimeTargetId > b.runtimeTargetId ? 1 : 0));
389
+ if (records.length > MAX_CORRELATION_RECORDS) {
390
+ return { ok: false, reason: `correlation.records exceeds MAX_CORRELATION_RECORDS (${MAX_CORRELATION_RECORDS}); caller must bound before attaching` };
391
+ }
392
+ // CONTRACT-002: any known required loss introduced by this attach step
393
+ // (from correlation.omissions/correlation.truncations only - pre-existing
394
+ // artifact-level loss is left exactly as the artifact already represented
395
+ // it) forces inadequate; optional-only loss may downgrade adequate to
396
+ // partial; no loss leaves adequacy untouched.
397
+ const newRequiredOmissions = correlation.omissions.filter((o) => o.required);
398
+ const newRequiredTruncations = correlation.truncations.filter((t) => t.required);
399
+ const hasNewRequiredLoss = newRequiredOmissions.length > 0 || newRequiredTruncations.length > 0;
400
+ const hasNewOptionalLoss = correlation.omissions.some((o) => !o.required) || correlation.truncations.some((t) => !t.required);
401
+ let adequacy = artifact.adequacy;
402
+ if (hasNewRequiredLoss) {
403
+ const newReasonCodes = new Set([
404
+ ...newRequiredOmissions.map((o) => classifyRequiredAdequacyReason(o.subject, true)),
405
+ ...newRequiredTruncations.map((t) => classifyRequiredAdequacyReason(t.subject, false)),
406
+ ]);
407
+ const existingCodes = new Set(artifact.adequacy.reasons.map((r) => r.code));
408
+ const addedReasons = [...newReasonCodes].filter((code) => !existingCodes.has(code)).map((code) => ({ code }));
409
+ adequacy = { state: 'inadequate', reasons: [...artifact.adequacy.reasons, ...addedReasons] };
410
+ }
411
+ else if (artifact.adequacy.state === 'adequate' && hasNewOptionalLoss) {
412
+ // No ADEQUACY_REASON_CODE exists specifically for "optional correlation
413
+ // evidence truncated" (every truncation-specific code is required-loss
414
+ // scoped by name: `required-source-evidence-truncated`). Per
415
+ // CONTRACT-002/CONTRACT-001 (no new diagnostic field/code), the closest
416
+ // truthful existing non-required-scoped correlation code is reused, with
417
+ // the free-text `detail` field (already part of the frozen
418
+ // `AdequacyReason` shape) carrying the honest specifics.
419
+ adequacy = {
420
+ state: 'partial',
421
+ reasons: [
422
+ ...artifact.adequacy.reasons,
423
+ { code: REQUIRED_CANDIDATE_TRUNCATION_ADEQUACY_REASON, detail: 'optional-only correlation evidence was truncated by a bound; no required correlation evidence was lost' },
424
+ ],
425
+ };
426
+ }
427
+ if (!isValidAdequacy(adequacy))
428
+ return { ok: false, reason: 'internal adequacy recomputation produced an invalid Adequacy value' };
429
+ const nextArtifact = {
430
+ ...artifact,
431
+ omissions: mergedOmissions,
432
+ truncations: mergedTruncations,
433
+ adequacy,
434
+ ...(records.length > 0 ? { correlations: records } : {}),
435
+ };
436
+ const finalValidation = isValidBoundedAgentContextArtifact(nextArtifact);
437
+ if (!finalValidation.valid)
438
+ return { ok: false, reason: `internal attach produced an invalid artifact: ${finalValidation.reason}` };
439
+ return { ok: true, artifact: nextArtifact };
440
+ }
441
+ //# sourceMappingURL=boundedAgentContextCorrelation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundedAgentContextCorrelation.js","sourceRoot":"","sources":["../../src/domain/boundedAgentContextCorrelation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,uCAAuC,EACvC,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,eAAe,EACf,qCAAqC,EACrC,+BAA+B,EAC/B,qCAAqC,EACrC,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAYlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAc;IAC9C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AACzF,CAAC;AA+CD,8EAA8E;AAC9E,2EAA2E;AAC3E,0CAA0C;AAC1C,8EAA8E;AAE9E,SAAS,mCAAmC,CAAC,KAAc;IACzD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,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C;IAC/F,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,KAAK,UAAU,IAAI,kBAAkB,EAAE,CAAC;QACxE,wEAAwE;QACxE,uEAAuE;QACvE,6DAA6D;QAC7D,wEAAwE;QACxE,yEAAyE;QACzE,2DAA2D;QAC3D,yDAAyD;QACzD,QAAQ,GAAG;YACT,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO;gBAC5B,EAAE,IAAI,EAAE,6CAA6C,EAAE,MAAM,EAAE,wGAAwG,EAAE;aAC1K;SACF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oEAAoE,EAAE,CAAC;IAEnI,MAAM,YAAY,GAAgC;QAChD,GAAG,QAAQ;QACX,SAAS,EAAE,eAAe;QAC1B,WAAW,EAAE,iBAAiB;QAC9B,QAAQ;QACR,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;IAEF,MAAM,eAAe,GAAG,kCAAkC,CAAC,YAAY,CAAC,CAAC;IACzE,IAAI,CAAC,eAAe,CAAC,KAAK;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iDAAiD,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;IAEpI,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { BoundedAgentContextSourceReferences, ProjectionProfile } from './boundedAgentContext.js';
2
+ /**
3
+ * Pure function of {sources (arrays sorted - order carries no semantic
4
+ * meaning here), targetIds (sorted), projectionProfile} only. Never includes
5
+ * an operational output location, a captured timestamp, or contextId - an
6
+ * operational output path must never affect logical identity, and equivalent
7
+ * semantic input must always produce the same identity regardless of the
8
+ * order targets were originally supplied in.
9
+ */
10
+ export declare function buildBoundedAgentContextRequestIdentity(sources: BoundedAgentContextSourceReferences, targetIds: readonly string[], projectionProfile: ProjectionProfile): string;
11
+ /**
12
+ * Fresh, opaque per-generated-instance identity - never derived from a
13
+ * timestamp alone, never collides even when called twice with the same
14
+ * requestIdentity within the same millisecond.
15
+ */
16
+ export declare function buildBoundedAgentContextInstanceIdentity(requestIdentity: string): string;
@@ -0,0 +1,53 @@
1
+ import { createHash, randomBytes } from 'node:crypto';
2
+ /**
3
+ * Deliberately duplicated from domain/identity.ts#canonicalize (and its other
4
+ * per-module duplicates) rather than imported - each identity module owns its
5
+ * own private canonicalize per existing repository convention. Same
6
+ * algorithm (sorted object keys, order-preserving arrays).
7
+ */
8
+ function canonicalize(value) {
9
+ if (Array.isArray(value))
10
+ return value.map(canonicalize);
11
+ if (value !== null && typeof value === 'object') {
12
+ const entries = Object.entries(value)
13
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
14
+ .map(([key, entryValue]) => [key, canonicalize(entryValue)]);
15
+ return Object.fromEntries(entries);
16
+ }
17
+ return value;
18
+ }
19
+ /**
20
+ * Pure function of {sources (arrays sorted - order carries no semantic
21
+ * meaning here), targetIds (sorted), projectionProfile} only. Never includes
22
+ * an operational output location, a captured timestamp, or contextId - an
23
+ * operational output path must never affect logical identity, and equivalent
24
+ * semantic input must always produce the same identity regardless of the
25
+ * order targets were originally supplied in.
26
+ */
27
+ export function buildBoundedAgentContextRequestIdentity(sources, targetIds, projectionProfile) {
28
+ const semanticView = {
29
+ sources: {
30
+ observationIds: [...sources.observationIds].sort(),
31
+ comparisonId: sources.comparisonId ?? null,
32
+ comparisonRequestId: sources.comparisonRequestId ?? null,
33
+ baselineContractId: sources.baselineContractId ?? null,
34
+ changeContractId: sources.changeContractId ?? null,
35
+ evaluationId: sources.evaluationId ?? null,
36
+ evaluationRequestId: sources.evaluationRequestId ?? null,
37
+ },
38
+ targetIds: [...targetIds].sort(),
39
+ projectionProfile,
40
+ };
41
+ const serialized = JSON.stringify(canonicalize(semanticView));
42
+ return createHash('sha256').update(serialized).digest('hex');
43
+ }
44
+ /**
45
+ * Fresh, opaque per-generated-instance identity - never derived from a
46
+ * timestamp alone, never collides even when called twice with the same
47
+ * requestIdentity within the same millisecond.
48
+ */
49
+ export function buildBoundedAgentContextInstanceIdentity(requestIdentity) {
50
+ const nonce = randomBytes(16).toString('hex');
51
+ return `${requestIdentity}-${nonce}`;
52
+ }
53
+ //# sourceMappingURL=boundedAgentContextIdentity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundedAgentContextIdentity.js","sourceRoot":"","sources":["../../src/domain/boundedAgentContextIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGtD;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC;aAC7D,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAChD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,UAAU,CAAC,CAAU,CAAC,CAAC;QAC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