@dzhechkov/harness-cli 0.7.6 → 0.7.7

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/.dz-manifest.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  {
11
11
  "path": "README.md",
12
- "sha256": "ba98f7078023a6202a8bf809b83ae20ef44b3d2e1ca14ce0ae5aac83ffd8d51e"
12
+ "sha256": "3d621db3f7811b174ee46b19fa462316ef13679786a910ac64c65fb05bfd5ef7"
13
13
  },
14
14
  {
15
15
  "path": "dist/bin.d.ts",
@@ -33,15 +33,15 @@
33
33
  },
34
34
  {
35
35
  "path": "dist/boolean-flags.d.ts.map",
36
- "sha256": "a8309c4a78c90a1c9db9518a6d07c5fa800c4d39710941a379635a65012e208d"
36
+ "sha256": "bf5eadb6ea3ed4761fbc8206167c86119467d7dfd28d7e0eee7cd21d30099da6"
37
37
  },
38
38
  {
39
39
  "path": "dist/boolean-flags.js",
40
- "sha256": "8cf050f1bc0b69be1088e58cc5f88f034d2e847fba9ffc87f3cc01121d7d9d74"
40
+ "sha256": "2cee996fe21ed692135c98b35bf5e56a89f2dc157f681b36c65020fd062b857b"
41
41
  },
42
42
  {
43
43
  "path": "dist/boolean-flags.js.map",
44
- "sha256": "442b8bbb2ec9f7701ddc2232fc8662956966097d6f46ee1fce49bd06c20db97f"
44
+ "sha256": "68a41f08452af263f2a378b54e813567b6ba52376f3d0e13567a7eef7dff09e0"
45
45
  },
46
46
  {
47
47
  "path": "dist/cli.d.ts",
@@ -49,15 +49,15 @@
49
49
  },
50
50
  {
51
51
  "path": "dist/cli.d.ts.map",
52
- "sha256": "3c0a60e8d8528e1b7df6bf5678388ce14d3ac3d0362bde42bc8e7e712d914dbd"
52
+ "sha256": "c7856b79fdf6683fe855268191805ed07b1c68f2ff7ac544d46ac3d93e4c94ef"
53
53
  },
54
54
  {
55
55
  "path": "dist/cli.js",
56
- "sha256": "f117e676f0a120e1314f3cc6416901931d9b389d97052985e1150fa75322b221"
56
+ "sha256": "27741d68ac996a060df7161b49e372f68e31b990a406f0792c79c474ff17eeca"
57
57
  },
58
58
  {
59
59
  "path": "dist/cli.js.map",
60
- "sha256": "718f0380983cb995fad2a30b87af79feb3b0c85656449957bada67956e7e8854"
60
+ "sha256": "bea844c256e8d947464a4690d2224e4f28d61f433d6e50e5fe26bed3b415ae26"
61
61
  },
62
62
  {
63
63
  "path": "dist/core-compat.d.ts",
@@ -113,15 +113,15 @@
113
113
  },
114
114
  {
115
115
  "path": "dist/known-flags.d.ts.map",
116
- "sha256": "93d7a002824ed631f1459e922ac2cad08772e06a21777b64eed095933dd0e889"
116
+ "sha256": "1e6f9fd92734216f3cc392fba9e2ec7899492a6892e5891197bc582c886a38fc"
117
117
  },
118
118
  {
119
119
  "path": "dist/known-flags.js",
120
- "sha256": "64928f5f20cc647f86323b4d179c614613635eeb6a553fd7733bf5ebad653d70"
120
+ "sha256": "fea029550cb557c73eea2d53d94ef09ec99ba353126a5090a658dc219e8ae5df"
121
121
  },
122
122
  {
123
123
  "path": "dist/known-flags.js.map",
124
- "sha256": "3cb9b072c57a3d9562cfb919c11c2b242db215169a4675b9940de46b67e0ccfa"
124
+ "sha256": "1b46a6093d0ff5713c870b5b7566623c98a33bb212c7f1ba0c56f336620961a3"
125
125
  },
126
126
  {
127
127
  "path": "keys/README.md",
@@ -133,7 +133,7 @@
133
133
  },
134
134
  {
135
135
  "path": "package.json",
136
- "sha256": "4831c7b0121cb2a62464bc4d4844e6037a80f9e2d1e6e0934836bde14a1bffdb"
136
+ "sha256": "b7c47af8811ca86ee8dd5d4d98cab76c4cceddaafbe09676141bacae92b69b9d"
137
137
  },
