@gitroll/tacitt-cli 0.6.12 → 0.6.14

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 (46) hide show
  1. package/dist/{agent-setup-B12VbvN_.mjs → agent-setup-CEPQfjBv.mjs} +2 -2
  2. package/dist/agent-setup-worker.mjs +5 -5
  3. package/dist/cli.mjs +10 -10
  4. package/dist/codex-title-worker.mjs +1 -1
  5. package/dist/configured-preview-worker.mjs +5 -5
  6. package/dist/configured-session-worker.mjs +5 -5
  7. package/dist/{frame-B3He21G8.mjs → frame-CRm99088.mjs} +1 -1
  8. package/dist/{heap-Blrat--4.mjs → heap-Bh9tySJp.mjs} +12 -7
  9. package/dist/inspection-worker.mjs +4 -4
  10. package/dist/{job-CBuIMTQ0.mjs → job-CsWKWcM4.mjs} +135 -36
  11. package/dist/{locate-D-ZaHpI0.mjs → locate-CP2t26j2.mjs} +449 -244
  12. package/dist/{model-DR9odhWP.mjs → model-ChHuVKoB.mjs} +1 -1
  13. package/dist/operation-executor.mjs +3 -3
  14. package/dist/preview-worker.mjs +1 -1
  15. package/dist/privacy-validator.mjs +1 -1
  16. package/dist/{query-BYDcNKy2.mjs → query-D28k3XOr.mjs} +6044 -5706
  17. package/dist/{run-DQ9xyKSt.mjs → run-CiJmV__5.mjs} +6 -6
  18. package/dist/{src-Do-qzuMn.mjs → src-B3il9x5F.mjs} +617 -545
  19. package/dist/{src-CKQlTA2Z.mjs → src-CWMrGXJK.mjs} +180 -30
  20. package/dist/{src-DeNJ8vOD.mjs → src-CmvEJj46.mjs} +1806 -1690
  21. package/dist/store-database-worker.mjs +1 -1
  22. package/dist/web/assets/index-XdWDOC5H.js +172 -0
  23. package/dist/web/index.html +1 -1
  24. package/package.json +1 -1
  25. package/skills/tacitt/INDEX.md +1 -1
  26. package/skills/tacitt/SKILL.md +5 -3
  27. package/skills/tacitt/references/INDEX.md +2 -2
  28. package/skills/tacitt/references/b-method.md +4 -2
  29. package/skills/tacitt/references/bootstrap.md +1 -1
  30. package/skills/tacitt/references/commands.md +23 -4
  31. package/skills/tacitt/references/journey.md +5 -3
  32. package/skills/tacitt/references/parallel-review.md +22 -9
  33. package/skills/tacitt/references/remote-workers.md +6 -2
  34. package/skills/tacitt/scripts/INDEX.md +5 -5
  35. package/skills/tacitt/scripts/answer.mjs +12 -1
  36. package/skills/tacitt/scripts/describe.mjs +3 -2
  37. package/skills/tacitt/scripts/journey-classification-tasks.mjs +2 -0
  38. package/skills/tacitt/scripts/journey-classification.mjs +1 -0
  39. package/skills/tacitt/scripts/journey-scan-timing.mjs +3 -2
  40. package/skills/tacitt/scripts/journey-state.d.mts +3 -0
  41. package/skills/tacitt/scripts/journey-state.mjs +8 -1
  42. package/skills/tacitt/scripts/journey.mjs +31 -1
  43. package/skills/tacitt/scripts/privacy-validator.mjs +160 -40
  44. package/skills/tacitt/scripts/review.d.mts +1 -0
  45. package/skills/tacitt/scripts/review.mjs +296 -35
  46. package/dist/web/assets/index-BgDdPL1c.js +0 -172
@@ -1,5 +1,5 @@
1
- import "./locate-D-ZaHpI0.mjs";
2
- import "./src-Do-qzuMn.mjs";
1
+ import "./locate-CP2t26j2.mjs";
2
+ import "./src-B3il9x5F.mjs";
3
3
  import { z } from "zod";
4
4
  import { Worker } from "node:worker_threads";
5
5
  //#region apps/cli/src/agent-setup/index.ts
@@ -1,8 +1,8 @@
1
- import { X as listAgentSetup } from "./src-DeNJ8vOD.mjs";
2
- import { Nn as createStaticProcessor, _n as workspaceSchema, hn as sessionSchema } from "./locate-D-ZaHpI0.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CKQlTA2Z.mjs";
4
- import { Pi as effectiveTreatmentSchema, ct as maximumAgentSetupSessions } from "./src-Do-qzuMn.mjs";
5
- import "./agent-setup-B12VbvN_.mjs";
1
+ import { Q as listAgentSetup } from "./src-CmvEJj46.mjs";
2
+ import { In as createStaticProcessor, bn as workspaceSchema, vn as sessionSchema } from "./locate-CP2t26j2.mjs";
3
+ import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CWMrGXJK.mjs";
4
+ import { Li as effectiveTreatmentSchema, ct as maximumAgentSetupSessions } from "./src-B3il9x5F.mjs";
5
+ import "./agent-setup-CEPQfjBv.mjs";
6
6
  import { z } from "zod";
7
7
  import { parentPort, workerData } from "node:worker_threads";
8
8
  //#region apps/cli/src/agent-setup/worker.ts
package/dist/cli.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { _ as permissionDiagnostic, a as readAgentPresence, d as packageIdentity, f as createRenderActivity, g as longCommands, h as businessCommands, i as invoke, l as serveDetached, m as parseOptions, n as readOperation, o as createRuntime, p as helpText, r as waitOperation, s as executorEventSchema, t as cancelOperation, u as guardDetachedStartup, v as startupFailure, y as traceStartup } from "./query-BYDcNKy2.mjs";
3
- import { at as makePrivateDirectory, ot as openPrivateFile } from "./src-DeNJ8vOD.mjs";
4
- import { A as createExecutionPort, I as inBackgroundStatusPoll, j as startHost, k as readStateDump } from "./job-CBuIMTQ0.mjs";
5
- import { an as safeField, in as safeCode, nn as ApplicationError } from "./locate-D-ZaHpI0.mjs";
6
- import { Ai as stateSchema, Kr as hostDrives, Wr as awaitingPassport, rt as readWorkspaceOutcomes, ut as resolveFailureLocation, yn as reviewTransportBytes } from "./src-Do-qzuMn.mjs";
7
- import { vt as isCoordinationBusy } from "./heap-Blrat--4.mjs";
2
+ import { _ as permissionDiagnostic, a as readAgentPresence, d as packageIdentity, f as createRenderActivity, g as longCommands, h as businessCommands, i as invoke, l as serveDetached, m as parseOptions, n as readOperation, o as createRuntime, p as helpText, r as waitOperation, s as executorEventSchema, t as cancelOperation, u as guardDetachedStartup, v as startupFailure, y as traceStartup } from "./query-D28k3XOr.mjs";
3
+ import { ct as openPrivateFile, st as makePrivateDirectory } from "./src-CmvEJj46.mjs";
4
+ import { B as inBackgroundStatusPoll, F as startHost, N as readStateDump, P as createExecutionPort } from "./job-CsWKWcM4.mjs";
5
+ import { an as ApplicationError, cn as safeField, sn as safeCode } from "./locate-CP2t26j2.mjs";
6
+ import { Fr as hostDrives, Ni as stateSchema, Nr as awaitingPassport, rt as readWorkspaceOutcomes, ut as resolveFailureLocation, yn as reviewTransportBytes } from "./src-B3il9x5F.mjs";
7
+ import { vt as isCoordinationBusy } from "./heap-Bh9tySJp.mjs";
8
8
  import { constants, createReadStream, write } from "node:fs";
