@gitroll/tacitt-cli 0.6.11 → 0.6.12

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 (53) hide show
  1. package/README.md +4 -0
  2. package/bin/INDEX.md +6 -4
  3. package/bin/tacitt.cjs +1 -0
  4. package/dist/{agent-setup-DdfF3zch.mjs → agent-setup-B12VbvN_.mjs} +2 -2
  5. package/dist/agent-setup-worker.mjs +5 -5
  6. package/dist/cli.mjs +28 -28
  7. package/dist/codex-title-worker.mjs +2 -2
  8. package/dist/configured-preview-worker.mjs +5 -5
  9. package/dist/configured-session-worker.mjs +23 -25
  10. package/dist/{frame-Bq2zRh-i.mjs → frame-B3He21G8.mjs} +1 -1
  11. package/dist/{heap-CV8Eca8V.mjs → heap-Blrat--4.mjs} +260 -23
  12. package/dist/inspection-worker.mjs +4 -4
  13. package/dist/{job-BKsifhyv.mjs → job-CBuIMTQ0.mjs} +24 -9
  14. package/dist/{locate-Cx52Zqxv.mjs → locate-D-ZaHpI0.mjs} +5 -0
  15. package/dist/{model-C1UXkHh9.mjs → model-DR9odhWP.mjs} +1 -1
  16. package/dist/operation-executor.mjs +3 -3
  17. package/dist/preview-worker.mjs +1 -1
  18. package/dist/privacy-validator.mjs +28 -8
  19. package/dist/{query-AMZerUh8.mjs → query-BYDcNKy2.mjs} +1614 -679
  20. package/dist/{run-CaPktPhH.mjs → run-DQ9xyKSt.mjs} +4 -4
  21. package/dist/session-process.mjs +20 -0
  22. package/dist/{src-wZx_v0Ih.mjs → src-CKQlTA2Z.mjs} +4 -4
  23. package/dist/{src-DlVbGB32.mjs → src-DeNJ8vOD.mjs} +465 -107
  24. package/dist/{src-D1iONla3.mjs → src-Do-qzuMn.mjs} +377 -130
  25. package/dist/store-database-worker.mjs +1 -1
  26. package/dist/web/assets/index-BgDdPL1c.js +172 -0
  27. package/dist/web/index.html +2 -1
  28. package/package.json +2 -1
  29. package/skills/INDEX.md +6 -4
  30. package/skills/tacitt/INDEX.md +7 -6
  31. package/skills/tacitt/SKILL.md +5 -5
  32. package/skills/tacitt/references/INDEX.md +14 -11
  33. package/skills/tacitt/references/b-method.md +4 -4
  34. package/skills/tacitt/references/bootstrap.md +17 -3
  35. package/skills/tacitt/references/classification.md +1 -1
  36. package/skills/tacitt/references/commands.md +24 -6
  37. package/skills/tacitt/references/journey.md +4 -4
  38. package/skills/tacitt/references/parallel-review.md +13 -7
  39. package/skills/tacitt/references/send.md +7 -3
  40. package/skills/tacitt/scripts/INDEX.md +40 -37
  41. package/skills/tacitt/scripts/answer.mjs +19 -1
  42. package/skills/tacitt/scripts/journey-card-consolidation.mjs +1 -1
  43. package/skills/tacitt/scripts/journey-classification-tasks.mjs +28 -8
  44. package/skills/tacitt/scripts/journey-panel-host.d.mts +2 -0
  45. package/skills/tacitt/scripts/journey-panel-host.mjs +25 -2
  46. package/skills/tacitt/scripts/journey-scan-timing.d.mts +4 -0
  47. package/skills/tacitt/scripts/journey-scan-timing.mjs +12 -0
  48. package/skills/tacitt/scripts/journey-state.mjs +11 -0
  49. package/skills/tacitt/scripts/journey-tasks.mjs +12 -5
  50. package/skills/tacitt/scripts/journey.mjs +10 -2
  51. package/skills/tacitt/scripts/privacy-validator.mjs +28 -7
  52. package/skills/tacitt/scripts/review.mjs +399 -99
  53. package/dist/web/assets/index-CYl7eDUu.js +0 -172
