@descryy/runtime-contracts 0.2.0 → 0.3.1

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/evidence.js CHANGED
@@ -1,26 +1,16 @@
1
1
  /**
2
- * Evidence contract.
2
+ * Evidence contract, per §13 (evidence model), plus `evidenceId` (the
3
+ * ID-reference pattern Execution uses) and `stackTrace`. `confidence` is
4
+ * the resolution-honesty axis (§9), never conflated with environment
5
+ * fidelity (lives on Execution/Capability). Redaction per §25.
3
6
  *
4
- * Field list is verbatim from `documents/descry-runtime-plan.md` §13
5
- * (Evidence model), plus `evidenceId` (needed for the ID-reference pattern
6
- * Execution uses) and `stackTrace` (structured detail for the plan's
7
- * STACK_TRACE event type, per Agent 3's stack-fidelity finding below). Also
8
- * grounded in the architecture doc's §18.2 (evidence bundling —
9
- * screenshot/console/network/backend log, "none of these individually
10
- * would have been enough"), §17.2 (the observe stream), §9 (the three
11
- * confidence axes — this file's `confidence` field is the resolution-
12
- * honesty axis, never conflated with environment fidelity, which lives on
13
- * Execution/Capability instead) and §25 (redaction before storage).
14
- *
15
- * Static facts and runtime observations stay separate. Evidence never
16
- * embeds a graph node's data — `graphNodeId` is a reference into
17
- * @descryy/ir's identity scheme, resolved by whoever reads it. This file
18
- * does not, and must not, redefine graph identity or storage.
7
+ * Evidence never embeds a graph node's data — `graphNodeId` is a reference
8
+ * into @descryy/ir's identity scheme, resolved by whoever reads it.
19
9
  */