138
138
  {
139
139
  "path": "src/bin.ts",
@@ -141,11 +141,11 @@
141
141
  },
142
142
  {
143
143
  "path": "src/boolean-flags.ts",
144
- "sha256": "c3ef929a729f53ca612ac67b1571d2e8da3681ac5060a1cd16e453e0bb1d4e00"
144
+ "sha256": "3ea2dd881198881f94675ce14e465ce007e5d987e25b7786f67d9af13e880e22"
145
145
  },
146
146
  {
147
147
  "path": "src/cli.ts",
148
- "sha256": "f30fb7c6b0795758578a90de19b870c4cde42eb2009fa246051023f499374c09"
148
+ "sha256": "d8288240b5420ddca2cabdb7b358c7c18ba59724defda951d0dbc61439b6fc4c"
149
149
  },
150
150
  {
151
151
  "path": "src/core-compat.ts",
@@ -161,9 +161,9 @@
161
161
  },
162
162
  {
163
163
  "path": "src/known-flags.ts",
164
- "sha256": "b08dc5d28795419f642df56fbf5cd036a43a06bb1bec5e864f4e538b0a025b13"
164
+ "sha256": "d123f4f88f51a6b6d283a4fe6d2502bb297ad0de4eb1ef6f99f01b86a7da98a0"
165
165
  }
166
166
  ]
167
167
  },
168
- "signature": "az3T9G53JK8QzlVMBBMgoXLUN0Awpx4vfe19JJVYkbN67X5FDWUn8nVhe8IRAIKogxxbmp9lgnLkeYOj/b2YCg=="
168
+ "signature": "OQCEpmIWKpZGhU/+x7WMKAFh0U4l40qE6AIVuUfTE5ACGVyVo5kon78Pw2MG2mNhf//gJwd+vAERs41vWR5rAw=="
169
169
  }
package/README.md CHANGED
@@ -4096,7 +4096,27 @@ npx @dzhechkov/p-replicator init
4096
4096
 
4097
4097
  ## Status
4098
4098
 
4099
- `v0.7.6` — **`dz drift-check` and `dz sync-canonical` stop being a `.claude/skills` gate.** Skill-copy
4099
+ `v0.7.7` — **the observability pass, and one new verb.** `dz feature-adr-record --backfill` fills the
4100
+ run-cost ledger from the host's own workflow record — dry-run by default, `--yes` writes atomically.
4101
+ A derived number is MARKED (`filledFrom`/`filledBy`), a number you typed is never overwritten and any
4102
+ disagreement is reported, and every unfillable row comes back NAMED rather than silently skipped.
4103
+ Two ambiguities are REFUSED rather than guessed: a slug matching more than one run, and a run claimed
4104
+ by more than one row — writing the same total into an L/XL feature's `plan` and `full` rows would
4105
+ double-count it for anyone who sums the column. Only `tokens` is derived; minutes and agents stay
4106
+ null because the run record exposes no duration and the ledger's `agents` column means a different
4107
+ quantity than the spend-bearing agent ids.
4108
+
4109
+ Ledger rows now carry a join key at all: the sandboxed workflow cannot know its own run id, so
4110
+ `dz feature-adr-record --kind ledger` resolves it at WRITE time — the only moment the run is
4111
+ unambiguous — and stamps it as `runIdSource: 'resolved-at-write'`, because a resolved id is an
4112
+ inference and not something the pipeline knew.
4113
+
4114
+ `dz feature-adr-checkpoint` stamps the write instant, so "how long did this stage take" becomes
4115
+ answerable for every future run. `dz doctor` reports AQE store integrity from a log that had 1508
4116
+ rows and no readers. `dz score` gains an `observability-declared` discipline: does the architecture
4117
+ artifact say how anyone would know this feature works? Descriptive, never a gate.
4118
+
4119
+ `v0.7.7` — **`dz drift-check` and `dz sync-canonical` stop being a `.claude/skills` gate.** Skill-copy
4100
4120
  discovery searched `packages/` plus one hardcoded install root, so the four other per-target install
4101
4121
  trees were ungated — measurably: this repo's own Codex install of `feature-adr` under `.agents/skills`
4102
4122
  drifted for a day while `dz sync-canonical feature-adr --check` reported "all 3 copies match
@@ -4110,7 +4130,7 @@ written by `dz init --enrich` is exempt from both the drift verdict and the heal
4110
4130
  cannot delete it. Also: `dz tg-post` gains `--max-per-day`, previously read by the code but