@@ -1,6 +1,6 @@
1
- import { S as readPrivateReviewPayload, at as restrictToOwner, it as openPrivateFile, nt as exclusiveLock, ot as windowsOwnerOnly, x as writePrivateReviewPayload } from "./src-DlVbGB32.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-Cx52Zqxv.mjs";
3
- import { $ as validateDetectionSummary, $t as journeyResourceSchema, At as obsoleteJourney, Bn as journeySearchResultSchema, Cn as mergeBRepair, Cr as preparationStartSchema, En as scanCanonicalResourceSchema, Er as validatePreparationFacts, Fr as applyCardAnswers, Ft as journeyGuidance, Gn as journeyEventSchema, Gr as staticSessionId, Gt as journeyContextQuerySchema, Hn as searchScopeDigest, Hr as mergePrivacyTerms, In as journeyInventoryReadSchema, It as journeyBatchReadSchema, J as validateInspectionFence, Jt as hideFinishSchema, Kt as journeyContextSchema, Ln as journeyInventorySchema, Lt as journeyReviewStorageQuerySchema, Nn as validateScanExclusion, Nt as attemptBudgetCodePoints, On as scanSessionResourceSchema, Ot as settleCorrections, Pt as validateAttemptAppend, Q as validateInspectionContribution, Qt as journeyResourceQuerySchema, Rn as journeyPreparationProgressSchema, Rt as applyClassificationProposal, Sn as bReviewDigest, Sr as preparationSettlementSchema, Tn as scanAliasResourceSchema, Tr as preparationUpdateSchema, U as validateInspectionBatch, Un as journeyCommitResultSchema, Ut as newJourneyWork, Vn as journeySearchSaveSchema, W as validateInspectionBatches, Wn as journeyCommitSchema, X as validateInspectionInputs, Xn as settleConfirmedHides, Xr as journeySendSchema, Xt as journeyPolicyRespondSchema, Y as validateInspectionHead, Yt as hidePublishSchema, Z as validateInspectionQuery, Zt as projectPreparationProgress, _r as workPrivacyDecisions, ai as isReadingComplete, an as reviewAttemptsResultSchema, bn as reviewRepairResourceSchema, br as preparationBeginSchema, c as reconstructBFields, ci as selectedWorks, cn as sessionReconciliationResourceSchema, cr as confirmedHideKey, d as resolveGroupSplit, dr as dictionaryHides, en as journeyIsolateSchema, et as inspectionInputs, fn as sessionReviewQuerySchema, g as semanticGroupKey, gi as stateSchema, gn as sessionUsefulnessResourceSchema, gr as workDecisionDigest, gt as manualUploadSchema, h as hideScopeDigest, hn as sessionUsefulnessInputSchema, hr as retireWorkDescription, in as reviewAttemptsQuerySchema, ir as bMaskedHits, kn as scanGitSeedsId, l as chooseCheapPlacement, li as withReadingProgress, mn as sessionReviewStatusSchema, mr as syncTermGroups, nn as sortingApplySchema, o as bRereadDigest, oi as isSelectedWork, pn as sessionReviewResourceSchema, pr as maskedHitsStale, pt as manualUploadBindingSchema, q as validateInspectionClaim, qn as confirmedHideDeltaSchema, qt as hideBeginSchema, rn as reviewAttemptResourceSchema, s as reconcileBSession, si as isSkippedWork, sn as sessionReconcileResultSchema, sr as confirmedHideGroupIds, t as scanBatchContextDigest, tn as journeyPlaceSchema, u as reviseGroupMembership, un as sessionRereadResourceSchema, ur as confirmedHideTerms, v as projectJourneyInventory, vn as reviewCandidateResourceSchema, vt as candidateSortAvailable, wr as preparationStateSchema, x as bReviewScope, xr as preparationPermissionSchema, y as preparationScope, zt as classificationCommitSchema } from "./src-D1iONla3.mjs";
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";
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";
@@ -346,9 +346,26 @@ function readJourney(db, journeyId) {
346
346
  if (typeof text !== "string") throw new ApplicationError("CORRUPTED_STATE");
347
347
  const state = JSON.parse(text);
348
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.");
349
+ let value = reconcileReaderKeeps(nativeJourneySchema.parse(state));
350
+ if (value.outputVersion !== void 0 && value.outputVersion > 1) throw new StoreError("OBSOLETE_SCHEMA", "This journey requires a newer final writer.");
351
+ if (value.outputVersion !== 1 && value.phase !== "completed" && !obsoleteJourney(value)) value = {
352
+ ...value,
353
+ outputVersion: 1,
354
+ phase: value.phase === "ready" ? "review" : value.phase,
355
+ privacy: {
356
+ ...value.privacy,
357
+ packageApproval: null
358
+ },
359
+ works: value.works.map((work) => ({
360
+ ...work,
361
+ revision: work.revision + 1,
362
+ status: work.status === "ready" ? "review" : work.status,
363
+ artifact: null
364
+ }))
365
+ };
349
366
  return {
350
367
  text,
351
- value: nativeJourneySchema.parse(state)
368
+ value
352
369
  };
353
370
  });
354
371
  }
@@ -362,23 +379,29 @@ function insertCorrectionReport(db, resource) {
362
379
  }
363
380
  db.prepare("INSERT INTO journey_resources VALUES(?,?,?,?)").run(resource.journeyId, resource.kind, resource.id, json);
364
381
  }
365
- /**
366
- * A snapshot of an earlier release cannot render, so a new Journey may replace it, but never
367
- * one with a Send record or a sent Work: that Send stays for the person to finish.
368
- */
369
- /** A receipt or persisted session mutation intent means a Send may have reached Passport. */
382
+ /** Whether any Send of this Journey may have reached Passport (`sendReachedPassport`). */
370
383
  function reachedPassport(db, journeyId) {
371
384
  return db.prepare("SELECT json FROM journey_sends WHERE journey_id=?").all(journeyId).some((row) => {
372
385
  if (typeof row["json"] !== "string") throw new ApplicationError("CORRUPTED_STATE");
373
- return journeySendSchema.parse(JSON.parse(row["json"])).items.some((item) => item.receipt || item.previousReceipts.length || item.sessionUpload !== void 0 || item.sessionMembership || item.sessionAssembly);
386
+ return sendReachedPassport(journeySendSchema.parse(JSON.parse(row["json"])));
374
387
  });
375
388
  }
376
389
  /** An abandoned Journey gives way to a new one unless one of its Sends reached Passport. */
377
390
  function abandoned(db, current) {
378
391
  return current.abandonedAt !== void 0 && !reachedPassport(db, current.journeyId);
379
392
  }
393
+ /**
394
+ * A snapshot of an earlier release cannot render, so a new Journey replaces it unless its current
395
+ * Send still owes Passport something its next advance sends without the person
396
+ * (`sendOwesPassport`, ADR 0284, owner answer A): sent Works stay on Passport, and the new Journey
397
+ * reads every Work again. Replacement cancels its unfinished Sends.
398
+ */
380
399
  function replaceable(db, current) {
381
- return obsoleteJourney(current) && !current.works.some((work) => work.binding) && !db.prepare("SELECT 1 FROM journey_sends WHERE journey_id=? LIMIT 1").get(current.journeyId);
400
+ if (!obsoleteJourney(current)) return false;
401
+ const row = db.prepare("SELECT json FROM journey_sends JOIN journey_current_send ON journey_sends.id=journey_current_send.send_id WHERE journey_current_send.journey_id=?").get(current.journeyId);
402
+ if (!row) return true;
403
+ if (typeof row["json"] !== "string") throw new ApplicationError("CORRUPTED_STATE");
404
+ return !sendOwesPassport(current, journeySendSchema.parse(JSON.parse(row["json"])));
382
405
  }
383
406
  /** An addition counts only when one of its findings was assigned to a confirmed Hide category. */
