@gitroll/tacitt-cli 0.6.9 → 0.6.11

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 (57) hide show
  1. package/README.md +43 -4
  2. package/dist/{agent-setup-CODlN6zl.mjs → agent-setup-DdfF3zch.mjs} +2 -2
  3. package/dist/agent-setup-worker.mjs +5 -5
  4. package/dist/cli.mjs +35 -12
  5. package/dist/codex-title-worker.mjs +1 -1
  6. package/dist/configured-preview-worker.mjs +5 -5
  7. package/dist/configured-session-worker.mjs +9 -7
  8. package/dist/{frame-Dj5Zs6UW.mjs → frame-Bq2zRh-i.mjs} +1 -1
  9. package/dist/{heap-Dt3-d27v.mjs → heap-CV8Eca8V.mjs} +217 -13
  10. package/dist/inspection-worker.mjs +4 -4
  11. package/dist/{job-BQXssW46.mjs → job-BKsifhyv.mjs} +38 -18
  12. package/dist/{locate-BWkblijS.mjs → locate-Cx52Zqxv.mjs} +204 -20
  13. package/dist/{model-CSx2dP_P.mjs → model-C1UXkHh9.mjs} +1 -1
  14. package/dist/operation-executor.mjs +3 -3
  15. package/dist/preview-worker.mjs +1 -1
  16. package/dist/privacy-validator.mjs +29 -2
  17. package/dist/{query-CfhcS4gd.mjs → query-AMZerUh8.mjs} +712 -215
  18. package/dist/{run-xlOaKCk8.mjs → run-CaPktPhH.mjs} +4 -4
  19. package/dist/{src-DzKuzGVH.mjs → src-D1iONla3.mjs} +2215 -1613
  20. package/dist/{src-V9GHLZQs.mjs → src-DlVbGB32.mjs} +74 -37
  21. package/dist/{src-BgsEnMsy.mjs → src-wZx_v0Ih.mjs} +297 -207
  22. package/dist/store-database-worker.mjs +1 -1
  23. package/dist/web/assets/index-CYl7eDUu.js +172 -0
  24. package/dist/web/assets/index-DzOozqms.css +1 -0
  25. package/dist/web/index.html +2 -2
  26. package/package.json +1 -1
  27. package/skills/tacitt/INDEX.md +6 -6
  28. package/skills/tacitt/SKILL.md +11 -11
  29. package/skills/tacitt/references/INDEX.md +3 -3
  30. package/skills/tacitt/references/b-method.md +2 -2
  31. package/skills/tacitt/references/bootstrap.md +2 -2
  32. package/skills/tacitt/references/classification.md +15 -5
  33. package/skills/tacitt/references/commands.md +37 -30
  34. package/skills/tacitt/references/journey.md +14 -6
  35. package/skills/tacitt/references/parallel-review.md +27 -33
  36. package/skills/tacitt/references/send.md +35 -9
  37. package/skills/tacitt/scripts/INDEX.md +37 -37
  38. package/skills/tacitt/scripts/answer.mjs +73 -15
  39. package/skills/tacitt/scripts/journey-classification-metadata.mjs +75 -26
  40. package/skills/tacitt/scripts/journey-classification-progress.mjs +1 -2
  41. package/skills/tacitt/scripts/journey-classification-validation.d.mts +13 -0
  42. package/skills/tacitt/scripts/journey-classification-validation.mjs +38 -0
  43. package/skills/tacitt/scripts/journey-classification.mjs +6 -1
  44. package/skills/tacitt/scripts/journey-consolidation.mjs +1 -0
  45. package/skills/tacitt/scripts/journey-scan-timing.d.mts +1 -0
  46. package/skills/tacitt/scripts/journey-scan-timing.mjs +19 -4
  47. package/skills/tacitt/scripts/journey-state.d.mts +15 -1
  48. package/skills/tacitt/scripts/journey-state.mjs +104 -5
  49. package/skills/tacitt/scripts/journey-tasks.d.mts +1 -0
  50. package/skills/tacitt/scripts/journey-tasks.mjs +13 -5
  51. package/skills/tacitt/scripts/journey.d.mts +46 -28
  52. package/skills/tacitt/scripts/journey.mjs +57 -8
  53. package/skills/tacitt/scripts/privacy-validator.mjs +178 -12
  54. package/skills/tacitt/scripts/review.d.mts +7 -6
  55. package/skills/tacitt/scripts/review.mjs +576 -147
  56. package/dist/web/assets/index-9UfCT_2C.js +0 -174
  57. package/dist/web/assets/index-CYJBq1px.css +0 -1