4111
4131
  unregistered.
4112
4132
 
4113
- `v0.7.6` — **the channel sender stops trusting itself.** `dz tg-post` could format-check, provenance-check
4133
+ `v0.7.7` — **the channel sender stops trusting itself.** `dz tg-post` could format-check, provenance-check
4114
4134
  and time-check a post and still publish it twice, or ten more times, or right through an operator who
4115
4135
  wanted everything stopped: nothing counted what had already gone out. It now runs three guards FAIL-CLOSED
4116
4136
  in a fixed order — a **stop-cord** file that halts even a perfect post before any cheaper check, **dedup**
@@ -4124,10 +4144,10 @@ and never inferred from its shape. Also: `dz challenge` is now discoverable from
4124
4144
  (it existed and was reachable only if you already knew the name), and the adversary it assembles is fed all
4125
4145
  five calibration documents rather than a subset.
4126
4146
 
4127
- `v0.7.6` — **a signature-only republish.** `0.7.0` shipped through `pnpm publish` rather than
4147
+ `v0.7.7` — **a signature-only republish.** `0.7.0` shipped through `pnpm publish` rather than
4128
4148
  `dz publish`, so the re-signing step was skipped and 17 of 497 files in the published core did not
4129
4149
  match their signed hashes — the content was correct, the manifest was ten hours stale. Nothing in
4130
- the shipped behaviour changes between `0.7.0` and `0.7.6`; the integrity check stops reporting these
4150
+ the shipped behaviour changes between `0.7.0` and `0.7.7`; the integrity check stops reporting these
4131
4151
  packages as tampered. The one code change is a TEST: the compat case that asserted the workspace
4132
4152
  core sits exactly on `MIN_CORE` is split into an integration half and a boundary half, so a patch