20
10
  export const EVIDENCE_SOURCES = [
21
- // Also the source for VIDEO (runtime-event.ts) -- SCREENSHOT's own
22
- // precedent: a captured-artifact *kind* is a RuntimeEventType, not a
23
- // watched *domain*, so it reuses this entry rather than adding one.
11
+ // Also the source for VIDEO (runtime-event.ts): a captured-artifact
12
+ // *kind* is a RuntimeEventType, not a watched domain, so it reuses this
13
+ // entry rather than adding one.
24
14
  "browser-dom",
25
15
  "browser-console",
26
16
  "browser-network",
@@ -28,86 +18,53 @@ export const EVIDENCE_SOURCES = [
28
18
  "backend-process",
29
19
  "process-exit",
30
20
  "http-response-payload",
31
- /** §17 (Test Runner Support, RT-073): TEST_STARTED/PASSED/FAILED, from a runner's own structured reporter output -- never parsed from printed prose (see `packages/test-runner`'s own module doc for why). */
21
+ /** RT-073: TEST_STARTED/PASSED/FAILED from a runner's own structured reporter output, never parsed from printed prose. */
32
22
  "test-runner",
33
23
  /**
34
- * RT-219 (runtime self-observability). Every other value in this list
35
- * names a domain the runtime is *watching* (a browser, a backend
36
- * process, a test runner). `"harness"` names the opposite direction: the
37
- * runtime observing **itself** -- a collector/orchestrator/correlator/
38
- * evidence-store operation that broke on its own terms, not on the
39
- * observed application's. DEC-273's `automation` fault value (Descry's
40
- * own harness broke, not the app) had no evidence this repo could point
41
- * at to positively establish it; this is that evidence's tag.
42
- *
43
- * Deliberately a new `source`, not a repurposing of `COLLECTOR_ERROR`
44
- * alone. `COLLECTOR_ERROR` already existed (`runtime-event.ts`) for "the
45
- * observer failed, not the observed system," but every existing emitter
46
- * stamps it with the *domain* source it was observing when it died
47
- * (`"backend-process"` for a log collector's consume loop, etc.) --
48
- * correct for a collector's own mid-stream failure, but it means a
49
- * COLLECTOR_ERROR row is not on its own distinguishable from ordinary
50
- * domain evidence by `source` alone, only by `eventType`. A harness
51
- * component with no domain of its own (the orchestrator's own
52
- * `Promise.all` around `collector.start()`, for instance) has no honest
53
- * domain source to reuse, and reusing one anyway would make a self-
54
- * failure look like it came from the thing being watched. `"harness"`
55
- * is that missing, honestly-named source -- additive, not a
56
- * retag of any existing emitter.
24
+ * RT-219. Every other source names a domain being watched; `"harness"`
25
+ * is the runtime observing itself — a collector/orchestrator/correlator
26
+ * operation that broke on its own terms, not the app's. Not
27
+ * `COLLECTOR_ERROR`: that's stamped with the domain source being watched
28
+ * when it died, so it's indistinguishable from domain evidence by
29
+ * `source` alone.
57
30
  */
58
31
  "harness",
59
32
  /**
60
- * `DEC-NEXT-fault-layer-empirical-confirmation.md`'s `dependency`
61
- * mechanism (`@descryy/runtime-controller`'s
62
- * `checkDependencyVersions`): a structural comparison finding the
63
- * project's lockfile-declared version of a direct dependency does not
64
- * match the version actually installed under `node_modules` at
65
- * execution time. Same standing as `"harness"` -- a fact the runtime
66
- * establishes about its own execution environment, not an observation of
67
- * the domain under test, so `signal` stays `null` for records carrying
68
- * this source (`classifyEvidenceChannel` fails it closed, same as
69
- * `"harness"`).
33
+ * `checkDependencyVersions`: lockfile-declared dependency version does
34
+ * not match what's actually installed at execution time. Same standing
35
+ * as `"harness"` — a fact about the runtime's own environment, so
36
+ * `signal` stays null for these records (`classifyEvidenceChannel` fails
37
+ * closed).
70
38
  */
71
39
  "dependency-check",
72
40
  /**
73
- * The same ruling's `environment` mechanism
74
- * (`checkEnvironmentVersion`): a structural comparison finding the
75
- * project's declared runner version (`.nvmrc`/`package.json
76
- * engines.node`) does not match the runner version actually observed at
77
- * execution (`process.version`). Same standing as `"dependency-check"`.
41
+ * `checkEnvironmentVersion`: declared runner version (`.nvmrc`/`engines.node`)
42
+ * does not match the observed runner (`process.version`). Same standing
43
+ * as `"dependency-check"`.
78
44
  */
79
45
  "environment-check",
80
46
  ];
81
47
  export const REDACTION_STATUSES = ["not-required", "redacted", "pending-redaction"];
82
48
  /**
83
- * Source-location reliability is not one axis with a probabilistic middle —
84
- * it is three structurally different classes (Agent 3's finding), and
85
- * conflating them into a single confidence number loses exactly the
49
+ * Three structurally different classes, not one axis with a probabilistic
50
+ * middle — collapsing them into a confidence number would lose the
86
51
  * information a reader needs to judge a location claim:
87
52
  *
88
- * - self-contained: the location came from the process's own captured
89
- * state (a Python traceback, a Ruby backtrace, a Go `recover()` frame).
90
- * Accurate when captured; the risk is *capture completeness*, not
53
+ * - self-contained: from the process's own captured state (Python/Ruby
54
+ * traceback, Go `recover()` frame). Risk is capture completeness, not
91
55
  * correctness.
92
56
  * - debug-info-present / debug-info-stripped: a binary's own line-number
93
- * table (Java/Kotlin). A binary outcome — there is no partial case.
94
- * - side-artifact-resolved / side-artifact-stale / side-artifact-missing:
95
- * resolution went through a separate file that can drift or vanish
96
- * (a Node source map, a C# PDB, a Swift dSYM). "We mapped it and it's
97
- * right" and "we mapped it through an artifact that may be stale" are
98
- * different confidence claims, and this type is what lets Evidence say
99
- * which one it is instead of reporting both identically.
100
- * - self-contained-eval-line: same mechanism as self-contained — the
101
- * process's own captured backtrace, nothing translated through a side
102
- * artifact — but the *line* does not index the named file. Ruby's
103
- * `instance_eval`/`eval` frames print a synthetic path,
104
- * `(eval at file.rb:12):1`, where `12` is where `eval` was called from
105
- * but `1` counts lines within the evaluated string, not within
106
- * `file.rb`. Opening `file.rb` at line `1` shows unrelated code, so this
107
- * is not a plain self-contained claim; it is not a side-artifact claim
108
- * either, since nothing was resolved through a separate file. See
109
- * `packages/adapter-ruby/src/ruby-source-location-resolver.ts` for the
110
- * one producer of this value.
57
+ * table (Java/Kotlin) — binary outcome, no partial case.
58
+ * - side-artifact-resolved / -stale / -missing: resolved through a
59
+ * separate file that can drift or vanish (source map, PDB, dSYM) —
60
+ * "mapped and right" vs. "mapped through something that may be stale"
61
+ * are different claims.
62
+ * - self-contained-eval-line: same mechanism as self-contained, but the
63
+ * line doesn't index the named file. Ruby's `eval` frames print
64
+ * `(eval at file.rb:12):1` — `12` is the eval call site, `1` counts
65
+ * lines in the evaluated string, not in `file.rb`. Neither plain
66
+ * self-contained nor side-artifact. See
67
+ * `packages/adapter-ruby/src/ruby-source-location-resolver.ts`.
111
68
  */
112
69
  export const SOURCE_LOCATION_RELIABILITIES = [
113
70
  "self-contained",
@@ -119,61 +76,31 @@ export const SOURCE_LOCATION_RELIABILITIES = [
119
76
  "self-contained-eval-line",
120
77
  ];
121
78
  /**
122
- * Whether a captured stack reflects the actual logical call chain is a
123
- * third, orthogonal axis (Agent 3's finding): concurrency models
124
- * (coroutines, goroutines, async/await, tokio tasks) can capture a stack
125
- * successfully while structurally breaking the "reflects the logical
126
- * caller" guarantee. That is not a low-confidence stack — it is a
127
- * different kind of evidence, and gets its own field rather than a lower
128
- * number folded into `confidence`.
79
+ * Orthogonal to `confidence`: concurrency models (coroutines, goroutines,
80
+ * async/await, tokio tasks) can capture a stack successfully while
81
+ * structurally breaking the "reflects the logical caller" guarantee. Not
82
+ * a low-confidence stack — a different kind of evidence, own field.
129
83
  */
130
84
  export const STACK_FIDELITIES = ["synchronous", "concurrency-fragmented", "unavailable"];
131
85
  /**
132
- * Which `SourceLocation` an `Evidence` carries for a given stack — one rule,
133
- * in one place, for every collector that turns a trace into evidence.
134
- *
135
- * ## Why it lives in the contract rather than in each collector
136
- *
137
- * It was written twice. `backend-observation`'s collector was moved onto
138
- * `primaryFrameIndex` (RT-083); `browser`'s console collector kept its own
139
- * `frames[0]` copy and nothing failed, because V8 reports
140
- * `primaryFrameIndex: 0` and the two rules agree there **by coincidence**.
141
- * A copied rule is a rule that will hold in one of them, and this one held
142
- * in one of them for exactly as long as one runtime was involved.
143
- *
144
- * ## The empty location, which is the part that is not obvious
86
+ * Which `SourceLocation` an `Evidence` carries for a stack — one rule, one
87
+ * place, for every collector (was written twice and only agreed by
88
+ * coincidence, RT-083, since V8 always reports index 0).
145
89
  *
146
- * `StackFrame.location` is not nullable, so a frame that resolved nothing
147
- * still carries a `SourceLocation` — one whose `file`, `line` and
148
- * `functionName` are all null. Returning it would set
149
- * `Evidence.sourceLocation` to a non-null object naming nothing, and
150
- * `evidence-package.ts` censuses located evidence with `sourceLocation !==
151
- * null`. An unsymbolicated crash would be counted as *located* in the very
152
- * artifact handed to a model — RT-124's shape (a thing reported as the thing
153
- * it failed to be), one field over.
90
+ * `StackFrame.location` isn't nullable, so an unresolved frame still
91
+ * carries a `SourceLocation` with everything null. Returning it as-is
92
+ * would make `evidence-package.ts`'s `sourceLocation !== null` census
93
+ * count an unsymbolicated crash as located (measured, RT-126: a Swift CI
94
+ * crash with an address-only backtrace).
154
95
  *
155
- * Measured rather than imagined (Lane C, RT-126): on a CI runner a real
156
- * Swift crash produced a real three-thread backtrace in which every frame is
157
- * address-only — no symbol, no `at file:line`.
96
+ * Discriminator is `functionName`, not `file`: a stripped JVM frame and a
97
+ * Rust release frame both have null file but a real symbol, resolvable
98
+ * against the graph by name — keying on `file` would delete the location
99
+ * for every stripped build.
158
100
  *
159
- * ## The discriminator is `functionName`, not `file`
160
- *
161
- * A stripped JVM frame (`at com.example.Thrower.handler(Unknown Source)`)
162
- * and a Rust release frame both have a null file **and a real symbol**,
163
- * which `SourceLocation.file`'s own doc calls real evidence that still
164
- * resolves against the graph by name. `adapter-jvm` and `adapter-rust` each
165
- * assert exactly that. Keying emptiness on a null file would delete the
166
- * location for every stripped build in both languages — the case this type
167
- * was widened to express.
168
- *
169
- * ## Nothing is lost by returning null
170
- *
171
- * The frames stay on `Evidence.stackTrace` with their raw text and their
172
- * `reliability`. "There was no stack" and "there was a stack that could name
173
- * nothing" therefore remain distinguishable **on the same record**, because
174
- * `stackTrace` separates them. That recoverability is the test for whether
175
- * nulling a field is honest degradation or information loss; here it is the
176
- * first.
101
+ * Nothing is lost by returning null: frames stay on `Evidence.stackTrace`
102
+ * with raw text and reliability, so "no stack" and "a stack naming
103
+ * nothing" stay distinguishable on the same record.
177
104
  */
178
105
  export function primaryFrameLocation(stackTrace) {
179
106
  if (stackTrace === null || stackTrace.frames.length === 0)
@@ -190,13 +117,10 @@ export function primaryFrameLocation(stackTrace) {
190
117
  return locationNamesNothing(location) ? null : location;
191
118
  }
192
119
  /**
193
- * True when a location identifies no place in any source.
194
- *
195
- * `column` is deliberately not consulted: a column is an offset into a line,
196
- * so with no line it names no position and cannot make an otherwise-empty
197
- * location informative. `reliability` and `resolvedVia` are not consulted
198
- * either — they record *why* nothing resolved, which describes the failure
199
- * rather than a place.
120
+ * True when a location identifies no place in any source. `column` isn't
121
+ * consulted — an offset into a null line names no position. `reliability`
122
+ * and `resolvedVia` aren't either — they record why nothing resolved, not
123
+ * a place.
200
124
  */
201
125
  export function locationNamesNothing(location) {
202
126
  return location.file === null && location.line === null && location.functionName === null;
@@ -1 +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