9
9
  import { z } from "zod";
10
10
  import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
@@ -804,11 +804,11 @@ function configureText(agent, source) {
804
804
  const field = agent === "claude" ? "CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS" : Object.hasOwn(section, "max_concurrent_threads_per_session") || !Object.hasOwn(section, "max_threads") ? "max_concurrent_threads_per_session" : "max_threads";
805
805
  const current = section[field];
806
806
  const count = current === void 0 ? void 0 : agent === "claude" ? z.string().regex(/^\d+$/).transform(Number).pipe(z.number().int().positive().safe()).parse(current) : z.number().int().positive().safe().parse(current);
807
- if (count !== void 0 && count >= 16) return {
807
+ if (count !== void 0 && count >= 24) return {
808
808
  text: source,
809
809
  count
810
810
  };
811
- const target = agent === "claude" ? String(16) : 16;
811
+ const target = agent === "claude" ? String(24) : 24;
812
812
  const updated = {
813
813
  ...data,
814
814
  [key]: {
@@ -824,7 +824,7 @@ function configureText(agent, source) {
824
824
  if (object.parse(check[key])[field] !== target) throw new Error("CONFIG_READBACK_FAILED");
825
825
  return {
826
826
  text,
827
- count: 16
827
+ count: 24
828
828
  };
829
829
  } catch (cause) {
830
830
  throw new Error("AGENT_CONFIG_INVALID", { cause });
@@ -841,7 +841,7 @@ async function askAgentConfiguration(clients, scope) {
841
841
  terminal: true
842
842
  });
843
843
  try {
844
- process.stderr.write(`Tacitt CLI uses up to 16 analysis subagents for faster review.\nRaise the concurrent subagent limit to 16 for ${names}? Higher limits can increase concurrent usage.
844
+ process.stderr.write(`Tacitt CLI uses up to 24 analysis subagents for faster review.\nRaise the concurrent subagent limit to 24 for ${names}? Higher limits can increase concurrent usage.
845
845
  ` + (scope === "user" ? "This changes your client settings across projects.\n" : "This changes client settings for this project.\n") + "Save your work and fully restart the affected App or CLI afterward. We will not close it for you.\nAllow this change? [y/N] ");
846
846
  return await new Promise((resolve) => {
847
847
  terminal.once("line", (line) => resolve(/^y(?:es)?$/i.test(line.trim())));
@@ -1,4 +1,4 @@
1
- import { i as errorCode } from "./model-DR9odhWP.mjs";
1
+ import { i as errorCode } from "./model-ChHuVKoB.mjs";
2
2
  import { a as titleHintLimits, i as encodeTitleError, o as titleInputSchema, t as assertTitleHeap } from "./heap-1FYhGds4.mjs";
3
3
  import { stat } from "node:fs/promises";
4
4
  import { isAbsolute, join } from "node:path";
@@ -1,8 +1,8 @@
1
- import { Z as createConfiguredPreviewStream } from "./src-DeNJ8vOD.mjs";
2
- import { Nn as createStaticProcessor, _n as workspaceSchema, hn as sessionSchema } from "./locate-D-ZaHpI0.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CKQlTA2Z.mjs";
4
- import { Pi as effectiveTreatmentSchema } from "./src-Do-qzuMn.mjs";
5
- import { a as classifyRecord, n as assertPreviewHeap, t as runPreview } from "./run-DQ9xyKSt.mjs";
1
+ import { $ as createConfiguredPreviewStream } from "./src-CmvEJj46.mjs";
2
+ import { In as createStaticProcessor, bn as workspaceSchema, vn as sessionSchema } from "./locate-CP2t26j2.mjs";
3
+ import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CWMrGXJK.mjs";
4
+ import { Li as effectiveTreatmentSchema } from "./src-B3il9x5F.mjs";
5
+ import { a as classifyRecord, n as assertPreviewHeap, t as runPreview } from "./run-CiJmV__5.mjs";
6
6
  import { z } from "zod";
7
7
  import { parentPort, workerData } from "node:worker_threads";
8
8
  //#region apps/cli/src/preview/run.ts
@@ -1,8 +1,8 @@
1
- import { N as runConfiguredSessionJob, V as gitSeedsProvider, _ as captureConfiguredSessionJob, f as runConfiguredScanJob, rt as safeError } from "./src-DeNJ8vOD.mjs";
2
- import { d as runJourneyBaseJob, i as runJourneyOutputVerifyJob, n as runJourneyOutputJob, r as runJourneyOutputShardJob } from "./job-CBuIMTQ0.mjs";
3
- import { Nn as createStaticProcessor, br as processingSite, in as safeCode } from "./locate-D-ZaHpI0.mjs";
4
- import { l as createNativeAdapters } from "./src-CKQlTA2Z.mjs";
5
- import "./src-Do-qzuMn.mjs";
1
+ import { N as runConfiguredSessionJob, V as gitSeedsProvider, _ as captureConfiguredSessionJob, at as safeError, f as runConfiguredScanJob } from "./src-CmvEJj46.mjs";
2
+ import { d as runJourneyBaseJob, i as runJourneyOutputVerifyJob, n as runJourneyOutputJob, r as runJourneyOutputShardJob } from "./job-CsWKWcM4.mjs";
3
+ import { Cr as processingSite, In as createStaticProcessor, sn as safeCode } from "./locate-CP2t26j2.mjs";
4
+ import { l as createNativeAdapters } from "./src-CWMrGXJK.mjs";
5
+ import "./src-B3il9x5F.mjs";
6
6
  import { parentPort } from "node:worker_threads";
7
7
  //#region packages/artifact/src/configured/parallel/spool-claim.ts
8
8
  /** A worker may create a named file only after the host has recorded its cleanup ownership. */
@@ -1,4 +1,4 @@
1
- import { gr as ProcessingError } from "./locate-D-ZaHpI0.mjs";
1
+ import { yr as ProcessingError } from "./locate-CP2t26j2.mjs";
2
2
  //#region packages/processing/src/compression/frame.ts
3
3
  function createZstdFrameCheck(fail = () => {
4
4
  throw new ProcessingError("PROCESSING_INVALID_RECORD");
@@ -1,6 +1,6 @@
1
- import { C as writePrivateReviewPayload, ct as windowsOwnerOnly, it as exclusiveLock, ot as openPrivateFile, st as restrictToOwner, w as readPrivateReviewPayload } from "./src-DeNJ8vOD.mjs";
2
- import { An as createDetectionSummary, Ft as emptyReviewCorrectionSchema, Ht as termTypeSchema, It as journeyTermSchema, Lt as reviewTermsInputSchema, Nt as privacyTermSchema, Pt as emptyReviewCorrectionResultSchema, Rt as reviewTermsResultSchema, S as validateBReview, a as reviewBatchChunks, b as bContextEvidence, bt as journeyWorkSuggestionSchema, c as reviewDigest, cn as reviewFamilies, d as validateReview, f as findingReferenceKey, g as reviewAlignmentSchema, gt as journeyGuidanceSchema, l as reviewSubmitSchema, lt as journeyIdSchema, mt as nativeJourneySchema, nn as ApplicationError, o as reviewBatchSchema, or as isStaticCategory, p as reviewAlignmentAudit, pn as fileIdentitySchema, sn as familySelected, sr as staticCategories, st as journeyDigestSchema, u as textDigest, v as validateReviewAlignment, y as semanticFindingSchema, yt as journeyDescribeSchema } from "./locate-D-ZaHpI0.mjs";
3
- import { $ as validateDetectionSummary, $t as journeyPlaceSchema, Ai as stateSchema, At as validateAttemptAppend, Bn as journeySearchSaveSchema, Bt as newJourneyWork, Ci as withReadingProgress, Cn as scanAliasResourceSchema, Cr as preparationStateSchema, Dn as scanGitSeedsId, En as scanSessionResourceSchema, Fn as journeyInventoryReadSchema, Fr as assertJourneyPrivacyReady, Ft as classificationCommitSchema, Gt as hideFinishSchema, Hn as journeyCommitResultSchema, Ht as journeyContextQuerySchema, In as journeyInventorySchema, J as validateInspectionFence, Jr as obsoleteJourney, Jt as sendOutputQuerySchema, Kn as confirmedHideDeltaSchema, Kt as hidePublishSchema, Ln as journeyPreparationProgressSchema, Lr as reconcileReaderKeeps, Mt as journeyBatchReadSchema, Nn as projectPreparationProgress, Nt as journeyReviewStorageQuerySchema, Ot as settleCorrections, Pr as applyCardAnswers, Pt as applyClassificationProposal, Q as validateInspectionContribution, Qt as journeyIsolateSchema, Sr as preparationStartSchema, Tr as validatePreparationFacts, U as validateInspectionBatch, Un as journeyCommitSchema, Ut as journeyContextSchema, Vn as searchScopeDigest, W as validateInspectionBatches, Wn as journeyEventSchema, Wt as hideBeginSchema, X as validateInspectionInputs, Xr as sendReachedPassport, Xt as journeyResourceQuerySchema, Y as validateInspectionHead, Yn as settleConfirmedHides, Yr as sendOwesPassport, Yt as sendOutputSchema, Z as validateInspectionQuery, Zt as journeyResourceSchema, an as sessionReconcileResultSchema, bi as isSkippedWork, bn as bReviewDigest, br as preparationPermissionSchema, c as reconstructBFields, ci as journeySendSchema, cn as sessionRereadResourceSchema, d as resolveGroupSplit, dn as sessionReviewResourceSchema, ei as mergePrivacyTerms, en as sortingApplySchema, et as inspectionInputs, fn as sessionReviewStatusSchema, fr as maskedHitsStale, g as semanticGroupKey, gn as reviewCandidateResourceSchema, gr as workPrivacyDecisions, gt as manualUploadSchema, h as hideScopeDigest, hi as hasCompleteWorkDescription, hr as workDecisionDigest, jn as validateScanExclusion, jt as journeyGuidance, kt as attemptBudgetCodePoints, l as chooseCheapPlacement, lr as confirmedHideTerms, mn as sessionUsefulnessResourceSchema, mr as retireWorkDescription, nn as reviewAttemptsQuerySchema, o as bRereadDigest, on as sessionReconciliationResourceSchema, or as confirmedHideGroupIds, pi as sendSessionUploadSchema, pn as sessionUsefulnessInputSchema, pr as syncTermGroups, pt as manualUploadBindingSchema, q as validateInspectionClaim, qt as journeyPolicyRespondSchema, ri as staticSessionId, rn as reviewAttemptsResultSchema, rr as bMaskedHits, s as reconcileBSession, sr as confirmedHideKey, t as scanBatchContextDigest, tn as reviewAttemptResourceSchema, u as reviseGroupMembership, un as sessionReviewQuerySchema, ur as dictionaryHides, v as projectJourneyInventory, vi as isReadingComplete, vn as reviewRepairResourceSchema, vt as candidateSortAvailable, wn as scanCanonicalResourceSchema, wr as preparationUpdateSchema, x as bReviewScope, xi as selectedWorks, xn as mergeBRepair, xr as preparationSettlementSchema, y as preparationScope, yi as isSelectedWork, yr as preparationBeginSchema, zn as journeySearchResultSchema, zt as isolatedWorkId } from "./src-Do-qzuMn.mjs";
1
+ import { C as writePrivateReviewPayload, ct as openPrivateFile, lt as restrictToOwner, ot as exclusiveLock, ut as windowsOwnerOnly, w as readPrivateReviewPayload } from "./src-CmvEJj46.mjs";
2
+ import { Bt as reviewTermsResultSchema, C as validateBReview, Ft as privacyTermSchema, It as emptyReviewCorrectionResultSchema, Lt as emptyReviewCorrectionSchema, M as semanticFindingSchema, Nn as createDetectionSummary, Rt as journeyTermSchema, St as journeyWorkSuggestionSchema, Wt as termTypeSchema, an as ApplicationError, b as validateReviewAlignment, c as reviewBatchSchema, d as reviewSubmitSchema, dn as reviewFamilies, dt as journeyIdSchema, f as textDigest, gn as fileIdentitySchema, gt as nativeJourneySchema, h as reviewAlignmentAudit, lr as isStaticCategory, lt as journeyDigestSchema, m as findingReferenceKey, p as validateReview, s as reviewBatchChunks, u as reviewDigest, un as familySelected, ur as staticCategories, v as reviewAlignmentSchema, vt as journeyGuidanceSchema, x as bContextEvidence, xt as journeyDescribeSchema, zt as reviewTermsInputSchema } from "./locate-CP2t26j2.mjs";
3
+ import { $ as validateDetectionSummary, $t as journeyPlaceSchema, At as validateAttemptAppend, Bn as journeySearchResultSchema, Bt as newJourneyWork, Ci as bMaskedHits, Cn as scanAliasResourceSchema, Cr as assertJourneyPrivacyReady, Dn as scanGitSeedsId, En as scanSessionResourceSchema, Fn as journeyInventoryReadSchema, Ft as classificationCommitSchema, Gn as journeyEventSchema, Gt as hideFinishSchema, Hn as searchScopeDigest, Ht as journeyContextQuerySchema, In as journeyInventorySchema, J as validateInspectionFence, Jt as sendOutputQuerySchema, Kr as staticSessionId, Kt as hidePublishSchema, Ln as journeyPreparationProgressSchema, Lr as obsoleteJourney, Mt as journeyBatchReadSchema, Ni as stateSchema, Nn as projectPreparationProgress, Nt as journeyReviewStorageQuerySchema, Ot as settleCorrections, Pt as applyClassificationProposal, Q as validateInspectionContribution, Qt as journeyIsolateSchema, Rr as sendOwesPassport, Sr as applyCardAnswers, Tr as reconcileReaderKeeps, U as validateInspectionBatch, Un as journeyCommitResultSchema, Ur as mergePrivacyTerms, Ut as journeyContextSchema, Vn as journeySearchSaveSchema, W as validateInspectionBatches, Wn as journeyCommitSchema, Wt as hideBeginSchema, X as validateInspectionInputs, Xn as settleConfirmedHides, Xt as journeyResourceQuerySchema, Y as validateInspectionHead, Yt as sendOutputSchema, Z as validateInspectionQuery, Zr as journeySendSchema, Zt as journeyResourceSchema, _i as dictionaryHides, an as sessionReconcileResultSchema, bi as syncTermGroups, bn as bReviewDigest, c as reconstructBFields, ci as isSelectedWork, cn as sessionRereadResourceSchema, cr as preparationPermissionSchema, d as resolveGroupSplit, dn as sessionReviewResourceSchema, dr as preparationStateSchema, en as sortingApplySchema, et as inspectionInputs, fi as withReadingProgress, fn as sessionReviewStatusSchema, fr as preparationUpdateSchema, g as semanticGroupKey, gi as confirmedHideTerms, gn as reviewCandidateResourceSchema, gt as manualUploadSchema, h as hideScopeDigest, ii as hasCompleteWorkDescription, ir as workPrivacyDecisions, jn as validateScanExclusion, jt as journeyGuidance, kt as attemptBudgetCodePoints, l as chooseCheapPlacement, li as isSkippedWork, lr as preparationSettlementSchema, mi as confirmedHideKey, mn as sessionUsefulnessResourceSchema, ni as sendSessionUploadSchema, nn as reviewAttemptsQuerySchema, nr as retireWorkDescription, o as bRereadDigest, on as sessionReconciliationResourceSchema, pi as confirmedHideGroupIds, pn as sessionUsefulnessInputSchema, pr as validatePreparationFacts, pt as manualUploadBindingSchema, q as validateInspectionClaim, qn as confirmedHideDeltaSchema, qt as journeyPolicyRespondSchema, rn as reviewAttemptsResultSchema, rr as workDecisionDigest, s as reconcileBSession, si as isReadingComplete, sr as preparationBeginSchema, t as scanBatchContextDigest, tn as reviewAttemptResourceSchema, u as reviseGroupMembership, ui as selectedWorks, un as sessionReviewQuerySchema, ur as preparationStartSchema, v as projectJourneyInventory, vn as reviewRepairResourceSchema, vt as candidateSortAvailable, wn as scanCanonicalResourceSchema, x as bReviewScope, xn as mergeBRepair, y as preparationScope, yi as maskedHitsStale, zr as sendReachedPassport, zt as isolatedWorkId } from "./src-B3il9x5F.mjs";
4
4
  import { constants } from "node:fs";
5
5
  import { z } from "zod";
6
6
  import { copyFile, link, lstat, mkdir, mkdtemp, open, readFile, realpath, rm, unlink } from "node:fs/promises";
@@ -345,7 +345,7 @@ function readJourney(db, journeyId) {
345
345
  const text = row["state_json"];
346
346
  if (typeof text !== "string") throw new ApplicationError("CORRUPTED_STATE");
347
347
  const state = JSON.parse(text);
348
- if (typeof state === "object" && state !== null && "formatVersion" in state && state.formatVersion !== 10) throw new StoreError("OBSOLETE_SCHEMA", "Stored native Journey state uses an obsolete candidate format and has been preserved.");
348
+ if (typeof state === "object" && state !== null && "formatVersion" in state && state.formatVersion !== 10 && state.formatVersion !== 11) throw new StoreError("OBSOLETE_SCHEMA", "Stored native Journey state uses an obsolete candidate format and has been preserved.");
349
349
  let value = reconcileReaderKeeps(nativeJourneySchema.parse(state));
350
350
  if (value.outputVersion !== void 0 && value.outputVersion > 1) throw new StoreError("OBSOLETE_SCHEMA", "This journey requires a newer final writer.");
351
351
  if (value.outputVersion !== 1 && value.phase !== "completed" && !obsoleteJourney(value)) value = {
@@ -519,6 +519,7 @@ function commitJourney(db, input) {
519
519
  ...input,
520
520
  state: {
521
521
  ...stamped,
522
+ formatVersion: 11,
522
523
  ...hideRevision === void 0 ? {} : { confirmedHideRevision: hideRevision }
523
524
  }
524
525
  };
@@ -2666,6 +2667,10 @@ function finishTerms(db, packet) {
2666
2667
  count: term.count - previous
2667
2668
  })) added++;
2668
2669
  }
2670
+ for (const term of packet.located) if (upsertJourneyTerm(db, state.journeyId, {
2671
+ ...term,
2672
+ count: 0
2673
+ })) added++;
2669
2674
  const groups = syncTermGroups(state, readTermCounts(db, state.journeyId), (key) => findingPreference(db, key));
2670
2675
  const reference = {
2671
2676
  kind: "term-pack",
@@ -3805,7 +3810,7 @@ function projection(fields) {
3805
3810
  return (db, journeyId) => {
3806
3811
  const row = db.prepare(sql).get(journeyId);
3807
3812
  if (!row) return null;
3808
- if (row["format"] !== 10) throw new StoreError("OBSOLETE_SCHEMA", "Stored Journey preparation format is obsolete.");
3813
+ if (row["format"] !== 10 && row["format"] !== 11) throw new StoreError("OBSOLETE_SCHEMA", "Stored Journey preparation format is obsolete.");
3809
3814
  const result = {};
3810
3815
  for (const key of fields) {
3811
3816
  const value = row[key];
@@ -5086,7 +5091,7 @@ function checkpointJourneySendTransfer(db, input) {
5086
5091
  const revisionValue = row["revision"];
5087
5092
  if (typeof revisionValue !== "number" || !Number.isSafeInteger(revisionValue) || revisionValue < 0) throw new ApplicationError("CORRUPTED_STATE");
5088
5093
  if (revisionValue !== input.expectedJourneyRevision) return { status: "stale" };
5089
- if (row["formatVersion"] !== 10) throw new StoreError("OBSOLETE_SCHEMA", "Stored native Journey state uses an obsolete candidate format and has been preserved.");
5094
+ if (row["formatVersion"] !== 10 && row["formatVersion"] !== 11) throw new StoreError("OBSOLETE_SCHEMA", "Stored native Journey state uses an obsolete candidate format and has been preserved.");
5090
5095
  if (row["consentType"] !== "object") throw new ApplicationError("CONFIRMATION_REQUIRED");
5091
5096
  if (row["phase"] !== "sending") throw new ApplicationError(row["phase"] === "paused" ? "OPERATION_CANCELED" : "INVALID_TRANSITION");
5092
5097
  if (row["pendingHideId"] !== null && row["pendingHideId"] !== void 0) throw new ApplicationError("REVISION_CONFLICT");
@@ -5124,7 +5129,7 @@ function checkpointJourneySendTransfer(db, input) {
5124
5129
  const lastEvent = Number(inserted.lastInsertRowid);
5125
5130
  if (!Number.isSafeInteger(lastEvent) || lastEvent < 1) throw new ApplicationError("CORRUPTED_STATE");
5126
5131
  if (db.prepare(`UPDATE journey_runs SET revision=?,state_json=json_set(
5127
- state_json,'$.revision',?,'$.lastEvent',?) WHERE id=? AND revision=?`).run(revision, revision, lastEvent, input.journeyId, input.expectedJourneyRevision).changes !== 1) throw new ApplicationError("REVISION_CONFLICT");
5132
+ state_json,'$.formatVersion',11,'$.revision',?,'$.lastEvent',?) WHERE id=? AND revision=?`).run(revision, revision, lastEvent, input.journeyId, input.expectedJourneyRevision).changes !== 1) throw new ApplicationError("REVISION_CONFLICT");
5128
5133
  db.prepare("INSERT INTO journey_receipts VALUES(?,?,?,?)").run(input.requestKey, requestHash, input.journeyId, revision);
5129
5134
  return {
5130
5135
  status: "applied",
@@ -1,7 +1,7 @@
1
- import { Q as createInspectionProcessor } from "./src-DeNJ8vOD.mjs";
2
- import { Nn as createStaticProcessor } from "./locate-D-ZaHpI0.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CKQlTA2Z.mjs";
4
- import { G as validateInspectionRequest } from "./src-Do-qzuMn.mjs";
1
+ import { et as createInspectionProcessor } from "./src-CmvEJj46.mjs";
2
+ import { In as createStaticProcessor } from "./locate-CP2t26j2.mjs";
3
+ import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CWMrGXJK.mjs";
4
+ import { G as validateInspectionRequest } from "./src-B3il9x5F.mjs";
5
5
  import "./messages-D3m3bhva.mjs";
6
6
  import { z } from "zod";
7
7
  import { parentPort, workerData } from "node:worker_threads";
@@ -1,7 +1,7 @@
1
- import { E as readConfiguredSearchFields, F as parseCollectionWorkspaceSummary, K as readConfiguredOutputInfo, M as renderJobDigest, O as checkReusableBundle, P as readCollectionIndex, S as writeLogicalJourneyBase, U as writeLogicalJourneyOutput, V as gitSeedsProvider, at as makePrivateDirectory, ct as windowsOwnerOnly, k as prepareCollectionProduction, lt as isWindowsAclFailure, m as writeOutputShard, ot as openPrivateFile, p as verifyOutputShard, z as privateCollectionDirectory } from "./src-DeNJ8vOD.mjs";
2
- import { F as bUnitFragments, Gt as filterInventoryByPeriod, J as utf16Offset, Jt as journeyProfileAddressActionSchema, L as bClassificationKey, Lt as reviewTermsInputSchema, Qt as passportAddressSchema, S as validateBReview, U as bDigest, V as bAnchorKey, Vt as termTypeInfo, W as codePointLength, Yt as journeyProfileLinksActionSchema, _ as reviewFindingsDigest, a as reviewBatchChunks, an as safeField, cn as reviewFamilies, d as validateReview, i as compileBFindings, in as safeCode, l as reviewSubmitSchema, n as matchesReadReceipts, nn as ApplicationError, t as locateTerms, u as textDigest, yt as journeyDescribeSchema } from "./locate-D-ZaHpI0.mjs";
3
- import { $t as journeyPlaceSchema, Ai as stateSchema, Ar as journeyRenderInputSchema, Br as nativeRespondSchema, C as rebindReviewOverlay, Ct as sendActionSchema, D as staticallyHiddenFindings, Di as selectionSchema, Dr as journeyFindingImpactSchema, Dt as sendStartSchema, E as guardedFindingText, Ei as selectionBatchSchema, Er as journeyClassificationSessionsSchema, Et as sendRequestSchema, Fi as defaultScopedSettings, Gn as confirmedHideAdditions, H as inspectionStartSchema, Hr as retryReviewActionSchema, Ht as journeyContextQuerySchema, Ii as freezeConfiguration, Jn as renderedHideValue, K as inspectionQuerySchema, Li as selectFrozenConfiguration, Nt as journeyReviewStorageQuerySchema, Or as journeyFindingsSchema, Pn as journeyInventoryQuerySchema, Qn as hideKeyId, Rr as nativeEventsSchema, S as rebindReviewAlignment, Sn as planBRepair, St as replaceSensitiveTermsSchema, T as reviewBatchReuse, Ti as packageCommandSchema, Tt as sendPrepareSchema, V as inspectionCancelSchema, Vt as reviewCompileSchema, Xn as termHideAdditions, Xt as journeyResourceQuerySchema, Zn as addHideIndexTokens, _n as reviewRepairInputSchema, _t as manualUploadStartSchema, a as bCrossSegmentReviewSchema, b as isGenericPublicTerm, bn as bReviewDigest, bt as maximumTermsFileBytes, c as reconstructBFields, er as packHideIndex, f as selectedValueMembers, fr as maskedHitsStale, ft as manualUploadActionSchema, gn as reviewCandidateResourceSchema, hn as reviewCandidateInputSchema, ht as manualUploadPrepareSchema, i as validateBCrossSegmentReview, ii as staticSessionResourceSchema, in as sessionReconcileInputSchema, jr as journeyRenderSchema, ki as producerVersion, kr as journeyPreviewSchema, ln as sessionReviewInputSchema, mt as manualUploadChoiceSchema, n as scanBatchEquivalenceDigest, nt as settingsQuerySchema, o as bRereadDigest, or as confirmedHideGroupIds, p as splitSelectorValues, pn as sessionUsefulnessInputSchema, qn as readConfirmedHideChange, qt as journeyPolicyRespondSchema, r as locateTermEvidence, rt as readWorkspaceOutcomes, s as reconcileBSession, sn as sessionRereadInputSchema, t as scanBatchContextDigest, tn as reviewAttemptResourceSchema, tt as settingsBatchSchema, un as sessionReviewQuerySchema, ut as resolveFailureLocation, vn as reviewRepairResourceSchema, w as rebindReviewSubmit, wi as commandSchema, wt as sendChoiceSchema, x as bReviewScope, zr as nativeGetSchema } from "./src-Do-qzuMn.mjs";
4
- import { $ as validateState, A as resourceSelectionQuerySchema, B as termReuseQuerySchema, C as loadAcceptedReview, D as aggregateUsefulness, E as loadPrivateResource, F as validateUnitCandidate, G as validateBatchBody, H as privateReviewHash, I as reuseQuerySchema, J as ownership, K as requireActiveBatch, L as batchQuery, M as evaluateUnitEvidence, N as sameCandidateRequest, O as sessionUsefulnessRecommendation, P as validateCandidateAttempt, Q as readStoredState, R as isPrivateResourceKind, S as validateSessionBindings, T as loadBatch, U as batchHeader, V as scanAliasRequestKey, W as createJourneyPayloadFiles, X as withDatabase, Y as validateDatabase, Z as readBundleDirectory, _ as loadReconciliation, _t as errorCode, a as decodeError, at as finishReset, b as validatePreparationSelection, c as dropsAnchor, ct as present, d as parseDelivery, dt as recheckPrivatePath, et as checkVersion, f as validateCandidate, ft as stateDirectory, g as loadPreparedBodies, gt as StoreError, h as loadPreparation, ht as withFileCheckTimings, i as createExecutor, it as databaseName, j as inspectionQuerySchema$1, k as sessionQuery, l as replySchema, lt as privatePath, m as loadStatus, mt as withStateSnapshot, n as releaseInheritedHeapFlags, nt as beginReset, o as ProtocolError, ot as hasResetMarker, p as classificationJourneyCommit, pt as syncDirectory, q as initializeAndClaim, r as storeHeapLimits, rt as createDatabaseFile, s as allowedReplies, st as inspectStateFiles, tt as schemaVersion, u as operations, ut as readResetMarker, v as loadRereadBodies, vt as isCoordinationBusy, w as loadAuthenticatedReview, x as validateSessionReconciliation, y as loadSessionBodies, yt as isSqliteCorruption, z as privateResourceHeader } from "./heap-Blrat--4.mjs";
1
+ import { E as readConfiguredSearchFields, F as parseCollectionWorkspaceSummary, K as readConfiguredOutputInfo, M as renderJobDigest, O as checkReusableBundle, P as readCollectionIndex, S as writeLogicalJourneyBase, U as writeLogicalJourneyOutput, V as gitSeedsProvider, ct as openPrivateFile, dt as isWindowsAclFailure, k as prepareCollectionProduction, m as writeOutputShard, p as verifyOutputShard, st as makePrivateDirectory, ut as windowsOwnerOnly, z as privateCollectionDirectory } from "./src-CmvEJj46.mjs";
2
+ import { C as validateBReview, J as bAnchorKey, Ut as termTypeInfo, X as bDigest, Xt as journeyProfileAddressActionSchema, Z as codePointLength, Zt as journeyProfileLinksActionSchema, an as ApplicationError, cn as safeField, d as reviewSubmitSchema, dn as reviewFamilies, en as passportAddressSchema, f as textDigest, i as matchesReadReceipts, j as bUnitFragments, n as runOccurrences, o as compileBFindings, p as validateReview, qt as filterInventoryByPeriod, r as termSearchRuns, s as reviewBatchChunks, sn as safeCode, t as locateTerms, tt as utf16Offset, xt as journeyDescribeSchema, y as reviewFindingsDigest, z as bClassificationKey, zt as reviewTermsInputSchema } from "./locate-CP2t26j2.mjs";
3
+ import { $n as hideKeyId, $t as journeyPlaceSchema, Ai as selectionSchema, Bi as selectFrozenConfiguration, C as rebindReviewOverlay, Ct as sendActionSchema, D as staticallyHiddenFindings, Di as commandSchema, Dr as nativeEventsSchema, Dt as sendStartSchema, E as guardedFindingText, Et as sendRequestSchema, H as inspectionStartSchema, Ht as journeyContextQuerySchema, Jn as readConfirmedHideChange, K as inspectionQuerySchema, Kn as confirmedHideAdditions, Mi as producerVersion, Ni as stateSchema, Nt as journeyReviewStorageQuerySchema, Oi as packageCommandSchema, Or as nativeGetSchema, Pn as journeyInventoryQuerySchema, Qn as addHideIndexTokens, Ri as defaultScopedSettings, S as rebindReviewAlignment, Sn as planBRepair, St as replaceSensitiveTermsSchema, T as reviewBatchReuse, Tt as sendPrepareSchema, V as inspectionCancelSchema, Vt as reviewCompileSchema, Xt as journeyResourceQuerySchema, Yn as renderedHideValue, Zn as termHideAdditions, _n as reviewRepairInputSchema, _r as journeyPreviewSchema, _t as manualUploadStartSchema, a as bCrossSegmentReviewSchema, b as isGenericPublicTerm, bn as bReviewDigest, bt as maximumTermsFileBytes, c as reconstructBFields, ci as isSelectedWork, f as selectedValueMembers, fi as withReadingProgress, ft as manualUploadActionSchema, gn as reviewCandidateResourceSchema, gr as journeyFindingsSchema, hn as reviewCandidateInputSchema, hr as journeyFindingImpactSchema, ht as manualUploadPrepareSchema, i as validateBCrossSegmentReview, in as sessionReconcileInputSchema, jr as retryReviewActionSchema, ki as selectionBatchSchema, kr as nativeRespondSchema, ln as sessionReviewInputSchema, mr as journeyClassificationSessionsSchema, mt as manualUploadChoiceSchema, n as scanBatchEquivalenceDigest, nt as settingsQuerySchema, o as bRereadDigest, p as splitSelectorValues, pi as confirmedHideGroupIds, pn as sessionUsefulnessInputSchema, qr as staticSessionResourceSchema, qt as journeyPolicyRespondSchema, r as locateTermEvidence, rt as readWorkspaceOutcomes, s as reconcileBSession, sn as sessionRereadInputSchema, t as scanBatchContextDigest, tn as reviewAttemptResourceSchema, tr as packHideIndex, tt as settingsBatchSchema, un as sessionReviewQuerySchema, ut as resolveFailureLocation, vn as reviewRepairResourceSchema, vr as journeyRenderInputSchema, w as rebindReviewSubmit, wt as sendChoiceSchema, x as bReviewScope, yi as maskedHitsStale, yr as journeyRenderSchema, zi as freezeConfiguration } from "./src-B3il9x5F.mjs";
4
+ import { $ as validateState, A as resourceSelectionQuerySchema, B as termReuseQuerySchema, C as loadAcceptedReview, D as aggregateUsefulness, E as loadPrivateResource, F as validateUnitCandidate, G as validateBatchBody, H as privateReviewHash, I as reuseQuerySchema, J as ownership, K as requireActiveBatch, L as batchQuery, M as evaluateUnitEvidence, N as sameCandidateRequest, O as sessionUsefulnessRecommendation, P as validateCandidateAttempt, Q as readStoredState, R as isPrivateResourceKind, S as validateSessionBindings, T as loadBatch, U as batchHeader, V as scanAliasRequestKey, W as createJourneyPayloadFiles, X as withDatabase, Y as validateDatabase, Z as readBundleDirectory, _ as loadReconciliation, _t as errorCode, a as decodeError, at as finishReset, b as validatePreparationSelection, c as dropsAnchor, ct as present, d as parseDelivery, dt as recheckPrivatePath, et as checkVersion, f as validateCandidate, ft as stateDirectory, g as loadPreparedBodies, gt as StoreError, h as loadPreparation, ht as withFileCheckTimings, i as createExecutor, it as databaseName, j as inspectionQuerySchema$1, k as sessionQuery, l as replySchema, lt as privatePath, m as loadStatus, mt as withStateSnapshot, n as releaseInheritedHeapFlags, nt as beginReset, o as ProtocolError, ot as hasResetMarker, p as classificationJourneyCommit, pt as syncDirectory, q as initializeAndClaim, r as storeHeapLimits, rt as createDatabaseFile, s as allowedReplies, st as inspectStateFiles, tt as schemaVersion, u as operations, ut as readResetMarker, v as loadRereadBodies, vt as isCoordinationBusy, w as loadAuthenticatedReview, x as validateSessionReconciliation, y as loadSessionBodies, yt as isSqliteCorruption, z as privateResourceHeader } from "./heap-Bh9tySJp.mjs";
5
5
  import { constants, write } from "node:fs";
6
6
  import { z } from "zod";
7
7
  import { copyFile, link, lstat, mkdir, mkdtemp, open, opendir, readFile, readdir, realpath, rename, rm, unlink, writeFile } from "node:fs/promises";
@@ -4616,7 +4616,7 @@ function createStagedTerms(access, files) {
4616
4616
  return leg.run("journey.terms.finish", {
4617
4617
  before,
4618
4618
  located,
4619
- occurrences: batches.flatMap((batch) => locateTerms([batch], terms).located.map((term) => ({
4619
+ occurrences: batches.flatMap((batch) => locateTerms([batch], terms).located.filter((term) => term.count > 0).map((term) => ({
4620
4620
  ...term,
4621
4621
  batchId: batch.id
4622
4622
  }))),
@@ -4690,34 +4690,12 @@ function createStagedTerms(access, files) {
4690
4690
  }
4691
4691
  /** A UUID named by a digest, so a replayed carry-over reuses its request key. */
4692
4692
  const digestId = (digest) => `${digest.slice(0, 8)}-${digest.slice(8, 12)}-4${digest.slice(13, 16)}-8${digest.slice(17, 20)}-${digest.slice(20, 32)}`;
4693
- /** Locate provenance over the same contiguous core fields admitted by locateTerms. */
4693
+ /** Locate provenance over the same field runs and core-overlapping occurrence as locateTerms. */
4694
4694
  function findingSources(batches) {
4695
- const fields = [];
4696
- for (const batch of batches) {
4697
- const groups = Map.groupBy(batch.chunks.filter((chunk) => chunk.core), (chunk) => JSON.stringify([chunk.fieldId, chunk.fieldHash]));
4698
- for (const group of groups.values()) {
4699
- let chunks = [];
4700
- let end = -1;
4701
- const flush = () => {
4702
- if (chunks.length) fields.push({
4703
- batch,
4704
- chunks,
4705
- text: chunks.map((chunk) => chunk.text).join("").normalize("NFC")
4706
- });
4707
- };
4708
- for (const chunk of group.toSorted((a, b) => a.offset - b.offset)) {
4709
- if (chunk.offset !== end) {
4710
- flush();
4711
- chunks = [];
4712
- }
4713
- chunks.push(chunk);
4714
- end = chunk.offset + chunk.text.length;
4715
- }
4716
- flush();
4717
- }
4718
- }
4719
- return (value) => fields.flatMap(({ batch, chunks, text }) => {
4720
- const at = text.indexOf(value);
4695
+ const runs = [...termSearchRuns(batches)];
4696
+ return (value) => runs.flatMap((run) => {
4697
+ const { batch, chunks } = run;
4698
+ const at = runOccurrences(run, value).first;
4721
4699
  if (at < 0) return [];
4722
4700
  let offset = 0;
4723
4701
  return chunks.flatMap((chunk) => {
@@ -5558,7 +5536,17 @@ async function collectRemoteWorkers(dispatches, confirmations, home, transport =
5558
5536
  const copied = [];
5559
5537
  const failures = /* @__PURE__ */ new Set();
5560
5538
  const seen = /* @__PURE__ */ new Set();
5561
- for (const window of dispatches) {
5539
+ const resolved = dispatches.flatMap((window) => window.harness === "unknown" ? [{
5540
+ ...window,
5541
+ harness: "codex"
5542
+ }, {
5543
+ ...window,
5544
+ harness: "claude"
5545
+ }] : [{
5546
+ ...window,
5547
+ harness: window.harness
5548
+ }]);
5549
+ for (const window of resolved) {
5562
5550
  if (confirmations[window.host] !== true || failures.has(window.host)) continue;
5563
5551
  let temporary;
5564
5552
  try {
@@ -5661,7 +5649,11 @@ async function readRemoteState(stateDir, journeyId) {
5661
5649
  return z.object({
5662
5650
  windows: z.array(z.object({
5663
5651
  host: z.string(),
5664
- harness: z.enum(["codex", "claude"]),
5652
+ harness: z.enum([
5653
+ "codex",
5654
+ "claude",
5655
+ "unknown"
5656
+ ]),
5665
5657
  transport: z.enum(["ssh", "gcloud"]),
5666
5658
  args: z.array(z.string()),
5667
5659
  sourceSessionId: z.string(),
@@ -5823,6 +5815,92 @@ function workApproval(approval, rootIds) {
5823
5815
  };
5824
5816
  }
5825
5817
  //#endregion
5818
+ //#region apps/cli/src/journey/prepare/update.ts
5819
+ /** Preparation owns only the changed Work rows, progress and package invalidation. */
5820
+ async function changePreparation(storage, journeyId, kind, change, attempts = Number.POSITIVE_INFINITY, clearPackageApproval = false) {
5821
+ for (let attempt = 0; attempt < attempts; attempt++) {
5822
+ const before = await storage.preparationState(journeyId);
5823
+ if (!before?.consent) throw new ApplicationError("CONFIRMATION_REQUIRED");
5824
+ const after = change(before);
5825
+ if (after === before) return before;
5826
+ const previous = new Map(before.works.map((work) => [work.id, work]));
5827
+ const result = await storage.updatePreparation({
5828
+ journeyId,
5829
+ expectedRevision: before.revision,
5830
+ requestKey: randomUUID(),
5831
+ at: (/* @__PURE__ */ new Date()).toISOString(),
5832
+ kind,
5833
+ works: after.works.filter((work) => work !== previous.get(work.id)),
5834
+ phase: after.phase,
5835
+ readingComplete: after.readingComplete,
5836
+ readingStartedAt: after.readingStartedAt,
5837
+ clearPackageApproval: clearPackageApproval && before !== after
5838
+ });
5839
+ if (result.status !== "stale") return result.state;
5840
+ }
5841
+ throw new ApplicationError("REVISION_CONFLICT");
5842
+ }
5843
+ //#endregion
5844
+ //#region apps/cli/src/journey/prepare/isolation.ts
5845
+ /** A Work-level refusal caused by identified roots, each with its own public-safe code. */
5846
+ var RootPreparationFailure = class extends ApplicationError {
5847
+ roots;
5848
+ constructor(code, roots, options) {
5849
+ super(code, void 0, options);
5850
+ this.roots = roots;
5851
+ }
5852
+ };
5853
+ /** The distinct public-safe codes of the identified failing roots, else the Work-level code. */
5854
+ function blockedCodes(error, code) {
5855
+ return error instanceof RootPreparationFailure && error.roots.size ? [...new Set(error.roots.values())] : [code];
5856
+ }
5857
+ /**
5858
+ * ADR 0188 (restoring ADR 0059 D06): moves the failing roots of a multi-root Work into its
5859
+ * stable blocked "<title> – couldn't prepare" Work so the rest can be prepared again. False
5860
+ * when the failure names no root or every root, or the Work changed. Track B may
5861
+ * reopen its still-current reading/review generation before the pending-only store call.
5862
+ */
5863
+ async function isolateFailingRoots(storage, journeyId, work, error, afterRead = false) {
5864
+ if (!(error instanceof RootPreparationFailure)) return false;
5865
+ if ([
5866
+ error.code,
5867
+ ...error.roots.values(),
5868
+ ...work.blockedCodes
5869
+ ].includes("PRIVACY_CHANGE_PENDING")) return false;
5870
+ const roots = work.rootSessionIds.flatMap((sessionId) => {
5871
+ const code = error.roots.get(sessionId);
5872
+ return code ? [{
5873
+ sessionId,
5874
+ code
5875
+ }] : [];
5876
+ });
5877
+ if (roots.length === 0 || roots.length === work.rootSessionIds.length) return false;
5878
+ if (afterRead) await changePreparation(storage, journeyId, "snapshot", (state) => {
5879
+ const current = state.works.find((item) => item.id === work.id);
5880
+ if (state.phase === "paused" || state.phase === "sending" || state.phase === "completed" || state.scope.status !== "confirmed" || state.pendingHideId || current?.inputRevision !== work.inputRevision || !isSelectedWork(current) || current.blockedCodes.includes("PRIVACY_CHANGE_PENDING") || !["reading", "review"].includes(current.status)) return state;
5881
+ return withReadingProgress({
5882
+ ...state,
5883
+ works: state.works.map((item) => item.id === work.id ? {
5884
+ ...item,
5885
+ status: "pending"
5886
+ } : item)
5887
+ });
5888
+ }, 100, true);
5889
+ for (;;) {
5890
+ const state = await storage.preparationState(journeyId);
5891
+ const current = state?.works.find((item) => item.id === work.id);
5892
+ if (!state || state.phase === "paused" || state.phase === "sending" || state.phase === "completed" || state.scope.status !== "confirmed" || state.pendingHideId || current?.inputRevision !== work.inputRevision || current.blockedCodes.includes("PRIVACY_CHANGE_PENDING") || current.status !== "pending") return false;
5893
+ if ((await storage.isolateRoots({
5894
+ journeyId,
5895
+ workId: work.id,
5896
+ inputRevision: work.inputRevision,
5897
+ roots,
5898
+ expectedRevision: state.revision,
5899
+ idempotencyKey: randomUUID()
5900
+ })).status !== "stale") return true;
5901
+ }
5902
+ }
5903
+ //#endregion
5826
5904
  //#region apps/cli/src/journey/captures.ts
5827
5905
  /** Bound each store reply to selected source IDs, including for a large single Work. */
5828
5906
  async function readSelectedCaptures(storage, journeyId, partIds) {
@@ -5899,8 +5977,29 @@ async function staticBaseFromInputs(inputs, processing, hooks) {
5899
5977
  captures: inputs.captures,
5900
5978
  everyAdmissionRefusal: true
5901
5979
  }, hooks);
5902
- if (production.kind !== "configured" || production.workspaceFailures.length) throw new ApplicationError("SCOPE_NOT_READY");
5980
+ if (production.kind !== "configured") throw new ApplicationError("SCOPE_NOT_READY");
5903
5981
  const families = reviewFamilies(approval.inventory);
5982
+ if (production.workspaceFailures.length) {
5983
+ const failures = /* @__PURE__ */ new Map();
5984
+ let unattributed = false;
5985
+ for (const failure of production.workspaceFailures) {
5986
+ let attributed = false;
5987
+ for (const session of approval.inventory.sessions) {
5988
+ if (session.workspaceId !== failure.workspaceId) continue;
5989
+ if (failure.location.sessionId && session.id !== failure.location.sessionId) continue;
5990
+ const root = families.owners.get(session.id);
5991
+ if (!root || !roots.includes(root.id)) unattributed = true;
5992
+ else {
5993
+ failures.set(root.id, failure.code);
5994
+ attributed = true;
5995
+ }
5996
+ }
5997
+ if (!attributed) unattributed = true;
5998
+ }
5999
+ const cause = new AggregateError(production.workspaceFailures.map((failure) => failure.cause), "SCOPE_NOT_READY");
6000
+ if (unattributed) throw new ApplicationError("SCOPE_NOT_READY", void 0, { cause });
6001
+ throw new RootPreparationFailure("SCOPE_NOT_READY", failures, { cause });
6002
+ }
5904
6003
  const admitted = new Set(production.selection.sessions.map((item) => item.session.id));
5905
6004
  return {
5906
6005
  production,
@@ -6350,4 +6449,4 @@ async function runJourneyOutputJob(job, live, signal, onPath) {
6350
6449
  };
6351
6450
  }
6352
6451
  //#endregion
6353
- export { createExecutionPort as A, saveRemoteState as C, createPackagingProgressPort as D, exportDelivery as E, loadDeliveryResults as F, inBackgroundStatusPoll as I, inBackgroundStoreLane as L, withStateMutex as M, createDeliveryService as N, createStore as O, preflight as P, isBackgroundStatusPoll as R, readRemoteState as S, collectRemoteWorkers as T, staticBaseProduction as _, writeJourneyOutput as a, workApproval as b, mergeHideIndexTokens as c, runJourneyBaseJob as d, writeJourneyBase as f, staticBaseInputs as g, staticSessions as h, runJourneyOutputVerifyJob as i, startHost as j, readStateDump as k, packRenderHideIndex as l, saveStaticSession as m, runJourneyOutputJob as n, createHideIndexTokens as o, readStaticResult as p, runJourneyOutputShardJob as r, hideIndexTexts as s, journeyOutputJob as t, journeyBaseJob as u, readSelectedCaptures as v, journeyDirectory as w, isRemoteImport as x, prepareSourcePlan as y, retrySharingViolation as z };
6452
+ export { exportDelivery as A, inBackgroundStatusPoll as B, prepareSourcePlan as C, saveRemoteState as D, readRemoteState as E, startHost as F, isBackgroundStatusPoll as H, withStateMutex as I, createDeliveryService as L, createStore as M, readStateDump as N, journeyDirectory as O, createExecutionPort as P, preflight as R, changePreparation as S, isRemoteImport as T, retrySharingViolation as U, inBackgroundStoreLane as V, staticBaseProduction as _, writeJourneyOutput as a, blockedCodes as b, mergeHideIndexTokens as c, runJourneyBaseJob as d, writeJourneyBase as f, staticBaseInputs as g, staticSessions as h, runJourneyOutputVerifyJob as i, createPackagingProgressPort as j, collectRemoteWorkers as k, packRenderHideIndex as l, saveStaticSession as m, runJourneyOutputJob as n, createHideIndexTokens as o, readStaticResult as p, runJourneyOutputShardJob as r, hideIndexTexts as s, journeyOutputJob as t, journeyBaseJob as u, readSelectedCaptures as v, workApproval as w, isolateFailingRoots as x, RootPreparationFailure as y, loadDeliveryResults as z };