@@ -1,7 +1,7 @@
1
- import { X as createInspectionProcessor } from "./src-V9GHLZQs.mjs";
2
- import { Dn as createStaticProcessor } from "./locate-BWkblijS.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-BgsEnMsy.mjs";
4
- import { U as validateInspectionRequest } from "./src-DzKuzGVH.mjs";
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";
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, at as windowsOwnerOnly, b as writeLogicalJourneyBase, d as verifyOutputShard, f as writeOutputShard, nt as makePrivateDirectory, ot as isWindowsAclFailure, rt as openPrivateFile, w as readConfiguredSearchFields, z as gitSeedsProvider } from "./src-V9GHLZQs.mjs";
2
- import { $t as safeField, F as bClassificationKey, Ft as termTypeInfo, H as codePointLength, Ht as journeyProfileAddressActionSchema, K as utf16Offset, Kt as passportAddressSchema, N as bUnitFragments, Qt as safeCode, Ut as journeyProfileLinksActionSchema, V as bDigest, Xt as ApplicationError, b as validateBReview, c as textDigest, h as reviewFindingsDigest, ht as journeyDescribeSchema, jt as reviewTermsInputSchema, l as validateReview, n as compileBFindings, nn as reviewFamilies, r as reviewBatchChunks, s as reviewSubmitSchema, t as locateTerms, z as bAnchorKey, zt as filterInventoryByPeriod } from "./locate-BWkblijS.mjs";
3
- import { $ as settingsBatchSchema, B as inspectionStartSchema, Br as staticSessionResourceSchema, C as rebindReviewOverlay, Cr as journeyFindingImpactSchema, Ct as sendPrepareSchema, D as staticallyHiddenFindings, Dn as termHideAdditions, Dr as journeyRenderSchema, E as guardedFindingText, Er as journeyRenderInputSchema, Fr as nativeRespondSchema, It as journeyReviewStorageQuerySchema, Ln as confirmedHideGroupIds, Nr as nativeEventsSchema, On as addHideIndexTokens, Pr as nativeGetSchema, Qn as reviewRepairResourceSchema, Qt as journeyPolicyRespondSchema, S as rebindReviewAlignment, Sn as confirmedHideAdditions, Sr as journeyClassificationSessionsSchema, St as sendChoiceSchema, T as reviewBatchReuse, Tn as renderedHideValue, Tr as journeyPreviewSchema, Tt as sendStartSchema, Un as maskedHitsStale, Ut as reviewCompileSchema, W as inspectionQuerySchema, Wt as journeyContextQuerySchema, Xn as reviewCandidateResourceSchema, Yn as reviewCandidateInputSchema, Zn as reviewRepairInputSchema, _i as selectFrozenConfiguration, _n as sessionUsefulnessInputSchema, a as bCrossSegmentReviewSchema, ai as packageCommandSchema, an as reviewAttemptResourceSchema, b as isGenericPublicTerm, bt as replaceSensitiveTermsSchema, c as reconstructBFields, cn as sessionReconcileInputSchema, ct as resolveFailureLocation, dn as sessionRereadInputSchema, en as journeyResourceQuerySchema, er as bReviewDigest, et as settingsQuerySchema, f as selectedValueMembers, ft as manualUploadChoiceSchema, gi as freezeConfiguration, hi as defaultScopedSettings, ht as manualUploadStartSchema, i as validateBCrossSegmentReview, ii as commandSchema, jn as packHideIndex, kn as hideKeyId, li as producerVersion, mn as sessionReviewQuerySchema, n as scanBatchEquivalenceDigest, nr as planBRepair, o as bRereadDigest, oi as selectionBatchSchema, p as splitSelectorValues, pn as sessionReviewInputSchema, pr as journeyInventoryQuerySchema, pt as manualUploadPrepareSchema, r as locateTermEvidence, rn as journeyPlaceSchema, s as reconcileBSession, si as selectionSchema, t as scanBatchContextDigest, tt as readWorkspaceOutcomes, ui as stateSchema, ut as manualUploadActionSchema, vt as maximumTermsFileBytes, w as rebindReviewSubmit, wn as readConfirmedHideChange, wr as journeyFindingsSchema, wt as sendRequestSchema, x as bReviewScope, xt as sendActionSchema, z as inspectionCancelSchema } from "./src-DzKuzGVH.mjs";
4
- import { $ as checkVersion, A as resourceSelectionQuerySchema, B as termReuseQuerySchema, C as loadAcceptedReview, D as aggregateUsefulness, E as loadPrivateResource, F as validateUnitCandidate, G as requireActiveBatch, H as batchHeader, I as reuseQuerySchema, J as validateDatabase, K as initializeAndClaim, L as batchQuery, M as evaluateUnitEvidence, N as sameCandidateRequest, O as sessionUsefulnessRecommendation, P as validateCandidateAttempt, Q as validateState, R as isPrivateResourceKind, S as validateSessionBindings, T as loadBatch, U as createJourneyPayloadFiles, V as privateReviewHash, W as validateBatchBody, X as readBundleDirectory, Y as withDatabase, Z as readStoredState, _ as loadReconciliation, _t as isCoordinationBusy, a as decodeError, at as hasResetMarker, b as validatePreparationSelection, c as dropsAnchor, ct as privatePath, d as parseDelivery, dt as stateDirectory, et as schemaVersion, f as validateCandidate, ft as syncDirectory, g as loadPreparedBodies, gt as errorCode, h as loadPreparation, ht as StoreError, i as createExecutor, it as finishReset, j as inspectionQuerySchema$1, k as sessionQuery, l as replySchema, lt as readResetMarker, m as loadStatus, mt as withFileCheckTimings, n as releaseInheritedHeapFlags, nt as createDatabaseFile, o as ProtocolError, ot as inspectStateFiles, p as classificationJourneyCommit, pt as withStateSnapshot, q as ownership, r as storeHeapLimits, rt as databaseName, s as allowedReplies, st as present, tt as beginReset, u as operations, ut as recheckPrivatePath, v as loadRereadBodies, vt as isSqliteCorruption, w as loadAuthenticatedReview, x as validateSessionReconciliation, y as loadSessionBodies, z as privateResourceHeader } from "./heap-Dt3-d27v.mjs";
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";
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";
@@ -640,6 +640,7 @@ const operation = z.enum([
640
640
  "journey.terms.contexts",
641
641
  "journey.terms.propose.select",
642
642
  "journey.terms.propose.finish",
643
+ "journey.terms.reopen-empty",
643
644
  "journey.terms.select",
644
645
  "journey.terms.finish",
645
646
  "journey.terms.read",
@@ -652,6 +653,9 @@ const operation = z.enum([
652
653
  "journey.events",
653
654
  "journey.inventory",
654
655
  "journey.preparation.progress",
656
+ "journey.preparation.state",
657
+ "journey.preparation.permission",
658
+ "journey.preparation.update",
655
659
  "journey.unsorted.reviewed",
656
660
  "journey.unsorted.categories",
657
661
  "journey.work.candidates",
@@ -857,8 +861,10 @@ const nativePanelRespondSchema = z.object({
857
861
  kind: z.literal("retry-work"),
858
862
  workId: z.uuid()
859
863
  }).strict(),
864
+ retryReviewActionSchema,
860
865
  journeyProfileAddressActionSchema,
861
- journeyProfileLinksActionSchema
866
+ journeyProfileLinksActionSchema,
867
+ z.object({ kind: z.literal("account-read") }).strict()
862
868
  ])
863
869
  }).strict();