4133
4153
  bump of core no longer reddens it and `MIN_CORE` need not claim a version the CLI does not require.
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-flags.d.ts","sourceRoot":"","sources":["../src/boolean-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAwFhD,CAAC;AAEH,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAc,CAAC;AAElE,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpE"}
1
+ {"version":3,"file":"boolean-flags.d.ts","sourceRoot":"","sources":["../src/boolean-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAyFhD,CAAC;AAEH,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAc,CAAC;AAElE,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpE"}
@@ -20,6 +20,7 @@
20
20
  */
21
21
  export const BOOLEAN_CLI_FLAGS = new Set([
22
22
  'affected',
23
+ 'backfill',
23
24
  'all',
24
25
  'allow-same-family',
25
26
  'allow-same-family-qe',
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-flags.js","sourceRoot":"","sources":["../src/boolean-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IAC5D,UAAU;IACV,KAAK;IACL,mBAAmB;IACnB,sBAAsB;IACtB,KAAK;IACL,OAAO;IACP,WAAW;IACX,MAAM;IACN,OAAO;IACP,KAAK;IACL,WAAW;IACX,UAAU;IACV,WAAW;IACX,OAAO;IACP,SAAS;IACT,cAAc;IACd,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAS;IACT,MAAM;IACN,QAAQ;IACR,WAAW;IACX,oBAAoB;IACpB,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,eAAe;IACf,MAAM;IACN,SAAS;IACT,gBAAgB;IAChB,cAAc;IACd,MAAM;IACN,cAAc;IACd,QAAQ;IACR,SAAS;IACT,MAAM;IACN,cAAc;IACd,MAAM;IACN,OAAO;IACP,YAAY;IACZ,UAAU;IACV,UAAU;IACV,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;IACb,UAAU;IACV,WAAW;IACX,MAAM;IACN,UAAU;IACV,SAAS;IACT,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,WAAW;IACX,oBAAoB;IACpB,mBAAmB;IACnB,QAAQ;IACR,cAAc;IACd,iBAAiB;IACjB,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,UAAU;IACV,MAAM;IACN,OAAO;IACP,aAAa;IACb,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IACP,UAAU;IACV,MAAM;IACN,YAAY;IACZ,iBAAiB;IACjB,KAAK;CACN,CAAC,CAAC;AAEH,gGAAgG;AAChG,MAAM,CAAC,MAAM,qBAAqB,GAAsB,CAAC,OAAO,CAAC,CAAC;AAElE,iGAAiG;AACjG,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,OAAe;IACzD,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtE,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"boolean-flags.js","sourceRoot":"","sources":["../src/boolean-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IAC5D,UAAU;IACV,UAAU;IACV,KAAK;IACL,mBAAmB;IACnB,sBAAsB;IACtB,KAAK;IACL,OAAO;IACP,WAAW;IACX,MAAM;IACN,OAAO;IACP,KAAK;IACL,WAAW;IACX,UAAU;IACV,WAAW;IACX,OAAO;IACP,SAAS;IACT,cAAc;IACd,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAS;IACT,MAAM;IACN,QAAQ;IACR,WAAW;IACX,oBAAoB;IACpB,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,eAAe;IACf,MAAM;IACN,SAAS;IACT,gBAAgB;IAChB,cAAc;IACd,MAAM;IACN,cAAc;IACd,QAAQ;IACR,SAAS;IACT,MAAM;IACN,cAAc;IACd,MAAM;IACN,OAAO;IACP,YAAY;IACZ,UAAU;IACV,UAAU;IACV,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;IACb,UAAU;IACV,WAAW;IACX,MAAM;IACN,UAAU;IACV,SAAS;IACT,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,WAAW;IACX,oBAAoB;IACpB,mBAAmB;IACnB,QAAQ;IACR,cAAc;IACd,iBAAiB;IACjB,QAAQ;IACR,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AC,eAAe,CAAC,CAI1B;AA8CD,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAEvG;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE;IACJ,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAChC,kGAAkG;IAClG,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,GACA,OAAO,CAAC,eAAe,CAAC,CA8D1B;AAutED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAE,KAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA8N5E"}
package/dist/cli.js CHANGED
@@ -16,7 +16,7 @@ import { homedir, tmpdir } from 'node:os';
16
16
  import { createRequire } from 'node:module';
17
17
  import { createSkill, getSkillInfo, listSkillsDetailed, formatSkillLoadFailures, formatSkillApplyFailures, resolveTargetName, formatTargetProblem, formatTargetAliasNote, TARGET_NAMES_SORTED, runDoctor, runInit, resolvePackageSkillRoots, PACKAGE_SKILL_LAYOUTS, benchmarkSkill, benchmarkSkills, scanMcp, reconcileCapabilities, RECONCILE_BANNER, buildRegistry, discoverSkillPackDirs, discoverVerifiablePackDirs, checkUpstream, compareSkills, checkAllUpstream, sweepSkillDrift, syncCanonicalSkill, checkUpgrades, discoverPackages, discoverSourcePackages, fetchAllDownloads, filterByCategory, pretrain, recommend, generatePlugin, publishPackages, runSetup, runMigrate, searchRegistry, runSync, runVerify, runInitAgentsMd, runInitGeminiMd, runSyncAgentsPolicy, runSyncCodexHooks, resolveCodexHome, withNamedLockSync,
18
18
  // dz workflow run (feature dz-workflow-run): the pure scheduler + the dispatch adapters.
19
- TRACE_RUNID_RE, WF_RUN_OWNER_HOST, preflight, runWorkflow, makeClaudePDispatcher, makeCodexExecDispatcher, NamedLockTimeoutError, NamedLockCompromisedError, POLICY_SOURCES, detectPolicyDrift, hasPolicyFence, TARGET_NAMES, buildParityMatrix, downgradeForStaleEvidence, findStaleTranscriptEvidence, TARGET_CAPABILITIES, TARGET_SHORT_LABELS, WORKFLOW_TEMPLATES_RETIRED_MESSAGE, parsePlan, isParseErrors, validatePlan, normalizePlan, planDigest, toTraceProjection, renderPlan, mergeRender, lint, lintExitCode, LOOP_BLOBS, parseTrace, assembleTimeline, runInvariants, deriveAttestation, stampAttestation, corroborate, NOT_WITNESSED, renderTimelineHtml, importEcc, recordPattern, resolveLearningBackend, storeStats, consolidateSessions, pruneNoisePatterns, lessonDeltaReport, removePatternsByIds, snapshotStore, recallHybrid, teachGuard, mirrorPatternsToVector, mirrorEntriesToVector, patternVectorEntry, readMemoryLearningConfig, promotePatterns, quarantineExpiryCandidates, pruneQuarantinePatterns, clearAgentdbQuarantine, vectorMirrorEnabled, vectorTierStatus, resolveVectorEngine, reindexVectorStore, harmonizeVectorStore, importRvfCheckpoint, statuslineData, writeFeatureAdrState, computeUsage, deriveCostLedger, renderCostLedger, verifyCostLedgerReport, writeCostLedgerJsonl, COST_LEDGER_SCOPE, deriveUsageCalibration, normalizeClaudeUsageModelKey, readUsageLimits, parseWeeklyResetAnchor, claimCheck, summarize, queryBookKnowledge, loadStorePatternsSync, patternRecordId, loadStoreRecords, recordToPattern, bundleSkills, brainHome, listBrain, bookKbPath, promoteProjectToBrain, updateBrainSource, queryBrain, groundPrompt, expandKu, reindexBrainVectors, buildPrimer, exportBrainSlice, importBrainSlice, registerKusToBrain, RECALL_USAGE_LOG_RELATIVE, RECALL_USAGE_LOG_MAX_BYTES, parseRecallUsageLog, buildRecallUsageReport, EVENT_CHAIN_TAIL_BYTES, EMPTY_LOG_TAIL, readTailInfo, appendChainedLines, verifyEventChainText, buildManifest, buildSbom, resolveTrustRoot, decideVerifyPolicy, generateSigningKeypair, evaluateGuard, resolveRules, auditRecord, guardExitCode, DEFAULT_RULES, parsePnpmLockImporters, scannableStubPath,
19
+ TRACE_RUNID_RE, WF_RUN_OWNER_HOST, preflight, runWorkflow, makeClaudePDispatcher, makeCodexExecDispatcher, NamedLockTimeoutError, NamedLockCompromisedError, POLICY_SOURCES, detectPolicyDrift, hasPolicyFence, TARGET_NAMES, buildParityMatrix, downgradeForStaleEvidence, findStaleTranscriptEvidence, TARGET_CAPABILITIES, TARGET_SHORT_LABELS, WORKFLOW_TEMPLATES_RETIRED_MESSAGE, parsePlan, isParseErrors, validatePlan, normalizePlan, planDigest, toTraceProjection, renderPlan, mergeRender, lint, lintExitCode, LOOP_BLOBS, parseTrace, assembleTimeline, runInvariants, deriveAttestation, stampAttestation, corroborate, NOT_WITNESSED, renderTimelineHtml, importEcc, recordPattern, resolveLearningBackend, storeStats, consolidateSessions, pruneNoisePatterns, lessonDeltaReport, removePatternsByIds, snapshotStore, recallHybrid, teachGuard, mirrorPatternsToVector, mirrorEntriesToVector, patternVectorEntry, readMemoryLearningConfig, promotePatterns, quarantineExpiryCandidates, pruneQuarantinePatterns, clearAgentdbQuarantine, vectorMirrorEnabled, vectorTierStatus, resolveVectorEngine, reindexVectorStore, harmonizeVectorStore, importRvfCheckpoint, statuslineData, writeFeatureAdrState, computeUsage, deriveCostLedger, planLedgerBackfill, listCostLedgerRuns, resolveLedgerRunId, AMBIGUOUS, stampCheckpointLine, LEDGER_FILL_SOURCE, renderCostLedger, verifyCostLedgerReport, writeCostLedgerJsonl, COST_LEDGER_SCOPE, deriveUsageCalibration, normalizeClaudeUsageModelKey, readUsageLimits, parseWeeklyResetAnchor, claimCheck, summarize, queryBookKnowledge, loadStorePatternsSync, patternRecordId, loadStoreRecords, recordToPattern, bundleSkills, brainHome, listBrain, bookKbPath, promoteProjectToBrain, updateBrainSource, queryBrain, groundPrompt, expandKu, reindexBrainVectors, buildPrimer, exportBrainSlice, importBrainSlice, registerKusToBrain, RECALL_USAGE_LOG_RELATIVE, RECALL_USAGE_LOG_MAX_BYTES, parseRecallUsageLog, buildRecallUsageReport, EVENT_CHAIN_TAIL_BYTES, EMPTY_LOG_TAIL, readTailInfo, appendChainedLines, verifyEventChainText, buildManifest, buildSbom, resolveTrustRoot, decideVerifyPolicy, generateSigningKeypair, evaluateGuard, resolveRules, auditRecord, guardExitCode, DEFAULT_RULES, parsePnpmLockImporters, scannableStubPath,
20
20
  // guard-promotion (feature guard-promotion, scout idea #1)
21
21
  assembleCandidates, renderPromotionReport, renderPromotionAdr, normalizePromotionState, nextPromotionState, globMatch, promotionAdrRelPath, DEFAULT_WINDOW_DAYS, DEFAULT_PERIODS, MAX_CONTENT_FETCHES, BUILTIN_COVERAGE, decideProvenance, isInsideTree, signManifest, verifyManifest, listSignablePackFiles, assertKeyOutsideTree, decidePublishGate, collectPackageFacts, planReleaseGates, selectAffectedPackages, classifyGateExecutions, buildFailureIssue, buildReleaseNotes, releaseTagName, firstOutputLine, formatPublishError, MANIFEST_NAME, SBOM_NAME, buildArchitectureMap, renderMapHuman, findArchitectureDrift, renderDriftReport, scanWorkspacePackages, loadSubsystemManifest, loadProductVision, checkFeatureAgainstArchitecture, renderArchCheck, planProjectSkills, guidanceForStage, renderInjectionReport, analyzeCorpus, renderRakeReport, renderCriticSection, rakeAsLesson, rakeReward, DEFAULT_RAKE_THRESHOLDS, streamSessionEvents, findLatestTranscript, detectProcessRakes, buildRetro, renderRetro, retroLessonText, PROCESS_SIGNATURES, RETRO_DOMAIN, scanForSetup, buildSetupPlan, scaffoldFromSpec, renderScaffoldPreview, readExistingForScaffold, assembleChallengeContext, buildChallengeBrief, planDiscriminationCheck, classifyDiscrimination, classifyExecutionEvidence, pickAdversaryModel, CHALLENGE_QUESTIONS, loadOutcomes, renderOutcomes, statsForKey, selectAutoCost, recordProvisional, finalizeOutcome, harvestStageOutcomes, recommendModels, planFeed, GRADE_SUCCESS_FLOOR, COST_LADDER, splitScenarios, budgetPlan, selectWinner, proseScopeOk, renderProseDiff, readScenarioIds, DEFAULT_MAX_JUDGE_RUNS, collectDeliveryFacts, planDeliveryCheck, renderDeliveryBrief, classifyDelivery, isUsablePlaneResult, renderDeliveryReview, scanSkillsLayout, declaredPluginSurface, parseInitFacts, verifyRegistration, buildContentProbePrompt, classifyContentProbe, renderContentProbe, findNonRegistrableSkillDirs, assembleCompoundingReport,
22
22
  // Cold-vs-warm EPOCH RUNNER (feature epoch-replay) — orchestrates + scores, never calls a model.
@@ -10320,8 +10320,111 @@ async function cmdRecap(options, flags, cwd, write) {
10320
10320
  }
10321
10321
  return 0;
10322
10322
  }
10323
+ /**
10324
+ * `dz feature-adr-record --backfill` — fill the run-cost ledger from the host workflow records.
10325
+ *
10326
+ * MEASURED 2026-08-25: of 87 ledger rows, all 20 written automatically carried
10327
+ * `tokens:null, minutes:null, agents:null`, so cost-per-feature was answerable only for the 66 rows
10328
+ * a human retyped. The numbers exist in the host record; the sandboxed workflow simply cannot reach
10329
+ * them. This is that join, run afterwards, on the dz side.
10330
+ */
10331
+ function cmdLedgerBackfill(options, flags, cwd, write) {
10332
+ const json = flags.has('json');
10333
+ const apply = flags.has('yes');
10334
+ const ledgerPath = resolve(options.get('project') ?? cwd, '.dz', 'feature-adr', 'run-cost-ledger.jsonl');
10335
+ if (!existsSync(ledgerPath)) {
10336
+ const msg = `dz feature-adr-record --backfill: no ledger at ${ledgerPath}`;
10337
+ write(json ? JSON.stringify({ ok: false, reason: 'no-ledger', path: ledgerPath }) : msg);
10338
+ return 1;
10339
+ }
10340
+ const raw = readFileSync(ledgerPath, 'utf-8');
10341
+ const lines = raw.split('\n').filter((l) => l !== '');
10342
+ const cache = new Map();
10343
+ // Only `tokens` is derived, and the scope is narrow on purpose:
10344
+ // • minutes — CostLedgerReport exposes startedTs but no run duration; there is nothing to divide.
10345
+ // • agents — the ledger column means TOTAL agent invocations including infra agents, while the
10346
+ // union of row.agentIds counts only agents that SPENT. Writing the second into the first would
10347
+ // quietly redefine the column, which that column's own writer explicitly warns against.
10348
+ const factsFor = (runId) => {
10349
+ try {
10350
+ const report = deriveCostLedger({ runId });
10351
+ if (report === null)
10352
+ return null;
10353
+ const tokens = typeof report.recordTotalTokens === 'number' && Number.isFinite(report.recordTotalTokens)
10354
+ ? report.recordTotalTokens
10355
+ : null;
10356
+ return { tokens, minutes: null, agents: null };
10357
+ }
10358
+ catch {
10359
+ return null;
10360
+ }
10361
+ };
10362
+ const facts = (key, value) => {
10363
+ const ck = key + ':' + value;
10364
+ const hit = cache.get(ck);
10365
+ if (hit !== undefined)
10366
+ return hit;
10367
+ let out = null;
10368
+ if (key === 'runId') {
10369
+ out = factsFor(value);
10370
+ }
10371
+ else {
10372
+ // The slug is the fallback because the sandboxed workflow cannot know its own run id. It is
10373
+ // only usable when it names exactly ONE host run: deriveCostLedger resolves a slug with
10374
+ // `runs.find(...)`, which takes the FIRST match SILENTLY, so a feature run twice would have
10375
+ // one run's spend written into the other run's row and called measured. Count first, refuse
10376
+ // on more than one.
10377
+ try {
10378
+ const matches = listCostLedgerRuns().filter((r) => r.slug === value);
10379
+ if (matches.length > 1)
10380
+ out = AMBIGUOUS;
10381
+ else if (matches.length === 1 && matches[0] !== undefined)
10382
+ out = factsFor(matches[0].runId);
10383
+ }
10384
+ catch {
10385
+ out = null;
10386
+ }
10387
+ }
10388
+ cache.set(ck, out);
10389
+ return out;
10390
+ };
10391
+ const plan = planLedgerBackfill({ lines, facts });
10392
+ const unfilled = plan.rows.filter((r) => r.skipped !== null && r.skipped !== 'already-complete');
10393
+ if (apply && plan.filledRows > 0) {
10394
+ // Atomic replace: a torn ledger is worse than an unfilled one.
10395
+ const tmp = ledgerPath + '.backfill-tmp';
10396
+ writeFileSync(tmp, plan.lines.join('\n') + '\n', 'utf-8');
10397
+ renameSync(tmp, ledgerPath);
10398
+ }
10399
+ if (json) {
10400
+ write(JSON.stringify({
10401
+ ok: true, applied: apply && plan.filledRows > 0, filledRows: plan.filledRows,
10402
+ totalRows: lines.length, disagreements: plan.disagreements,
10403
+ unfilled: unfilled.map((r) => ({ index: r.index, runId: r.runId, reason: r.skipped })),
10404
+ source: LEDGER_FILL_SOURCE, path: ledgerPath,
10405
+ }));
10406
+ return 0;
10407
+ }
10408
+ write('dz feature-adr-record --backfill: SCOPE — only tokens is derived; minutes and agents stay null (the run record exposes no duration, and the agents column means a different quantity than the spend-bearing agent ids). A row without a runId is matched by SLUG, and only when the slug names exactly one run.');
10409
+ write(`dz feature-adr-record --backfill: ${plan.filledRows} of ${lines.length} row(s) fillable from the host record${apply ? ' — WRITTEN' : ' (dry run; pass --yes to write)'}`);
10410
+ for (const d of plan.disagreements) {
10411
+ write(` DISAGREEMENT row ${d.index} ${d.field}: ledger says ${d.existing}, host record says ${d.derived} — the typed number stands, look at this`);
10412
+ }
10413
+ const byReason = new Map();
10414
+ for (const r of unfilled)
10415
+ byReason.set(String(r.skipped), (byReason.get(String(r.skipped)) ?? 0) + 1);
10416
+ for (const [reason, n] of byReason)
10417
+ write(` not filled: ${n} row(s) — ${reason}`);
10418
+ return 0;
10419
+ }
10323
10420
  function cmdFeatureAdrRecord(options, flags, cwd, write) {
10324
10421
  const json = flags.has('json');
10422
+ // `--backfill` is a different verb on the same store: it fills the ledger's null cost fields from
10423
+ // the host's own workflow record. DRY-RUN BY DEFAULT — this rewrites an append-only log, so the
10424
+ // writing form must be asked for (`--yes`), the same contract `dz publish` and `sync-canonical`
10425
+ // already use. See ledger-backfill.ts for the four rules the plan obeys.
10426
+ if (flags.has('backfill'))
10427
+ return cmdLedgerBackfill(options, flags, cwd, write);
10325
10428
  const kind = (options.get('kind') ?? '').trim();
10326
10429
  const stage = (options.get('stage') ?? '').trim();
10327
10430
  const slug = (options.get('slug') ?? '').trim();
@@ -10362,6 +10465,11 @@ function cmdFeatureAdrRecord(options, flags, cwd, write) {
10362
10465
  });
10363
10466
  if (decision.line === null)
10364
10467
  return emit(decision);
10468
+ // Declared out here because the READ-BACK below must verify what was ACTUALLY written, not what
10469
+ // the decision proposed — the ledger path enriches the line with a resolved runId before the
10470
+ // append, and comparing against the pre-enrichment text made every ledger write report
10471
+ // "not-verified" (caught by running it, not by reading it).
10472
+ let lineToWrite = decision.line;
10365
10473
  // MEASURE, never assume: an unwritable target is a LOUD refusal, because a swallowed mkdir failure
10366
10474
  // is exactly how a write becomes a silent no-op (acid case A4).
10367
10475
  try {
@@ -10383,7 +10491,28 @@ function cmdFeatureAdrRecord(options, flags, cwd, write) {
10383
10491
  return emit({ verdict: 'refused', exit: 2, reason: `the target could not be prepared: ${err.message}`, blocking: false, line: null });
10384
10492
  }
10385
10493
  try {
10386
- appendFileSync(target, `${decision.line}\n`, 'utf-8');
10494
+ // WRITE-TIME RUN-ID RESOLUTION. The sandboxed workflow cannot know its own run id — it is not in
10495
+ // `args` and not a sandbox global — so 16 of 20 automatic ledger rows carried no join key at all
10496
+ // and nothing could ever be joined to them (MEASURED 2026-08-25). This command runs on the host,
10497
+ // where the records live, so it answers the question the sandbox cannot. Resolving HERE beats
10498
+ // resolving later: right now the run is in flight and is simply the newest for this slug; an hour
10499
+ // from now the same slug may have several and the choice becomes a guess. Refuses on any tie.
10500
+ lineToWrite = decision.line;
10501
+ if (kind === 'ledger') {
10502
+ try {
10503
+ const parsed = JSON.parse(decision.line);
10504
+ if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
10505
+ const rowObj = parsed;
10506
+ const resolved = resolveLedgerRunId(rowObj, listCostLedgerRuns());
10507
+ if (resolved !== null) {
10508
+ // Marked, because a resolved run id is our inference, not something the pipeline knew.
10509
+ lineToWrite = JSON.stringify({ ...rowObj, runId: resolved, runIdSource: 'resolved-at-write' });
10510
+ }
10511
+ }
10512
+ }
10513
+ catch { /* resolution is an ENRICHMENT; a failure must never cost the row itself */ }
10514
+ }
10515
+ appendFileSync(target, `${lineToWrite}\n`, 'utf-8');
10387
10516
  }
10388
10517
  catch (err) {
10389
10518
  return emit({ verdict: 'refused', exit: 2, reason: `the append failed: ${err.message}`, blocking: false, line: null });
@@ -10398,7 +10527,7 @@ function cmdFeatureAdrRecord(options, flags, cwd, write) {
10398
10527
  catch {
10399
10528
  lastLine = null;
10400
10529
  }
10401
- return emit(decideReadBack(decision.line, lastLine), { target });
10530
+ return emit(decideReadBack(lineToWrite, lastLine), { target });
10402
10531
  }
10403
10532
  function cmdAmendmentCheck(options, flags, cwd, write) {
10404
10533
  const json = flags.has('json');
@@ -10564,7 +10693,9 @@ function cmdFeatureAdrCheckpoint(options, flags, cwd, write) {
10564
10693
  const stateDir = join(featureDir, '.fa-state');
10565
10694
  try {
10566
10695
  mkdirSync(stateDir, { recursive: true });
10567
- appendFileSync(join(stateDir, 'checkpoints.jsonl'), verdict.line + '\n', 'utf-8');
10696
+ // The CLI is the only participant with a clock — the sandboxed workflow has no `Date` — so the
10697
+ // write instant is stamped here, at the append, and nowhere inside the blob-mirrored serializer.
10698
+ appendFileSync(join(stateDir, 'checkpoints.jsonl'), stampCheckpointLine(verdict.line, new Date().toISOString()) + '\n', 'utf-8');
10568
10699
  }
10569
10700
  catch (err) {
10570
10701
  const reason = err instanceof Error ? err.message : String(err);