384
407
  function joinedHideValues(db, state, delta) {
@@ -439,6 +462,7 @@ function commitJourney(db, input) {
439
462
  ...input,
440
463
  state: {
441
464
  ...input.state,
465
+ outputVersion: 1,
442
466
  privacy: {
443
467
  ...input.state.privacy,
444
468
  rememberedRules
@@ -453,6 +477,7 @@ function commitJourney(db, input) {
453
477
  state: current
454
478
  };
455
479
  }
480
+ if (input.expectedRevision === null && current && replaceable(db, current)) db.prepare("DELETE FROM journey_current_send WHERE journey_id=?").run(current.journeyId);
456
481
  if (input.state.journeyId !== input.event.journeyId) throw new ApplicationError("INVALID_ARGUMENTS");
457
482
  if (input.closedReader) {
458
483
  const hold = input.closedReader;
@@ -2578,6 +2603,7 @@ function selectTerms(db, query) {
2578
2603
  if (!source || source["review_ref_json"] === null) throw new ApplicationError("SCOPE_NOT_READY");
2579
2604
  }
2580
2605
  const work = requireActiveBatch(state, batch.header);
2606
+ if (work.access === "drop") throw new ApplicationError("REVISION_CONFLICT");
2581
2607
  if (work.reviewInterruptions?.some((hold) => hold.inputRevision === work.inputRevision && hold.batchIds.includes(unit.batchId)) || db.prepare("SELECT 1 FROM journey_resources WHERE journey_id=? AND kind='closed-reader' AND id=?").get(state.journeyId, unit.batchId + ":" + input.packId)) throw new ApplicationError("REVISION_CONFLICT");
2582
2608
  if (batch.header.digest !== unit.batchDigest) throw new ApplicationError("REVISION_CONFLICT");
2583
2609
  return batch;
@@ -3853,9 +3879,9 @@ function activeScope(db, input, starting) {
3853
3879
  if (state.pendingHideId) throw new ApplicationError("SCOPE_NOT_READY");
3854
3880
  const work = state.works.find((item) => item.id === input.workId);
3855
3881
  if (!work || input.inputRevision !== work.inputRevision || input.snapshotId !== state.snapshotId) throw new ApplicationError("REVISION_CONFLICT");
3856
- const plan = readInventoryPlan(db, state);
3882
+ const { plan, families } = readInventoryFamilies(db, state);
3857
3883
  if (!plan.approval.inventory.complete) throw new ApplicationError("CORRUPTED_STATE");
3858
- return preparationScope(plan.approval.inventory, work);
3884
+ return preparationScope(plan.approval.inventory, work, families);
3859
3885
  }
3860
3886
  function insert(db, record) {
3861
3887
  db.prepare("INSERT INTO journey_resources VALUES(?,?,?,?)").run(record.journeyId, record.kind, record.id, JSON.stringify(record));
@@ -3926,7 +3952,16 @@ function readJourneyPreparationProgress(db, input) {
3926
3952
  const state = readFencedJourney(db, input);
3927
3953
  if (!state.consent || !state.snapshotId) return null;
3928
3954
  const { starts, settlements } = readPreparationReceipts(db, state.journeyId);
3929
- return projectPreparationProgress(state, readInventoryPlan(db, state), readCaptures(db, state.journeyId), starts, settlements);
3955
+ const captures = db.prepare(`SELECT id, json_extract(json,'$.capture.partId') AS partId,
3956
+ json_extract(json,'$.capture.facts.byteLength') AS bytes FROM journey_resources
3957
+ WHERE journey_id=? AND kind='capture'`).all(state.journeyId).map(({ id, partId, bytes }) => {
3958
+ if (id !== partId || typeof partId !== "string" || typeof bytes !== "number" || !Number.isSafeInteger(bytes) || bytes < 0) throw new ApplicationError("CORRUPTED_STATE");
3959
+ return {
3960
+ partId,
3961
+ bytes
3962
+ };
3963
+ });
3964
+ return projectPreparationProgress(state, readInventoryFamilies(db, state).families, captures, starts, settlements);
3930
3965
  }
3931
3966
  //#endregion
3932
3967
  //#region packages/local-host/src/store/journey/hide.ts
@@ -4732,14 +4767,6 @@ function finishJourneyPlacement(db, packet) {
4732
4767
  //#endregion
4733
4768
  //#region packages/local-host/src/store/journey/isolation.ts
4734
4769
  const reason = " – couldn't prepare";
4735
- /** Stable blocked Work IDs per parent, so later failing roots join one instead of multiplying. */
4736
- function isolatedWorkId(parentId, ordinal) {
4737
- const bytes = createHash("sha256").update(`isolated-roots:${parentId}:${ordinal}`).digest().subarray(0, 16);
4738
- bytes[6] = (bytes[6] ?? 0) & 15 | 64;
4739
- bytes[8] = (bytes[8] ?? 0) & 63 | 128;
4740
- const hex = bytes.toString("hex");
4741
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
4742
- }
4743
4770
  /**
4744
4771
  * Moves identified failing roots out of a pending multi-root Work into its visible blocked
4745
4772
  * Work, carrying their public-safe codes; the parent returns to pending for the rest.
@@ -4783,8 +4810,15 @@ function isolateJourneyRoots(db, input) {
4783
4810
  })),
4784
4811
  blocks: /* @__PURE__ */ new Map([[targetId, [...codes]]])
4785
4812
  });
4813
+ const classified = !existing && parent.classificationRecommendation && hasCompleteWorkDescription(parent) && !parent.suggestion ? {
4814
+ description: parent.description,
4815
+ classificationRecommendation: parent.classificationRecommendation,
4816
+ reason: parent.classificationRecommendation.reason,
4817
+ projectType: parent.projectType?.origin === "model" ? parent.projectType : null
4818
+ } : {};
4786
4819
  const works = next.works.map((work) => work.id === targetId ? {
4787
4820
  ...work,
4821
+ ...classified,
4788
4822
  ...access
4789
4823
  } : work);
4790
4824
  return commitJourney(db, commit(input, {
@@ -4912,9 +4946,197 @@ function finishJourneyDescription(db, packet) {
4912
4946
  }
4913
4947
  //#endregion
4914
4948
  //#region packages/local-host/src/store/journey/send.ts
4949
+ /** Run the privacy fence against the store's current immutable row on every request.
4950
+ * Only the approved output and this Work's frozen upload identities cross the worker boundary. */
4951
+ function readSendOutput(db, input) {
4952
+ const { journeyId, workId, revision } = input;
4953
+ const state = readJourney(db, journeyId);
4954
+ if (!state?.consent) throw new ApplicationError("CONFIRMATION_REQUIRED");
4955
+ if (state.phase === "completed" && state.outputVersion !== 1) throw new ApplicationError("SCOPE_NOT_READY");
4956
+ assertJourneyPrivacyReady(state, true);
4957
+ if (state.phase === "paused") throw new ApplicationError("OPERATION_CANCELED");
4958
+ const work = state.works.find((item) => item.id === workId);
4959
+ if (!work?.artifact || work.revision !== revision || work.artifact.revision !== revision) throw new ApplicationError("REVISION_CONFLICT");
4960
+ const [output] = readJourneyResources(db, {
4961
+ journeyId,
4962
+ kind: "output",
4963
+ id: `${workId}:${revision}`
4964
+ });
4965
+ if (output?.kind !== "output" || output.workId !== workId || output.revision !== revision || output.primary.sha256 !== work.artifact.sha256) throw new ApplicationError("ARTIFACT_IDENTITY_MISMATCH");
4966
+ if (!input.sessions) return {
4967
+ output,
4968
+ identities: []
4969
+ };
4970
+ const [base] = readJourneyResources(db, {
4971
+ journeyId,
4972
+ kind: "base",
4973
+ id: `${workId}:${output.finalMaskLedger.inputRevision}`
4974
+ });
4975
+ if (base?.kind !== "base" || base.workId !== workId || base.inputRevision !== output.finalMaskLedger.inputRevision || base.primary.sha256 !== output.finalMaskLedger.basePrimarySha256) throw new ApplicationError("ARTIFACT_IDENTITY_MISMATCH");
4976
+ const plan = readInventoryPlan(db, state);
4977
+ const sessions = new Map(plan.approval.inventory.sessions.map((session) => [session.id, session]));
4978
+ const groups = /* @__PURE__ */ new Map();
4979
+ const identities = base.sessions.map((binding) => {
4980
+ const session = sessions.get(binding.applicationSessionId);
4981
+ const part = session?.parts[0];
4982
+ const lastAt = session?.lastInteractionAt ?? session?.createdAt;
4983
+ if (!session || !part || !lastAt || !Number.isFinite(Date.parse(lastAt))) throw new ApplicationError("ARTIFACT_IDENTITY_MISMATCH");
4984
+ const native = part.nativeEvidence?.identity;
4985
+ if (native?.sessionId?.trim() && native.role !== "unknown" && (native.role !== "worker" || native.agentId?.trim() && session.harness === "claude")) {
4986
+ const key = JSON.stringify([
4987
+ session.harness,
4988
+ native.sessionId,
4989
+ native.role === "worker" ? native.agentId : null
4990
+ ]);
4991
+ const group = groups.get(key) ?? [];
4992
+ group.push(binding.archiveSessionId);
4993
+ groups.set(key, group);
4994
+ }
4995
+ const nativeId = part.nativeEvidence?.identity?.sessionId ?? session.sourceSessionId;
4996
+ const path = part.harnessRelativePath ?? "";
4997
+ if (!path && !nativeId?.trim() || isAbsolute(path) || path.includes("\\") || path.split("/").some((segment) => segment === ".." || segment === ".")) throw new ApplicationError("ARTIFACT_IDENTITY_MISMATCH");
4998
+ return {
4999
+ archiveSessionId: binding.archiveSessionId,
5000
+ relativePath: path,
5001
+ lastAt: new Date(lastAt).toISOString()
5002
+ };
5003
+ });
5004
+ const duplicates = [...groups.values()].filter((group) => group.length > 1);
5005
+ if (!duplicates.length) return {
5006
+ output,
5007
+ identities
5008
+ };
5009
+ const duplicateIds = new Set(duplicates.flat());
5010
+ const owners = new Map(base.sessions.map((s) => [s.archiveSessionId, s.applicationSessionId]));
5011
+ const sources = base.sourceBindings.flatMap((binding) => {
5012
+ if (!duplicateIds.has(binding.sessionId) || binding.bundleId !== base.bundleId || owners.get(binding.sessionId) !== binding.applicationSessionId) return [];
5013
+ const part = sessions.get(binding.applicationSessionId)?.parts.find((p) => p.id === binding.sourcePartId);
5014
+ return part ? [{
5015
+ session: binding.sessionId,
5016
+ source: binding.bundleSourceId,
5017
+ part
5018
+ }] : [];
5019
+ });
5020
+ const outputs = state.works.filter(isSelectedWork).flatMap((w) => w.artifact ? [{
5021
+ workId: w.id,
5022
+ revision: w.revision,
5023
+ sha256: w.artifact.sha256,
5024
+ bundleId: w.artifact.bundleId
5025
+ }] : []);
5026
+ const approval = state.privacy.packageApproval;
5027
+ if (!approval) throw new ApplicationError("CONFIRMATION_REQUIRED");
5028
+ return {
5029
+ output,
5030
+ identities,
5031
+ extension: {
5032
+ groups: duplicates,
5033
+ sources,
5034
+ outputs,
5035
+ approval
5036
+ }
5037
+ };
5038
+ }
5039
+ const sendCurrentSchema = z.object({
5040
+ journeyId: journeyIdSchema,
5041
+ sendId: journeyIdSchema,
5042
+ revision: z.number().int().nonnegative()
5043
+ }).strict();
5044
+ function isCurrentSend(db, input) {
5045
+ return !!db.prepare(`SELECT 1 FROM journey_runs r JOIN journey_current_send s ON s.journey_id=r.id
5046
+ JOIN journey_current c ON c.journey_id=r.id AND c.singleton=1
5047
+ WHERE r.id=? AND r.revision=? AND s.send_id=?`).get(input.journeyId, input.revision, input.sendId);
5048
+ }
5049
+ const transferCountSchema = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
5050
+ const sendTransferSchema = z.object({
5051
+ journeyId: journeyIdSchema,
5052
+ sendId: journeyIdSchema,
5053
+ workId: journeyIdSchema,
5054
+ expectedJourneyRevision: transferCountSchema,
5055
+ expectedSendRevision: transferCountSchema,
5056
+ storedSessions: transferCountSchema.optional(),
5057
+ sessionUpload: sendSessionUploadSchema,
5058
+ requestKey: journeyIdSchema,
5059
+ at: z.iso.datetime()
5060
+ }).strict();
5061
+ const sendTransferResultSchema = z.discriminatedUnion("status", [z.object({
5062
+ status: z.literal("applied"),
5063
+ revision: transferCountSchema,
5064
+ lastEvent: transferCountSchema,
5065
+ sendRevision: transferCountSchema
5066
+ }).strict(), z.object({ status: z.enum(["stale", "replayed"]) }).strict()]);
5067
+ /** Update only transfer fields in the Send document and stamp its Journey revision/event. */
5068
+ function checkpointJourneySendTransfer(db, input) {
5069
+ const requestHash = createHash("sha256").update(JSON.stringify(input)).digest("hex");
5070
+ const receipt = db.prepare("SELECT request_hash,journey_id FROM journey_receipts WHERE request_key=?").get(input.requestKey);
5071
+ if (receipt) {
5072
+ if (receipt["request_hash"] !== requestHash || receipt["journey_id"] !== input.journeyId) throw new ApplicationError("OPERATION_CONFLICT");
5073
+ return { status: "replayed" };
5074
+ }
5075
+ const row = db.prepare(`SELECT r.revision,r.state_json ->> '$.formatVersion' AS formatVersion,
5076
+ r.state_json ->> '$.phase' AS phase,
5077
+ json_type(r.state_json,'$.consent') AS consentType,
5078
+ r.state_json ->> '$.pendingHideId' AS pendingHideId,
5079
+ json_type(r.state_json,'$.abandonedAt') AS abandonedType,s.json
5080
+ FROM journey_runs r
5081
+ JOIN journey_current c ON c.singleton=1 AND c.journey_id=r.id
5082
+ JOIN journey_current_send cs ON cs.journey_id=r.id AND cs.send_id=?
5083
+ JOIN journey_sends s ON s.journey_id=r.id AND s.id=cs.send_id
5084
+ WHERE r.id=?`).get(input.sendId, input.journeyId);
5085
+ if (!row) return { status: "stale" };
5086
+ const revisionValue = row["revision"];
5087
+ if (typeof revisionValue !== "number" || !Number.isSafeInteger(revisionValue) || revisionValue < 0) throw new ApplicationError("CORRUPTED_STATE");
5088
+ 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.");
5090
+ if (row["consentType"] !== "object") throw new ApplicationError("CONFIRMATION_REQUIRED");
5091
+ if (row["phase"] !== "sending") throw new ApplicationError(row["phase"] === "paused" ? "OPERATION_CANCELED" : "INVALID_TRANSITION");
5092
+ if (row["pendingHideId"] !== null && row["pendingHideId"] !== void 0) throw new ApplicationError("REVISION_CONFLICT");
5093
+ if (row["abandonedType"] !== null && row["abandonedType"] !== void 0) throw new ApplicationError("INVALID_TRANSITION");
5094
+ if (typeof row["json"] !== "string") throw new ApplicationError("CORRUPTED_STATE");
5095
+ const send = journeySendSchema.parse(JSON.parse(row["json"]));
5096
+ if (send.revision !== input.expectedSendRevision) return { status: "stale" };
5097
+ if (!send.subject || !send.confirmedAt) throw new ApplicationError("CONFIRMATION_REQUIRED");
5098
+ if (send.status === "paused") throw new ApplicationError("OPERATION_CANCELED");
5099
+ if (!["sending", "waiting"].includes(send.status)) throw new ApplicationError("INVALID_TRANSITION");
5100
+ const index = send.items.findIndex((item) => item.workId === input.workId);
5101
+ if (index < 0) throw new ApplicationError("INVALID_SELECTION");
5102
+ const item = send.items[index];
5103
+ if (!item) throw new ApplicationError("CORRUPTED_STATE");
5104
+ if (item.status !== "uploading") throw new ApplicationError("INVALID_TRANSITION");
5105
+ const revision = revisionValue + 1;
5106
+ const sendRevision = send.revision + 1;
5107
+ const next = journeySendSchema.parse({
5108
+ ...send,
5109
+ revision: sendRevision,
5110
+ items: send.items.map((candidate, candidateIndex) => candidateIndex === index ? {
5111
+ ...candidate,
5112
+ sessionUpload: input.sessionUpload,
5113
+ ...input.storedSessions === void 0 ? {} : { storedSessions: input.storedSessions }
5114
+ } : candidate)
5115
+ });
5116
+ if (db.prepare("UPDATE journey_sends SET json=? WHERE journey_id=? AND id=?").run(JSON.stringify(next), input.journeyId, input.sendId).changes !== 1) throw new ApplicationError("REVISION_CONFLICT");
5117
+ const inserted = db.prepare("INSERT INTO journey_events(journey_id,event_json) VALUES(?,?)").run(input.journeyId, JSON.stringify({
5118
+ journeyId: input.journeyId,
5119
+ revision,
5120
+ kind: "send",
5121
+ source: "system",
5122
+ at: input.at
5123
+ }));
5124
+ const lastEvent = Number(inserted.lastInsertRowid);
5125
+ if (!Number.isSafeInteger(lastEvent) || lastEvent < 1) throw new ApplicationError("CORRUPTED_STATE");
5126
+ 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");
5128
+ db.prepare("INSERT INTO journey_receipts VALUES(?,?,?,?)").run(input.requestKey, requestHash, input.journeyId, revision);
5129
+ return {
5130
+ status: "applied",
5131
+ revision,
5132
+ lastEvent,
5133
+ sendRevision
5134
+ };
5135
+ }
4915
5136
  const sendLoadSchema = z.object({
4916
5137
  journeyId: journeyIdSchema,
4917
- sendId: journeyIdSchema.optional()
5138
+ sendId: journeyIdSchema.optional(),
5139
+ observedRevision: z.number().int().nonnegative().optional()
4918
5140
  }).strict();
4919
5141
  const sendSnapshotSchema = z.object({
4920
5142
  journey: nativeJourneySchema,
@@ -4935,6 +5157,7 @@ const sendCommitResultSchema = sendSnapshotSchema.extend({ status: z.enum([
4935
5157
  "stale"
4936
5158
  ]) });
4937
5159
  function loadJourneySend(db, input) {
5160
+ if (input.observedRevision !== void 0 && !input.sendId && db.prepare("SELECT 1 AS same FROM journey_runs WHERE id=? AND revision=?").get(input.journeyId, input.observedRevision)) return null;
4938
5161
  const journey = readJourney(db, input.journeyId);
4939
5162
  if (!journey) return null;
4940
5163
  const row = input.sendId ? db.prepare("SELECT json FROM journey_sends WHERE journey_id=? AND id=?").get(input.journeyId, input.sendId) : db.prepare("SELECT json FROM journey_sends JOIN journey_current_send ON journey_sends.id=journey_current_send.send_id WHERE journey_current_send.journey_id=?").get(input.journeyId);
@@ -4972,6 +5195,7 @@ function commitJourneySend(db, input) {
4972
5195
  ...input.state,
4973
5196
  revision
4974
5197
  });
5198
+ if (!prior && obsoleteJourney(current.journey)) throw new ApplicationError("JOURNEY_OBSOLETE");
4975
5199
  const skipped = (workId) => current.journey.works.some((work) => work.id === workId && isSkippedWork(work));
4976
5200
  const finished = send.status === "completed" && send.omitted.every((work) => [
4977
5201
  "drop",
@@ -7058,6 +7282,9 @@ const operations = {
7058
7282
  "journey.policy.respond": define(true, policyRespondSchema, respondJourneyPolicy, (value) => journeyCommitResultSchema.parse(value)),
7059
7283
  "journey.policy.batches": define(false, policyBatchesSchema, selectPolicyBatches, (value) => z.array(z.uuid()).parse(value)),
7060
7284
  "journey.send.load": define(false, sendLoadSchema, loadJourneySend, (value) => sendSnapshotSchema.nullable().parse(value)),
7285
+ "journey.send.current": define(false, sendCurrentSchema, isCurrentSend, (value) => z.boolean().parse(value)),
7286
+ "journey.send.transfer": define(true, sendTransferSchema, checkpointJourneySendTransfer, (value) => sendTransferResultSchema.parse(value)),
7287
+ "journey.send.output": define(false, sendOutputQuerySchema, readSendOutput, (value) => sendOutputSchema.parse(value)),
7061
7288
  "journey.send.commit": define(true, sendCommitSchema, commitJourneySend, (value) => sendCommitResultSchema.parse(value)),
7062
7289
  "manual.upload.load": define(false, manualUploadLoadSchema, loadManualUpload, (value) => manualUploadSchema.nullable().parse(value)),
7063
7290
  "manual.upload.commit": define(true, manualUploadCommitSchema, commitManualUpload, (value) => manualUploadResultSchema.parse(value)),
@@ -7091,6 +7318,16 @@ const operations = {
7091
7318
  ]),
7092
7319
  state: preparationStateSchema
7093
7320
  }).strict().parse(value)),
7321
+ "journey.receipt.revision": define(false, z.object({
7322
+ journeyId: z.uuid(),
7323
+ key: z.uuid(),
7324
+ hash: z.string().regex(/^[0-9a-f]{64}$/u)
7325
+ }).strict(), (db, { journeyId, key, hash }) => {
7326
+ const row = db.prepare("SELECT journey_id,request_hash,revision FROM journey_receipts WHERE request_key=?").get(key);
7327
+ if (!row) return null;
7328
+ if (row["journey_id"] !== journeyId || row["request_hash"] !== hash) throw new ApplicationError("OPERATION_CONFLICT");
7329
+ return z.number().int().nonnegative().parse(row["revision"]);
7330
+ }, (value) => z.number().int().nonnegative().nullable().parse(value)),
7094
7331
  "journey.current": define(false, z.object({ journeyId: z.uuid().optional() }), (db, input) => readJourney(db, input.journeyId), (value) => nativeJourneySchema.nullable().parse(value)),
7095
7332
  "journey.terms.reopen-empty": define(true, emptyReviewCorrectionSchema, reopenEmptyReview, (value) => emptyReviewCorrectionResultSchema.parse(value)),
7096
7333
  "journey.terms.select": define(false, termsQuerySchema, selectTerms, (value) => termsSelectionSchema.parse(value)),
@@ -1,7 +1,7 @@
1
- import { X as createInspectionProcessor } from "./src-DlVbGB32.mjs";
2
- import { Nn as createStaticProcessor } from "./locate-Cx52Zqxv.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-wZx_v0Ih.mjs";
4
- import { G as validateInspectionRequest } from "./src-D1iONla3.mjs";
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";
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 { A as renderJobDigest, D as prepareCollectionProduction, E as checkReusableBundle, L as privateCollectionDirectory, M as readCollectionIndex, N as parseCollectionWorkspaceSummary, V as writeLogicalJourneyOutput, W as readConfiguredOutputInfo, b as writeLogicalJourneyBase, d as verifyOutputShard, f as writeOutputShard, it as openPrivateFile, ot as windowsOwnerOnly, rt as makePrivateDirectory, st as isWindowsAclFailure, w as readConfiguredSearchFields, z as gitSeedsProvider } from "./src-DlVbGB32.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-Cx52Zqxv.mjs";
3
- import { $n as hideKeyId, Ar as journeyPreviewSchema, Br as nativeRespondSchema, C as rebindReviewOverlay, Ci as selectFrozenConfiguration, Ct as sendActionSchema, D as staticallyHiddenFindings, Dr as journeyClassificationSessionsSchema, Dt as sendStartSchema, E as guardedFindingText, Et as sendRequestSchema, Fn as journeyInventoryQuerySchema, Gt as journeyContextQuerySchema, H as inspectionStartSchema, Jn as readConfirmedHideChange, K as inspectionQuerySchema, Kn as confirmedHideAdditions, Kr as staticSessionResourceSchema, Lt as journeyReviewStorageQuerySchema, Mr as journeyRenderSchema, Or as journeyFindingImpactSchema, Qn as addHideIndexTokens, Qt as journeyResourceQuerySchema, Rr as nativeEventsSchema, S as rebindReviewAlignment, Si as freezeConfiguration, Sn as bReviewDigest, St as replaceSensitiveTermsSchema, T as reviewBatchReuse, Tt as sendPrepareSchema, V as inspectionCancelSchema, Vr as retryReviewActionSchema, Wt as reviewCompileSchema, Xt as journeyPolicyRespondSchema, Yn as renderedHideValue, Zn as termHideAdditions, _n as reviewCandidateInputSchema, _t as manualUploadStartSchema, a as bCrossSegmentReviewSchema, b as isGenericPublicTerm, bn as reviewRepairResourceSchema, bt as maximumTermsFileBytes, c as reconstructBFields, di as packageCommandSchema, dn as sessionReviewInputSchema, f as selectedValueMembers, fi as selectionBatchSchema, fn as sessionReviewQuerySchema, ft as manualUploadActionSchema, gi as stateSchema, hi as producerVersion, hn as sessionUsefulnessInputSchema, ht as manualUploadPrepareSchema, i as validateBCrossSegmentReview, jr as journeyRenderInputSchema, kr as journeyFindingsSchema, ln as sessionRereadInputSchema, mt as manualUploadChoiceSchema, n as scanBatchEquivalenceDigest, nt as settingsQuerySchema, o as bRereadDigest, on as sessionReconcileInputSchema, p as splitSelectorValues, pi as selectionSchema, pr as maskedHitsStale, r as locateTermEvidence, rn as reviewAttemptResourceSchema, rt as readWorkspaceOutcomes, s as reconcileBSession, sr as confirmedHideGroupIds, t as scanBatchContextDigest, tn as journeyPlaceSchema, tr as packHideIndex, tt as settingsBatchSchema, ui as commandSchema, ut as resolveFailureLocation, vn as reviewCandidateResourceSchema, w as rebindReviewSubmit, wn as planBRepair, wt as sendChoiceSchema, x as bReviewScope, xi as defaultScopedSettings, yn as reviewRepairInputSchema, zr as nativeGetSchema } from "./src-D1iONla3.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-CV8Eca8V.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, 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";
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";
@@ -20,8 +20,8 @@ import { AsyncLocalStorage } from "node:async_hooks";
20
20
  import { ZipWriter } from "@zip.js/zip.js/index-native.js";
21
21
  import { tmpdir } from "node:os";
22
22
  import { pipeline } from "node:stream/promises";
23
- import { DatabaseSync } from "node:sqlite";
24
23
  import { Worker } from "node:worker_threads";
24
+ import { DatabaseSync } from "node:sqlite";
25
25
  import { quote } from "shell-quote";
26
26
  //#region packages/file-privacy/src/sharing.ts
27
27
  const sharingCodes = /* @__PURE__ */ new Set([
@@ -595,6 +595,9 @@ const operation = z.enum([
595
595
  "journey.current",
596
596
  "journey.resources",
597
597
  "journey.send.load",
598
+ "journey.send.current",
599
+ "journey.send.transfer",
600
+ "journey.send.output",
598
601
  "journey.send.commit",
599
602
  "manual.upload.load",
600
603
  "manual.upload.commit",
@@ -650,6 +653,7 @@ const operation = z.enum([
650
653
  "journey.commit",
651
654
  "journey.commit.checked",
652
655
  "journey.classification.commit",
656
+ "journey.receipt.revision",
653
657
  "journey.events",
654
658
  "journey.inventory",
655
659
  "journey.preparation.progress",
@@ -932,7 +936,7 @@ function createRouter(application, account, stopping, delivery, nativeInspection
932
936
  }),
933
937
  send: t.router({
934
938
  request: t.procedure.input(sendRequestSchema).mutation(({ input }) => sending().request(input, "panel")),
935
- get: t.procedure.input(sendAddress.partial({ sendId: true })).query(({ input, signal }) => readThroughContention(() => sending().get(input), signal)),
939
+ get: t.procedure.input(sendAddress.partial({ sendId: true }).extend({ observedRevision: z.number().int().nonnegative().optional() })).query(({ input, signal }) => readThroughContention(() => sending().get(input), signal)),
936
940
  prepare: t.procedure.input(sendPrepareSchema).mutation(({ input, signal }) => sending().prepare(input, signal)),
937
941
  start: t.procedure.input(sendStartSchema).mutation(({ input, signal }) => sending().start(input, signal)),
938
942
  respond: t.procedure.input(sendChoiceSchema).mutation(({ input }) => sending().respond(input)),
@@ -940,6 +944,8 @@ function createRouter(application, account, stopping, delivery, nativeInspection
940
944
  resume: t.procedure.input(sendActionSchema).mutation(({ input }) => sending().resume(input)),
941
945
  withdraw: t.procedure.input(sendActionSchema).mutation(({ input }) => sending().withdraw(input)),
942
946
  advance: t.procedure.input(sendAddress).mutation(({ input }) => sending().advance(input, stopping)),
947
+ uploadAssessments: t.procedure.input(sendAddress).query(({ input }) => sending().uploadAssessments(input)),
948
+ ownedPassport: t.procedure.input(sendAddress).query(({ input, signal }) => sending().ownedPassport(input, signal ?? stopping)),
943
949
  ownerProfile: t.procedure.query(({ signal }) => sending().ownerProfile(signal ?? stopping)),
944
950
  addressTaken: t.procedure.input(z.object({ address: passportAddressSchema }).strict()).query(({ input, signal }) => sending().addressTaken(input, signal ?? stopping)),
945
951
  saveSentProfile: t.procedure.input(z.object({ journeyId: z.uuid() }).strict()).mutation(({ input }) => sending().saveSentProfile(input, stopping))
@@ -5064,11 +5070,13 @@ async function openStore(options, backupObsolete) {
5064
5070
  sessionReviewStatus: (input) => stagedJourney.sessionReviewStatus(input),
5065
5071
  reviewAttempts: (input) => access.run("journey.review.attempts", input),
5066
5072
  acknowledgeSessionUsefulness: (input) => stagedJourney.acknowledgeSessionUsefulness(input),
5073
+ readSendOutput: (input) => access.run("journey.send.output", input),
5067
5074
  preparationState: (journeyId) => access.run("journey.preparation.state", { journeyId }),
5068
5075
  preparationPermission: (journeyId) => access.run("journey.preparation.permission", { journeyId }),
5069
5076
  updatePreparation: (input) => access.run("journey.preparation.update", input),
5070
5077
  current: (journeyId) => access.run("journey.current", journeyId ? { journeyId } : {}),
5071
5078
  commit: (input) => stagedJourney.commit(input),
5079
+ receiptRevision: (input) => access.run("journey.receipt.revision", input),
5072
5080
  commitClassification: (input) => stagedJourney.commitClassification(input),
5073
5081
  hideIndexKey: (journeyId) => stagedJourney.hideIndexKey(journeyId),
5074
5082
  reopenEmpty: (input) => access.run("journey.terms.reopen-empty", input),
@@ -5081,11 +5089,18 @@ async function openStore(options, backupObsolete) {
5081
5089
  })
5082
5090
  },
5083
5091
  journeySend: {
5084
- loadSend: (journeyId, sendId) => access.run("journey.send.load", {
5092
+ isCurrentSend: (journeyId, sendId, revision) => access.run("journey.send.current", {
5093
+ journeyId,
5094
+ sendId,
5095
+ revision
5096
+ }),
5097
+ loadSend: (journeyId, sendId, observedRevision) => access.run("journey.send.load", {
5085
5098
  journeyId,
5086
- ...sendId ? { sendId } : {}
5099
+ ...sendId ? { sendId } : {},
5100
+ ...observedRevision !== void 0 ? { observedRevision } : {}
5087
5101
  }),
5088
- commitSend: (input) => access.run("journey.send.commit", input)
5102
+ commitSend: (input) => access.run("journey.send.commit", input),
5103
+ checkpointTransfer: (input) => access.run("journey.send.transfer", input)
5089
5104
  },
5090
5105
  manualUpload: {
5091
5106
  load: (uploadId) => access.run("manual.upload.load", uploadId ? { uploadId } : {}),
@@ -8538,8 +8538,10 @@ const safeCodes = /* @__PURE__ */ new Set([
8538
8538
  "SESSION_UPLOAD_EXHAUSTED",
8539
8539
  "SESSION_TRANSPORT_UNAVAILABLE",
8540
8540
  "SEND_SCOPE_BUSY",
8541
+ "HOST_REPLACEMENT_PENDING",
8541
8542
  "SEND_REPLACE_REFUSED",
8542
8543
  "SESSION_CONTENT_CONFLICT",
8544
+ "WORK_SESSION_CAPACITY_EXCEEDED",
8543
8545
  "SESSION_MOVE_ACCESS_REQUIRED",
8544
8546
  "SESSION_MOVE_ACCESS_HELD",
8545
8547
  "SEND_SCOPE_INVALIDATED",
@@ -8622,6 +8624,8 @@ const safeCodes = /* @__PURE__ */ new Set([
8622
8624
  "OPERATION_BUSY",
8623
8625
  "OPERATION_CONFLICT",
8624
8626
  "OPERATION_FAILED",
8627
+ "WORK_METADATA_INCOMPLETE",
8628
+ "PACKAGING_FAILED",
8625
8629
  "PACKAGING_BUSY",
8626
8630
  "PROCESSING_PLAN_UNAVAILABLE",
8627
8631
  "PROCESSING_PLAN_MISMATCH",
@@ -9644,6 +9648,7 @@ const journeyExceptionSchema = z.object({
9644
9648
  }).strict();
9645
9649
  const nativeJourneySchema = z.object({
9646
9650
  formatVersion: z.literal(10),
9651
+ outputVersion: z.number().int().positive().optional(),
9647
9652
  classificationRevision: count$1.nullable(),
9648
9653
  privacy: journeyPrivacySchema,
9649
9654
  delegation: journeyDelegationSchema.nullable(),
@@ -1,4 +1,4 @@
1
- import "./src-D1iONla3.mjs";
1
+ import "./src-Do-qzuMn.mjs";
2
2
  //#region packages/harnesses/src/discovery/model.ts
3
3
  const discoveryBounds = {
4
4
  entries: 1e5,
@@ -1,6 +1,6 @@
1
- import { _ as longCommands, c as executorRequestSchema, h as parseOptions, i as invoke, n as readOperation, o as createRuntime, r as waitOperation, y as startupFailure } from "./query-AMZerUh8.mjs";
2
- import { an as safeField, in as safeCode, nn as ApplicationError } from "./locate-Cx52Zqxv.mjs";
3
- import "./src-D1iONla3.mjs";
1
+ import { c as executorRequestSchema, g as longCommands, i as invoke, m as parseOptions, n as readOperation, o as createRuntime, r as waitOperation, v as startupFailure } from "./query-BYDcNKy2.mjs";
2
+ import { an as safeField, in as safeCode, nn as ApplicationError } from "./locate-D-ZaHpI0.mjs";
3
+ import "./src-Do-qzuMn.mjs";
4
4
  import { z } from "zod";
5
5
  import { setTimeout } from "node:timers/promises";
6
6
  //#region apps/cli/src/operation/executor.ts
@@ -1,4 +1,4 @@
1
- import { n as assertPreviewHeap, o as previewInputSchema, t as runPreview } from "./run-CaPktPhH.mjs";
1
+ import { n as assertPreviewHeap, o as previewInputSchema, t as runPreview } from "./run-DQ9xyKSt.mjs";
2
2
  import { parentPort, workerData } from "node:worker_threads";
3
3
  //#region packages/harnesses/src/preview/worker/index.ts
4
4
  function notify(message) {