864
870
  function createRouter(application, account, stopping, delivery, nativeInspection, agentPresence) {
@@ -954,7 +960,7 @@ function createRouter(application, account, stopping, delivery, nativeInspection
954
960
  files: t.procedure.input(journeyRenderSchema).query(({ input, signal }) => native().files(input, signal)),
955
961
  searchResult: t.procedure.input(nativeGetSchema.required()).query(({ input }) => native().searchResult(input)),
956
962
  prepare: t.procedure.input(nativeGetSchema.required()).mutation(({ input }) => native().prepare(input, stopping)),
957
- render: t.procedure.input(journeyRenderInputSchema).mutation(({ input, signal }) => native().render(input, signal)),
963
+ render: t.procedure.input(journeyRenderInputSchema).mutation(({ input }) => native().render(input, stopping)),
958
964
  findings: t.procedure.input(journeyFindingsSchema).query(({ input, signal }) => native().findings(input, signal)),
959
965
  findingImpact: t.procedure.input(journeyFindingImpactSchema).query(({ input, signal }) => native().findingImpact(input, signal)),
960
966
  preview: t.procedure.input(journeyPreviewSchema).query(({ input, signal }) => native().preview(input, signal)),
@@ -4496,13 +4502,13 @@ function aliasTerms(canonical, target, terms) {
4496
4502
  locateTermEvidence([target], result, locateTerms([target], result).located);
4497
4503
  return result;
4498
4504
  }
4499
- const digestId$1 = (digest) => `${digest.slice(0, 8)}-${digest.slice(8, 12)}-4${digest.slice(13, 16)}-8${digest.slice(17, 20)}-${digest.slice(20, 32)}`;
4500
4505
  /** Partial judgments remain durable; only the final accepted pack completes the alias. */
4501
4506
  function createScanAliasResolver(access, files, record) {
4502
4507
  return async (input) => {
4503
4508
  const requests = await access.staged(async (leg, signal) => {
4504
4509
  const selected = await leg.run("journey.terms.select-aliases", input);
4505
- const state = await leg.run("journey.current", input);
4510
+ if (selected.length === 0) return [];
4511
+ const state = await leg.run("journey.preparation.state", input);
4506
4512
  if (!state) throw new ApplicationError("UNKNOWN_ITEM");
4507
4513
  const requests = [];
4508
4514
  for (const item of selected) {
@@ -4515,11 +4521,7 @@ function createScanAliasResolver(access, files, record) {
4515
4521
  const body = termPackBodySchema.parse(await files.read(input.journeyId, "term-pack", reference.idempotencyKey, reference.payload, signal));
4516
4522
  const unit = body.units.find((unit) => unit.batchId === canonical.id);
4517
4523
  if (!unit || unit.batchDigest !== canonical.digest || unit.workId !== canonical.workId || body.journeyId !== input.journeyId || body.packId !== reference.packId || body.idempotencyKey !== reference.idempotencyKey || body.requestHash !== reference.requestHash || receiptHash !== reference.requestHash) throw new ApplicationError("CORRUPTED_STATE");
4518
- const key = digestId$1(textDigest(JSON.stringify([
4519
- "scan-alias-v1",
4520
- alias,
4521
- reference.idempotencyKey
4522
- ])));
4524
+ const key = scanAliasRequestKey(alias, reference.idempotencyKey);
4523
4525
  requests.push({
4524
4526
  journeyId: input.journeyId,
4525
4527
  idempotencyKey: key,
@@ -4547,7 +4549,7 @@ function createScanAliasResolver(access, files, record) {
4547
4549
  * private payload is written, then one transaction records the pack.
4548
4550
  */
4549
4551
  function createStagedTerms(access, files) {
4550
- const recordTerms = (raw) => access.staged(async (leg, signal) => {
4552
+ const recordTerms = (raw, trustedReuse = false) => access.staged(async (leg, signal) => {
4551
4553
  const input = reviewTermsInputSchema.parse(raw);
4552
4554
  const requestHash = textDigest(JSON.stringify(input));
4553
4555
  const before = await leg.run("journey.terms.select", {
@@ -4557,6 +4559,10 @@ function createStagedTerms(access, files) {
4557
4559
  if (before.replay) return before.replay;
4558
4560
  const batches = [];
4559
4561
  for (const stored of before.batches) batches.push(await loadBatch(files, stored, signal));
4562
+ if (input.completeUnits && !trustedReuse) for (const [index, batch] of batches.entries()) {
4563
+ const proof = input.units[index]?.coverage;
4564
+ if (!proof || proof.attemptId !== input.packId || !matchesReadReceipts(batch, input.packId, proof.receipts)) throw new ApplicationError("INVALID_SELECTION", "incompleteReviewCoverage");
4565
+ }
4560
4566
  const admitted = [...input.terms.entries()].filter(([, term]) => !isGenericPublicTerm(term));
4561
4567
  const terms = admitted.map(([, term]) => term);
4562
4568
  const { located, kept, unlocated, unlocatedIndices } = locateTerms(batches, terms);
@@ -4615,7 +4621,7 @@ function createStagedTerms(access, files) {
4615
4621
  confirmedHideDelta
4616
4622
  });
4617
4623
  });
4618
- const resolveScanAliases = createScanAliasResolver(access, files, recordTerms);
4624
+ const resolveScanAliases = createScanAliasResolver(access, files, (input) => recordTerms(input, true));
4619
4625
  return {
4620
4626
  resolveScanAliases,
4621
4627
  async recordTerms(input) {
@@ -4671,7 +4677,7 @@ function createStagedTerms(access, files) {
4671
4677
  completeUnits: true,
4672
4678
  units: slice,
4673
4679
  terms: []
4674
- });
4680
+ }, true);
4675
4681
  }
4676
4682
  }
4677
4683
  };
@@ -4791,7 +4797,7 @@ function createStagedJourney(access, root, databaseId) {
4791
4797
  async putBatch(batch) {
4792
4798
  await access.staged(async (leg, signal) => {
4793
4799
  signal.throwIfAborted();
4794
- const state = await leg.run("journey.current", { journeyId: batch.journeyId });
4800
+ const state = await leg.run("journey.preparation.state", { journeyId: batch.journeyId });
4795
4801
  if (!state) throw new ApplicationError("UNKNOWN_ITEM");
4796
4802
  await putStagedBatch(leg, signal, state, batch, files);
4797
4803
  });
@@ -5058,10 +5064,14 @@ async function openStore(options, backupObsolete) {
5058
5064
  sessionReviewStatus: (input) => stagedJourney.sessionReviewStatus(input),
5059
5065
  reviewAttempts: (input) => access.run("journey.review.attempts", input),
5060
5066
  acknowledgeSessionUsefulness: (input) => stagedJourney.acknowledgeSessionUsefulness(input),
5067
+ preparationState: (journeyId) => access.run("journey.preparation.state", { journeyId }),
5068
+ preparationPermission: (journeyId) => access.run("journey.preparation.permission", { journeyId }),
5069
+ updatePreparation: (input) => access.run("journey.preparation.update", input),
5061
5070
  current: (journeyId) => access.run("journey.current", journeyId ? { journeyId } : {}),
5062
5071
  commit: (input) => stagedJourney.commit(input),
5063
5072
  commitClassification: (input) => stagedJourney.commitClassification(input),
5064
5073
  hideIndexKey: (journeyId) => stagedJourney.hideIndexKey(journeyId),
5074
+ reopenEmpty: (input) => access.run("journey.terms.reopen-empty", input),
5065
5075
  recordTerms: (input) => stagedJourney.recordTerms(input),
5066
5076
  journeyTerms: (input) => stagedJourney.journeyTerms(input),
5067
5077
  events: (journeyId, after, requireCurrent) => access.run("journey.events", {
@@ -5646,7 +5656,17 @@ async function readRemoteState(stateDir, journeyId) {
5646
5656
  decisions: z.record(z.string(), z.boolean()),
5647
5657
  parents: z.record(z.string(), z.string()),
5648
5658
  copied: z.array(attachment),
5649
- failures: z.array(z.string())
5659
+ failures: z.array(z.string()),
5660
+ sourceFailureCounts: z.partialRecord(z.enum([
5661
+ "source-changed",
5662
+ "source-inaccessible",
5663
+ "source-missing",
5664
+ "compressed-decode",
5665
+ "invalid-json",
5666
+ "record-limit",
5667
+ "invalid-utf8",
5668
+ "other"
5669
+ ]), z.number().int().positive()).optional()
5650
5670
  }).strict().parse(value);
5651
5671
  } catch (error) {
5652
5672
  if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
@@ -21,12 +21,52 @@ const knownCodes = {
21
21
  function isProcessingCode(value) {
22
22
  return Object.prototype.hasOwnProperty.call(knownCodes, value);
23
23
  }
24
+ const sitePattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+){0,7}$/;
25
+ const harnessPattern = /^[a-z]{1,16}$/;
26
+ const versionPattern = /^\d{1,6}(?:\.\d{1,6}){1,3}(?:-[0-9A-Za-z.]{1,24})?$/;
27
+ /** The validated site fields of `value`; anything that does not match its pattern is dropped. */
28
+ function siteFields(value) {
29
+ if (typeof value !== "object" || value === null) return void 0;
30
+ const site = Reflect.get(value, "site");
31
+ if (typeof site !== "string" || !sitePattern.test(site)) return void 0;
32
+ const harness = Reflect.get(value, "harness");
33
+ const harnessVersion = Reflect.get(value, "harnessVersion");
34
+ return {
35
+ site,
36
+ ...typeof harness === "string" && harnessPattern.test(harness) ? { harness } : {},
37
+ ...typeof harnessVersion === "string" && versionPattern.test(harnessVersion) ? { harnessVersion } : {}
38
+ };
39
+ }
40
+ /** The version string a harness record declares, when it has the shape of a version. */
41
+ function declaredVersion(value) {
42
+ return value !== void 0 && versionPattern.test(value) ? value : void 0;
43
+ }
44
+ /**
45
+ * The outermost named site in an error's cause chain (and aggregate members), if any. Depth first:
46
+ * a wide aggregate of wrapped refusals must not spend the visit budget before the first named one.
47
+ */
48
+ function processingSite(error) {
49
+ const stack = [error];
50
+ for (let visited = 0; visited < 32 && stack.length; visited++) {
51
+ const current = stack.pop();
52
+ if (!(current instanceof Error)) continue;
53
+ const found = siteFields(current);
54
+ if (found) return found;
55
+ if (current instanceof AggregateError) stack.push(...current.errors.slice(0, 16).reverse());
56
+ if (current.cause !== void 0) stack.push(current.cause);
57
+ }
58
+ }
24
59
  var ProcessingError = class extends Error {
25
60
  code;
61
+ site;
62
+ harness;
63
+ harnessVersion;
26
64
  constructor(code, options) {
27
65
  super(code, options);
28
66
  this.name = "ProcessingError";
29
67
  this.code = code;
68
+ const named = siteFields(options);
69
+ if (named) Object.assign(this, named);
30
70
  }
31
71
  };
32
72
  function fail(code, options) {
@@ -138,6 +178,10 @@ const credentialNames = Object.freeze([
138
178
  "auth_token",
139
179
  "session_token",
140
180
  "authorization",
181
+ "authorization_code",
182
+ "oauth_code",
183
+ "密碼",
184
+ "密码",
141
185
  "proxy_authorization",
142
186
  "x_api_key",
143
187
  "private_key",
@@ -423,13 +467,13 @@ function assignments(input, output) {
423
467
  }
424
468
  if (input.field.kind === "key") return;
425
469
  const consumed = headers(input, output);
426
- if (!/[:=]|--/u.test(input.text)) return;
470
+ if (!/[:=:]|--/u.test(input.text)) return;
427
471
  if (!mayContainCredentialName(input.text)) return;
428
- const expression = /(?:(?<![\p{L}\p{N}_/?&#-])(\\?["']?)([\p{L}\p{N}_-]{1,64})\1([ \t]*)[:=]([ \t]*)|(?<![\p{L}\p{N}_-])--([\p{L}\p{N}_-]{1,64})([ \t]+)(?![ \t-]))/giu;
472
+ const expression = /(?:(?<![\p{L}\p{N}_/?&#-])(\\?["']?)((?:oauth[ \t]+)?authorization[ \t]+code|oauth[ \t]+code|[\p{L}\p{N}_-]{1,64})\1([ \t]*)[:=:]([ \t]*)|(?<![\p{L}\p{N}_-])--([\p{L}\p{N}_-]{1,64})([ \t]+)(?![ \t-]))/giu;
429
473
  let match;
430
474
  let headerIndex = 0;
431
475
  while ((match = expression.exec(input.text)) !== null) {
432
- const label = normalizeCredentialName(match[2] ?? match[5] ?? "");
476
+ const label = normalizeCredentialName((match[2] ?? match[5] ?? "").replace(/[ \t]+/gu, "_"));
433
477
  if (!credentialName(label)) continue;
434
478
  while ((consumed[headerIndex]?.end ?? Infinity) <= match.index) headerIndex += 1;
435
479
  const header = consumed[headerIndex];
@@ -2564,10 +2608,10 @@ function urlActions(locator, input, result) {
2564
2608
  actions: [action]
2565
2609
  });
2566
2610
  }
2567
- const inspect = (range, key, query = false) => {
2611
+ const inspect = (range, key, query = false, oauthResponse = false) => {
2568
2612
  if (range.start >= range.end) return;
2569
2613
  const raw = input.text.slice(range.start, range.end);
2570
- const credential = key !== void 0 && credentialName(key);
2614
+ const credential = key !== void 0 && (credentialName(key) || oauthResponse && key === "code");
2571
2615
  if (!withinLimit({
2572
2616
  raw,
2573
2617
  range
@@ -2614,6 +2658,8 @@ function urlActions(locator, input, result) {
2614
2658
  const end = hash < 0 ? locator.raw.length : hash;
2615
2659
  const question = locator.raw.indexOf("?", pathEnd);
2616
2660
  if (question >= 0 && question < end) {
2661
+ const keys = new URLSearchParams(locator.raw.slice(question + 1, end));
2662
+ const oauthResponse = (locator.scheme === "http" || locator.scheme === "https") && keys.has("code") && (keys.has("state") || keys.has("session_state") || /(?:^|\/)(?:oauth2?|callback|oauth2?[_-]callback)(?:\/|$)/iu.test(locator.raw.slice(suffix, pathEnd)));
2617
2663
  start = question + 1;
2618
2664
  for (let index = start; index <= end; index++) {
2619
2665
  if (index !== end && locator.raw[index] !== "&") continue;
@@ -2623,7 +2669,7 @@ function urlActions(locator, input, result) {
2623
2669
  if (key !== null) inspect({
2624
2670
  start: offset + equals + 1,
2625
2671
  end: offset + index
2626
- }, key, true);
2672
+ }, key, true, oauthResponse);
2627
2673
  } else inspect({
2628
2674
  start: offset + start,
2629
2675
  end: offset + index
@@ -4794,7 +4840,7 @@ function createRegistry(options, limits) {
4794
4840
  const required = /* @__PURE__ */ new Map();
4795
4841
  for (const step of steps) {
4796
4842
  const registration = nodes.get(refKey(step.node));
4797
- if (!registration) return fail("PROCESSING_UNSUPPORTED");
4843
+ if (!registration) return fail("PROCESSING_UNSUPPORTED", { site: "registry-node-missing" });
4798
4844
  const configured = registration.configure(step.options);
4799
4845
  if (refKey(configured.ref) !== refKey(step.node) || typeof configured.process !== "function" || !Array.isArray(configured.requires) || !Array.isArray(configured.ruleIds) || configured.ruleIds.length > 256 || configured.ruleIds.some((id) => typeof id !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(id)) || new Set(configured.ruleIds).size !== configured.ruleIds.length) return fail("PROCESSING_INVALID_PLAN");
4800
4846
  const checked = buildPlan([], configured.requires.map((ref) => ({
@@ -4802,7 +4848,7 @@ function createRegistry(options, limits) {
4802
4848
  version: ref.version
4803
4849
  })));
4804
4850
  for (const ref of checked.analyses) {
4805
- if (!analyses.has(refKey(ref))) return fail("PROCESSING_UNSUPPORTED");
4851
+ if (!analyses.has(refKey(ref))) return fail("PROCESSING_UNSUPPORTED", { site: "registry-analysis-missing" });
4806
4852
  required.set(refKey(ref), ref);
4807
4853
  }
4808
4854
  Object.freeze(configured);
@@ -4821,7 +4867,7 @@ function createRegistry(options, limits) {
4821
4867
  }
4822
4868
  const plan = buildPlan(steps, [...required.values()]);
4823
4869
  const parsers = plan.analyses.map((ref) => {
4824
- return analyses.get(refKey(ref)) ?? fail("PROCESSING_UNSUPPORTED");
4870
+ return analyses.get(refKey(ref)) ?? fail("PROCESSING_UNSUPPORTED", { site: "registry-parser-missing" });
4825
4871
  });
4826
4872
  return Object.freeze({
4827
4873
  plan,
@@ -5176,7 +5222,7 @@ function validateSelection(root, selection, options) {
5176
5222
  if (edit?.mode.kind === "empty" && node.kind === "literal") fail("PROCESSING_INVALID_PROPOSAL");
5177
5223
  if (edit?.replacementOrigin !== void 0 && node.kind !== "string") fail("PROCESSING_INVALID_PROPOSAL");
5178
5224
  if (edit?.replacementSourceRanges !== void 0) {
5179
- if (node.kind !== "string" || edit.replacementOrigin !== "user-message" || !edit.replacementSourceRanges.length) fail("PROCESSING_INVALID_PROPOSAL");
5225
+ if (node.kind !== "string" || edit.replacementOrigin !== "user-message" && !(edit.role === "main-text" && edit.mode.kind === "remove" && edit.replacement !== void 0) || !edit.replacementTargetRanges || !edit.replacementSourceRanges.length) fail("PROCESSING_INVALID_PROPOSAL");
5180
5226
  let end = 0;
5181
5227
  for (const range of edit.replacementSourceRanges) {
5182
5228
  if (!Number.isSafeInteger(range.start) || !Number.isSafeInteger(range.end) || range.start < end || range.end <= range.start || range.end > node.value.length) fail("PROCESSING_INVALID_PROPOSAL");
@@ -5917,7 +5963,7 @@ function projectNativeRecord(root, selection, options) {
5917
5963
  if (Buffer.byteLength(edit.replacement) > options.limits.maxOutputBytes) fail("PROCESSING_LIMIT");
5918
5964
  }
5919
5965
  if (edit?.mode.kind === "head-tail") {
5920
- if (node.kind !== "string") fail("PROCESSING_UNSUPPORTED");
5966
+ if (node.kind !== "string") fail("PROCESSING_UNSUPPORTED", { site: "retention-window-not-string" });
5921
5967
  const { segments } = selectOriginalWindows(options.sampleTexts?.get(node.id) ?? node.value, edit.mode);
5922
5968
  const rendered = JSON.stringify({
5923
5969
  kind: "text-sample",
@@ -6306,7 +6352,7 @@ function staticRegistration(category) {
6306
6352
  if (seen.has(action.targetId)) continue;
6307
6353
  seen.add(action.targetId);
6308
6354
  if (action.range.start < end) {
6309
- if (action.range.end > end) fail("PROCESSING_UNSUPPORTED");
6355
+ if (action.range.end > end) fail("PROCESSING_UNSUPPORTED", { site: "static-action-overlap" });
6310
6356
  continue;
6311
6357
  }
6312
6358
  const view = context.view(action.targetId);
@@ -7146,7 +7192,7 @@ function createDetectionSummary() {
7146
7192
  }
7147
7193
  //#endregion
7148
7194
  //#region packages/processing/src/inspection/versions.ts
7149
- const currentDetectorVersion = `static-catalog-11`;
7195
+ const currentDetectorVersion = `static-catalog-12`;
7150
7196
  /** Before-redaction inspection; cleanup and redaction have independent lifetimes. */
7151
7197
  const inspectionSemanticVersions = Object.freeze({
7152
7198
  implementation: originalInspectionVersion,
@@ -7733,7 +7779,7 @@ function collectNativeReviewInput(request, originals, options, scope = "output")
7733
7779
  const originalSource = source ?? sources.get(field.fieldId.replace(/-k$/u, ""));
7734
7780
  if (!originalSource) fail("PROCESSING_INVALID_RECORD");
7735
7781
  const edit = edits.get(originalSource.nodeId);
7736
- if (scope === "main-prose" && edit?.replacementOrigin === "user-message") {
7782
+ if (scope === "main-prose" && (edit?.replacementOrigin === "user-message" || edit?.replacementSourceRanges)) {
7737
7783
  if (!edit.replacementSourceRanges?.length) fail("PROCESSING_INVALID_RECORD");
7738
7784
  for (const [index, range] of edit.replacementSourceRanges.entries()) {
7739
7785
  const text = originalSource.text.slice(range.start, range.end);
@@ -8494,6 +8540,8 @@ const safeCodes = /* @__PURE__ */ new Set([
8494
8540
  "SEND_SCOPE_BUSY",
8495
8541
  "SEND_REPLACE_REFUSED",
8496
8542
  "SESSION_CONTENT_CONFLICT",
8543
+ "SESSION_MOVE_ACCESS_REQUIRED",
8544
+ "SESSION_MOVE_ACCESS_HELD",
8497
8545
  "SEND_SCOPE_INVALIDATED",
8498
8546
  "WORK_REMOVED",
8499
8547
  "ACCOUNT_CHANGED",
@@ -8504,6 +8552,8 @@ const safeCodes = /* @__PURE__ */ new Set([
8504
8552
  "SENSITIVE_TERMS_CHANGED",
8505
8553
  "ACCOUNT_NOT_CONFIGURED",
8506
8554
  "ACCOUNT_SIGNED_OUT",
8555
+ "ACCOUNT_ACCESS_UNAVAILABLE",
8556
+ "JOURNEY_SIGN_IN_REQUIRED",
8507
8557
  "ACCOUNT_PROFILE_UNAVAILABLE",
8508
8558
  "PASSPORT_ADDRESS_TAKEN",
8509
8559
  "PASSPORT_ADDRESS_RESERVED",
@@ -8649,7 +8699,18 @@ const safeFields = /* @__PURE__ */ new Set([
8649
8699
  "cleanup.ref",
8650
8700
  "cleanup.bodyModes",
8651
8701
  "changes",
8652
- "mode"
8702
+ "mode",
8703
+ "cards.append.empty",
8704
+ "cards.append.limit",
8705
+ "cards.append.duplicate-card",
8706
+ "cards.append.existing-card",
8707
+ "cards.append.duplicate-extension",
8708
+ "cards.append.unknown-card",
8709
+ "cards.append.duplicate-term",
8710
+ "cards.append.term-not-open",
8711
+ "cards.append.own-identity-card",
8712
+ "cards.append.other-person",
8713
+ "classification.late.several-works"
8653
8714
  ]);
8654
8715
  function safeField(error) {
8655
8716
  if (!(error instanceof ApplicationError) || !error.field) return null;
@@ -8975,6 +9036,24 @@ const termEvidenceSchema = z.object({
8975
9036
  rationale: termAssessmentSchema.shape.rationale,
8976
9037
  stance: termAssessmentSchema.shape.stance
8977
9038
  }).strict().refine((evidence) => evidence.end > evidence.start);
9039
+ const namedBatch = z.object({
9040
+ journeyId: id$1,
9041
+ batchId: id$1,
9042
+ batchDigest: digest$3
9043
+ }).strict();
9044
+ const emptyReviewCorrectionSchema = z.discriminatedUnion("kind", [namedBatch.extend({ kind: z.literal("inspect") }).strict(), namedBatch.extend({
9045
+ kind: z.literal("apply"),
9046
+ expectedPackId: id$1,
9047
+ idempotencyKey: id$1
9048
+ }).strict()]);
9049
+ const emptyReviewCorrectionResultSchema = z.object({
9050
+ status: z.enum([
9051
+ "eligible",
9052
+ "reopened",
9053
+ "replayed"
9054
+ ]),
9055
+ packId: id$1
9056
+ }).strict();
8978
9057
  /** One pack of read units and the values found in them (`review.terms`). */
8979
9058
  const reviewTermsInputSchema = z.object({
8980
9059
  journeyId: id$1,
@@ -8985,6 +9064,10 @@ const reviewTermsInputSchema = z.object({
8985
9064
  units: z.array(z.object({
8986
9065
  batchId: id$1,
8987
9066
  batchDigest: digest$3,
9067
+ coverage: z.object({
9068
+ attemptId: id$1,
9069
+ receipts: z.array(digest$3).min(1).max(8e4)
9070
+ }).strict().optional(),
8988
9071
  /** Legacy unit summary in stored packs; accepted and never read (ADR 0178). */
8989
9072
  summary: z.string().trim().min(1).refine((value) => Buffer.byteLength(value) <= 1024).optional(),
8990
9073
  exclude: z.string().trim().refine((value) => codePoints(value) >= 1 && codePoints(value) <= 500).nullable()
@@ -9420,6 +9503,13 @@ const journeyArtifactSchema = z.object({
9420
9503
  archiveBytes: count$1
9421
9504
  }).strict()
9422
9505
  }).strict();
9506
+ /** A closed reader attempt that left named units without a coverage receipt. */
9507
+ const reviewInterruptionSchema = z.object({
9508
+ inputRevision: count$1.min(1),
9509
+ packId: journeyIdSchema,
9510
+ reason: z.enum(["reader-refused", "retry-exhausted"]),
9511
+ batchIds: z.array(journeyIdSchema).min(1).max(1e4).refine((ids) => new Set(ids).size === ids.length)
9512
+ }).strict();
9423
9513
  const journeyWorkSchema = z.object({
9424
9514
  id: journeyIdSchema,
9425
9515
  title: label,
@@ -9444,7 +9534,8 @@ const journeyWorkSchema = z.object({
9444
9534
  "default",
9445
9535
  "model",
9446
9536
  "explicit",
9447
- "delegate"
9537
+ "delegate",
9538
+ "account"
9448
9539
  ]),
9449
9540
  placement: z.enum([
9450
9541
  "placed",
@@ -9461,6 +9552,15 @@ const journeyWorkSchema = z.object({
9461
9552
  grouping: z.enum(["workspace", "regrouped"]),
9462
9553
  access: journeyAccessSchema,
9463
9554
  accessConfirmed: z.boolean(),
9555
+ accessChoice: z.object({
9556
+ channel: z.enum([
9557
+ "conversation",
9558
+ "panel",
9559
+ "account"
9560
+ ]),
9561
+ at: z.iso.datetime()
9562
+ }).strict().optional(),
9563
+ accountAccessConflict: z.boolean().optional(),
9464
9564
  reason: z.string().max(1e3),
9465
9565
  revision: count$1,
9466
9566
  inputRevision: count$1.min(1),
@@ -9501,6 +9601,7 @@ const journeyWorkSchema = z.object({
9501
9601
  /** Images the Work's sessions leave out (D7); absent when a session receipt predates it. */
9502
9602
  imagesOmitted: count$1.optional()
9503
9603
  }).strict().optional(),
9604
+ reviewInterruptions: z.array(reviewInterruptionSchema).optional(),
9504
9605
  totalBatches: count$1,
9505
9606
  completedBatches: count$1,
9506
9607
  groupIds: z.array(journeyIdSchema),
@@ -9524,7 +9625,12 @@ const journeyWorkSchema = z.object({
9524
9625
  const journeyConsentSchema = z.object({
9525
9626
  provider: label,
9526
9627
  allowedAt: z.iso.datetime(),
9527
- source: z.enum(["conversation", "panel"])
9628
+ source: z.enum(["conversation", "panel"]),
9629
+ /**
9630
+ * The account signed in when consent was recorded (ADR 0276 D8). Absent in a build with no
9631
+ * sign-in client and in a journey started before this version (Q11 a, Q13 a).
9632
+ */
9633
+ subject: z.string().min(1).max(128).optional()
9528
9634
  }).strict();
9529
9635
  const journeyExceptionSchema = z.object({
9530
9636
  id: journeyIdSchema,
@@ -9595,8 +9701,29 @@ const nativeJourneySchema = z.object({
9595
9701
  /** Sessions whose last activity lies in this period (ADR 0206); absent means all. */
9596
9702
  period: sessionPeriodSchema.optional(),
9597
9703
  /** The Passport address and links chosen in this Journey (ADR 0246); absent means none yet. */
9598
- profile: journeyProfileSchema.optional()
9704
+ profile: journeyProfileSchema.optional(),
9705
+ /**
9706
+ * The last account read that re-seeded every Work (ADR 0277 section 5). Only scope
9707
+ * confirmation and Retry set `read`; late classification records only a failure. Absent in a
9708
+ * journey of an earlier version, which reads as not `read`.
9709
+ */
9710
+ accountRead: z.object({
9711
+ status: z.enum([
9712
+ "read",
9713
+ "signed-out",
9714
+ "unavailable"
9715
+ ]),
9716
+ subject: z.string().min(1).max(128).optional(),
9717
+ at: z.iso.datetime()
9718
+ }).strict().optional()
9599
9719
  }).strict();
9720
+ /**
9721
+ * Consent with no subject: a journey started before sign-in was required, or in a build with no
9722
+ * sign-in client. It finishes under the rules it started with (ADR 0276 Q13 a, Q11 a).
9723
+ */
9724
+ function consentedWithoutAccount(state) {
9725
+ return state.consent !== null && state.consent.subject === void 0;
9726
+ }
9600
9727
  //#endregion
9601
9728
  //#region packages/application/src/journey/b/model.ts
9602
9729
  const bMethod = "sesspilot-b-v2";
@@ -10714,6 +10841,63 @@ function compileBFindings(batch, evidence) {
10714
10841
  return findings;
10715
10842
  }
10716
10843
  //#endregion
10844
+ //#region packages/application/src/journey/terms/read-pages.ts
10845
+ /** Leave ample space for tool framing, JSON escaping and the final receipt on each read. */
10846
+ const pageBytes = 6e3;
10847
+ /** Each receipt binds the delivered text, its position, the frozen batch and its assignment. */
10848
+ function reviewReadPages(batch, attemptId) {
10849
+ const pages = [];
10850
+ let text = "";
10851
+ function flush() {
10852
+ if (!text) return;
10853
+ const receipt = createHash("sha256").update(JSON.stringify([
10854
+ "scan-read-v1",
10855
+ attemptId,
10856
+ batch.id,
10857
+ batch.digest,
10858
+ pages.length,
10859
+ text
10860
+ ])).digest("hex");
10861
+ pages.push({
10862
+ text,
10863
+ receipt
10864
+ });
10865
+ text = "";
10866
+ }
10867
+ for (const chunk of batch.chunks) {
10868
+ if (!chunk.text.length) throw new Error("EMPTY_REVIEW_PAGE");
10869
+ let offset = 0;
10870
+ while (offset < chunk.text.length) {
10871
+ const header = "\nCHUNK " + chunk.id + " " + (chunk.core ? "review" : "context") + " " + chunk.role + " UTF16_START " + offset + "\n";
10872
+ const available = pageBytes - Buffer.byteLength(text + header);
10873
+ if (available < 4) {
10874
+ if (!text) throw new Error("INVALID_REVIEW_PAGE_HEADER");
10875
+ flush();
10876
+ continue;
10877
+ }
10878
+ let end = offset;
10879
+ let bytes = 0;
10880
+ while (end < chunk.text.length) {
10881
+ const point = chunk.text.codePointAt(end);
10882
+ if (point === void 0) throw new Error("INVALID_REVIEW_PAGE_RANGE");
10883
+ const size = point < 128 ? 1 : point < 2048 ? 2 : point < 65536 ? 3 : 4;
10884
+ if (bytes + size > available) break;
10885
+ end += point >= 65536 ? 2 : 1;
10886
+ bytes += size;
10887
+ }
10888
+ text += header + chunk.text.slice(offset, end);
10889
+ offset = end;
10890
+ if (offset < chunk.text.length) flush();
10891
+ }
10892
+ }
10893
+ flush();
10894
+ return pages;
10895
+ }
10896
+ function matchesReadReceipts(batch, attemptId, receipts) {
10897
+ const pages = reviewReadPages(batch, attemptId);
10898
+ return pages.length > 0 && pages.length === receipts.length && pages.every((page, i) => page.receipt === receipts[i]);
10899
+ }
10900
+ //#endregion
10717
10901
  //#region packages/application/src/journey/terms/locate.ts
10718
10902
  /** NFC core text of each analysed field, contiguous core chunks joined, with its Work. */
10719
10903
  function coreTexts(batches) {
@@ -10764,7 +10948,7 @@ function locateTerms(batches, terms) {
10764
10948
  }];
10765
10949
  }));
10766
10950
  for (const { type, value, index } of unique.values()) {
10767
- if (admitCustomTerm(value)?.value !== value || !texts.some((item) => item.text.includes(value))) {
10951
+ if (value.includes("█") || admitCustomTerm(value)?.value !== value || !texts.some((item) => item.text.includes(value))) {
10768
10952
  unlocated++;
10769
10953
  unlocatedIndices.push(index);
10770
10954
  continue;
@@ -10788,4 +10972,4 @@ function locateTerms(batches, terms) {
10788
10972
  };
10789
10973
  }
10790
10974
  //#endregion
10791
- export { bCountSchema as $, detectStatic as $n, safeField as $t, bDuplicateMirror as A, createReplacementKey as An, journeyTermSchema as At, bEvidenceReader as B, nativeItems as Bn, sessionPeriodSchema as Bt, validateBUnit as C, inspectionSemanticVersions as Cn, cardsSubmitSchema as Ct, uncoveredBObligations as D, createStaticProcessor as Dn, privacyResolveSchema as Dt, bLiterals as E, walkNativeFields as En, packageConfirmActionSchema as Et, bClassificationKey as F, entityDictionaryVersion as Fn, termTypeInfo as Ft, subtractBRanges as G, validateProfile as Gn, ownerProfileSchema as Gt, codePointLength as H, transformRecords as Hn, journeyProfileAddressActionSchema as Ht, bIssue as I, nativeParserVersion as In, termTypeSchema as It, bRetainedGroupSchema as J, validatePlan as Jn, respondProfileLinks as Jt, utf16Offset as K, orderProfile as Kn, passportAddressSchema as Kt, bOverlaps as L, redactionImplementationVersion as Ln, termTypes as Lt, bLegacyBindings as M, projectNativeRecord as Mn, reviewTermsResultSchema as Mt, bUnitFragments as N, parseNativeRecord as Nn, termAssessmentSchema as Nt, indexBRanges as O, staticDefaults as On, privacyTermKey as Ot, bAdoptedObligations as P, cleanupImplementationVersion as Pn, termOverrideValueSchema as Pt, bAnchorSchema as Q, resolveLimits as Qn, safeCode as Qt, unownedBObligations as R, nativeBoolean as Rn, deselectOutsidePeriod as Rt, validateBFields as S, currentDetectorVersion as Sn, cardsConfirmActionSchema as St, bLiteralTerms as T, gapReasons as Tn, emptyJourneyPrivacy as Tt, codePointSlice as U, frameRecords as Un, journeyProfileLinksActionSchema as Ut, bDigest as V, nativeText as Vn, emptyJourneyProfile as Vt, createCodePointIndex as W, retainedMainTextNodes as Wn, mergeOwnerProfile as Wt, bSessionDecisionSchema as X, defaultLimits as Xn, ApplicationError as Xt, bReviewSubmissionSchema as Y, copyData as Yn, classificationTitleMaskSchema as Yt, bTermSchema as Z, recordPointerLimits as Zn, UnfinishedJourneyError as Zt, semanticFindingSchema as _, reviewRoles as _n, hideConfirmSchema as _t, reviewChunkSchema as a, observeSource as an, admitCustomTerm as ar, journeyExceptionSchema as at, validateBReview as b, createSessionPreparation as bn, journeyConfigurationSchema as bt, textDigest as c, inventorySchema as cn, scalarBefore as cr, journeyPreferenceScopeSchema as ct, reviewAlignmentAudit as d, workspaceSchema as dn, fail as dr, nativeJourneySchema as dt, familyNeedsReview as en, isStaticCategory as er, bIdSchema as et, reviewAlignmentAuditSchema as f, nativeSourceIdentitySchema as fn, isProcessingCode as fr, journeyGuidanceSchema as ft, validateReviewAlignment as g, mainReviewRole as gn, journeyWorkSuggestionSchema as gt, reviewFindingsDigest as h, projectNativeReviewInput as hn, journeyDescribeSchema as ht, reviewBatchSchema as i, sourceKey as in, createEntityMatcher as ir, journeyDigestSchema as it, bDuplicateShift as j, sessionNonce as jn, reviewTermsInputSchema as jt, bBindingCap as k, staticOptions as kn, privacyTermSchema as kt, validateReview as l, sessionSchema as ln, defaultDetectionLimits as lr, journeyProjectTypeSchema as lt, reviewAlignmentSchema as m, processNativeRecord as mn, delegatedDecisionSchema as mt, compileBFindings as n, reviewFamilies as nn, jsonSpans as nr, journeyAccessSchema as nt, reviewDigest as o, sourceSnapshotId as on, admitGitName as or, journeyIdSchema as ot, reviewAlignmentInputSchema as p, withMandatoryCustomTerms as pn, journeyInstructionInputSchema as pt, bRepresentationSchema as q, buildPlan as qn, profileHasChoices as qt, reviewBatchChunks as r, sourceGraph as rn, agentContextLocation as rr, journeyChoiceSchema as rt, reviewSubmitSchema as s, fileIdentitySchema as sn, scalarAfter as sr, journeyKindSchema as st, locateTerms as t, familySelected as tn, staticCategories as tr, bMethod as tt, findingReferenceKey as u, sourcePartSchema as un, ProcessingError as ur, journeyWorkTypeSchema as ut, bContextEvidence as v, createSentenceContext as vn, hidePlanInputSchema as vt, bLiteralAdmitted as w, createDetectionSummary as wn, decisionCardInputSchema as wt, createBAnalysisUnits as x, bindInspection as xn, cardAnswerActionSchema as xt, validateBClassification as y, renderNative as yn, hidePlanResourceSchema as yt, bAnchorKey as z, nativeField as zn, filterInventoryByPeriod as zt };
10975
+ export { bTermSchema as $, buildPlan as $n, profileHasChoices as $t, indexBRanges as A, createDetectionSummary as An, packageConfirmActionSchema as At, unownedBObligations as B, cleanupImplementationVersion as Bn, termOverrideValueSchema as Bt, createBAnalysisUnits as C, reviewRoles as Cn, hidePlanResourceSchema as Ct, bLiteralTerms as D, bindInspection as Dn, cardsSubmitSchema as Dt, bLiteralAdmitted as E, createSessionPreparation as En, cardsConfirmActionSchema as Et, bUnitFragments as F, staticOptions as Fn, emptyReviewCorrectionSchema as Ft, codePointSlice as G, nativeField as Gn, filterInventoryByPeriod as Gt, bEvidenceReader as H, nativeParserVersion as Hn, termTypeSchema as Ht, bAdoptedObligations as I, createReplacementKey as In, journeyTermSchema as It, utf16Offset as J, transformRecords as Jn, journeyProfileAddressActionSchema as Jt, createCodePointIndex as K, nativeItems as Kn, sessionPeriodSchema as Kt, bClassificationKey as L, sessionNonce as Ln, reviewTermsInputSchema as Lt, bDuplicateMirror as M, walkNativeFields as Mn, privacyTermKey as Mt, bDuplicateShift as N, createStaticProcessor as Nn, privacyTermSchema as Nt, bLiterals as O, currentDetectorVersion as On, decisionCardInputSchema as Ot, bLegacyBindings as P, staticDefaults as Pn, emptyReviewCorrectionResultSchema as Pt, bSessionDecisionSchema as Q, orderProfile as Qn, passportAddressSchema as Qt, bIssue as R, projectNativeRecord as Rn, reviewTermsResultSchema as Rt, validateBReview as S, mainReviewRole as Sn, hidePlanInputSchema as St, validateBUnit as T, renderNative as Tn, cardAnswerActionSchema as Tt, bDigest as U, redactionImplementationVersion as Un, termTypes as Ut, bAnchorKey as V, entityDictionaryVersion as Vn, termTypeInfo as Vt, codePointLength as W, nativeBoolean as Wn, deselectOutsidePeriod as Wt, bRetainedGroupSchema as X, retainedMainTextNodes as Xn, mergeOwnerProfile as Xt, bRepresentationSchema as Y, frameRecords as Yn, journeyProfileLinksActionSchema as Yt, bReviewSubmissionSchema as Z, validateProfile as Zn, ownerProfileSchema as Zt, reviewFindingsDigest as _, workspaceSchema as _n, declaredVersion as _r, journeyInstructionInputSchema as _t, reviewBatchChunks as a, safeField as an, detectStatic as ar, journeyAccessSchema as at, bContextEvidence as b, processNativeRecord as bn, processingSite as br, journeyWorkSuggestionSchema as bt, reviewDigest as c, reviewFamilies as cn, jsonSpans as cr, journeyExceptionSchema as ct, validateReview as d, observeSource as dn, admitCustomTerm as dr, journeyPreferenceScopeSchema as dt, respondProfileLinks as en, validatePlan as er, bAnchorSchema as et, findingReferenceKey as f, sourceSnapshotId as fn, admitGitName as fr, journeyProjectTypeSchema as ft, reviewAlignmentSchema as g, sourcePartSchema as gn, ProcessingError as gr, journeyGuidanceSchema as gt, reviewAlignmentInputSchema as h, sessionSchema as hn, defaultDetectionLimits as hr, reviewInterruptionSchema as ht, compileBFindings as i, safeCode as in, resolveLimits as ir, consentedWithoutAccount as it, bBindingCap as j, gapReasons as jn, privacyResolveSchema as jt, uncoveredBObligations as k, inspectionSemanticVersions as kn, emptyJourneyPrivacy as kt, reviewSubmitSchema as l, sourceGraph as ln, agentContextLocation as lr, journeyIdSchema as lt, reviewAlignmentAuditSchema as m, inventorySchema as mn, scalarBefore as mr, nativeJourneySchema as mt, matchesReadReceipts as n, ApplicationError as nn, defaultLimits as nr, bIdSchema as nt, reviewBatchSchema as o, familyNeedsReview as on, isStaticCategory as or, journeyChoiceSchema as ot, reviewAlignmentAudit as p, fileIdentitySchema as pn, scalarAfter as pr, journeyWorkTypeSchema as pt, subtractBRanges as q, nativeText as qn, emptyJourneyProfile as qt, reviewReadPages as r, UnfinishedJourneyError as rn, recordPointerLimits as rr, bMethod as rt, reviewChunkSchema as s, familySelected as sn, staticCategories as sr, journeyDigestSchema as st, locateTerms as t, classificationTitleMaskSchema as tn, copyData as tr, bCountSchema as tt, textDigest as u, sourceKey as un, createEntityMatcher as ur, journeyKindSchema as ut, validateReviewAlignment as v, nativeSourceIdentitySchema as vn, fail as vr, delegatedDecisionSchema as vt, validateBFields as w, createSentenceContext as wn, journeyConfigurationSchema as wt, validateBClassification as x, projectNativeReviewInput as xn, siteFields as xr, hideConfirmSchema as xt, semanticFindingSchema as y, withMandatoryCustomTerms as yn, isProcessingCode as yr, journeyDescribeSchema as yt, bOverlaps as z, parseNativeRecord as zn, termAssessmentSchema as zt };
@@ -1,4 +1,4 @@
1
- import "./src-DzKuzGVH.mjs";
1
+ import "./src-D1iONla3.mjs";
2
2
  //#region packages/harnesses/src/discovery/model.ts
3
3
  const discoveryBounds = {
4
4
  entries: 1e5,