Repository navigation
fix(observability): ConsoleLogger and JsonLogger record an error's cause chain - #37716
Conversation
…use chain Both loggers now add `causes` (message and stack per link, at most five links, cycle-safe) beside `error` and `stack`, in the shape faultCauseChain and ObjectLogger record. The helper is a pinned copy, since the package depends on @objectstack/spec alone; a parity test against faultCauseChain (devDependency on @objectstack/types, aliased to source) holds the two to one output. core's parity fixture now glues every redact qualifier to a default word. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
…020 lib Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
📓 Docs Drift Check16 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin e41bcf21d8769eafb528451a68904ac1b309d150 && git checkout e41bcf21d8769eafb528451a68904ac1b309d150
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f722411eddac2c3e34235cd7a5ba1ccdda4d40d4 80855b22b02063419c2db2e6dab9bb9b2983eb0c && git checkout -B drift-repro f722411eddac2c3e34235cd7a5ba1ccdda4d40d4 && git merge --no-ff 80855b22b02063419c2db2e6dab9bb9b2983eb0c
node scripts/docs-audit/affected-docs.mjs --json f722411eddac2c3e34235cd7a5ba1ccdda4d40d4 |
… field Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Test UI (11/16) on head This PR's tree does not reach that test. The diff is |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 80855b2 · 2026-11-27T00:51Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Inputs read: card #37658 (body, triage, unblock, claim, os-dev report, claim amendment), PR #37716 (body, 7 files, net diff against ① Derived judgments
② Semver levelClause-②: yes (widening) — confirmed. The change is an additive, optional field on a log record that already merges arbitrary caller Existing parsers of ③ Boundary flags
Findings:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Adding |
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Landing: ACCEPT 7206892683 (contract record 7206884238, PASS) at head
Status: ready + auto-merge (merge queue). On MERGED, #37658 closes by |
Fixes #37658
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
packages/observability/src/loggers.ts:ConsoleLoggerandJsonLoggererror()/fatal()now addcausesbesideerrorandstackwhen the error carries acausechain: one entry per link, outermost first, each the link's message and stack; at most five links, a cycle stopped at its first repeat, and a marker entry whenever the chain was cut. An error with nocauselogs byte-identically to before (causesomitted).faultCauseChain(@objectstack/types), because@objectstack/observabilitydepends on@objectstack/specalone. No runtime dependency added; no export added.packages/observability/package.json: devDependency on@objectstack/types(workspace), for the parity test only;vitest.config.tsaliases it to source (check:test-source-alias), with the preset's console-intercept setting spelled in place (the plugin-email precedent).packages/core/src/logger-error-cause.test.ts(N4 of the contract record on PR fix(types,core): the 5xx fault log and ObjectLogger print an error's cause chain #37652): the parity block gains one fixture that glues each of the 31 glued redact qualifiers to a default word, plus a control proving the fixture exercises each qualifier, so a list edit in either copy fails the parity test.ObjectLoggerandlogServerFaultare unchanged.Tests
observability: test + typecheck (head d2a09be)
pnpm --filter @objectstack/observability testthentypecheck, under the verify lock:Test Files 7 passed (7)·Tests 120 passed (120)· bothtscprograms clean ·VERDICT command-exit 0.loggers.test.tsalone:Tests 44 passed (44)— per logger: each cause's message and stack, the no-cause control, a cycle, a deep chain cut at the limit;fatalfor both; 12 parity fixtures per logger againstfaultCauseChain.core: test + typecheck (head d2a09be)
pnpm --filter @objectstack/core testthentypecheck:Test Files 158 passed (158)·Tests 3791 passed (3791)·VERDICT command-exit 0.Ablation — the cause reading in errorFields (one, as ordered)
node scripts/ablation-replace.mjs --file packages/observability/src/loggers.ts --anchor " const causes = causeChain(error);" --replacement " const causes: CauseLine[] = []; // ABLATION"around the loggers test file. Landed: anchor 1 to 0, blob d037c912f881 to 3aed5820db82. Result:Tests 30 failed | 14 passed (44)— every cause, cycle, depth, fatal and non-empty parity case red; the 14 green are the pre-existing cases, the two no-cause controls, the fixture control and the throwing-getter parity case (an empty chain both ways). Restored: blob equals HEAD (d037c912f881),git diff HEADempty. The test imports../loggers.jsfrom source, so no build or dist leg applies.Acceptance notes
GLUED_QUALIFIERSfixture lists are hand copies of the list: a qualifier REMOVED from any copy fails a parity test; one ADDED to a single copy fails nothing until the fixture list grows too.@objectstack/observabilitynow carries the third copy of the cause-chain helper (types, core, observability), each pinned tofaultCauseChainby a parity test.Verification
Read first:
packages/observability/src/loggers.ts(errorFields,causeChain— the only behaviour change),packages/observability/src/__tests__/loggers.test.ts(parity block),packages/observability/vitest.config.ts.Two-minute check:
pnpm --filter @objectstack/observability exec vitest run --maxWorkers=2 src/__tests__/loggers.test.tsprintsTests 44 passed (44).🤖 Generated with Claude Code
https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
Generated by Claude Code