@gitroll/tacitt-cli 0.6.6 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { _ as permissionDiagnostic, a as readAgentPresence, d as guardDetachedStartup, f as createRenderActivity, g as longCommands, h as businessCommands, i as invoke, l as awaitingPassport, m as parseOptions, n as readOperation, o as createRuntime, p as helpText, r as waitOperation, s as executorEventSchema, t as cancelOperation, u as serveDetached, v as startupFailure, y as traceStartup } from "./query-D2L1WzCS.mjs";
2
+ import { _ as permissionDiagnostic, a as readAgentPresence, d as guardDetachedStartup, f as createRenderActivity, g as longCommands, h as businessCommands, i as invoke, l as awaitingPassport, m as parseOptions, n as readOperation, o as createRuntime, p as helpText, r as waitOperation, s as executorEventSchema, t as cancelOperation, u as serveDetached, v as startupFailure, y as traceStartup } from "./query-CaBXQlpF.mjs";
3
3
  import { nt as makePrivateDirectory, rt as openPrivateFile } from "./src-p_uJNjV3.mjs";
4
- import { A as createExecutionPort, I as inBackgroundStatusPoll, j as startHost, k as readStateDump } from "./job-DiewDY_E.mjs";
4
+ import { A as createExecutionPort, I as inBackgroundStatusPoll, j as startHost, k as readStateDump } from "./job-CeSf9UCC.mjs";
5
5
  import { $t as safeField, Qt as safeCode, Xt as ApplicationError } from "./locate-BWkblijS.mjs";
6
6
  import { $n as reviewTransportBytes, ci as stateSchema, ct as resolveFailureLocation, tt as readWorkspaceOutcomes } from "./src-d7n58sbH.mjs";
7
- import { _t as isCoordinationBusy } from "./heap-DFHajqf2.mjs";
7
+ import { _t as isCoordinationBusy } from "./heap-DsE74_-n.mjs";
8
8
  import { constants, createReadStream, write } from "node:fs";
9
9
  import { z } from "zod";
10
10
  import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
@@ -1,5 +1,5 @@
1
1
  import { et as safeError, h as captureConfiguredSessionJob, j as runConfiguredSessionJob, u as runConfiguredScanJob, z as gitSeedsProvider } from "./src-p_uJNjV3.mjs";
2
- import { d as runJourneyBaseJob, i as runJourneyOutputVerifyJob, n as runJourneyOutputJob, r as runJourneyOutputShardJob } from "./job-DiewDY_E.mjs";
2
+ import { d as runJourneyBaseJob, i as runJourneyOutputVerifyJob, n as runJourneyOutputJob, r as runJourneyOutputShardJob } from "./job-CeSf9UCC.mjs";
3
3
  import { Dn as createStaticProcessor, Qt as safeCode } from "./locate-BWkblijS.mjs";
4
4
  import { l as createNativeAdapters } from "./src-BBjnljUs.mjs";
5
5
  import "./src-d7n58sbH.mjs";
@@ -3608,7 +3608,15 @@ function saveJourneyResource(db, resource) {
3608
3608
  db.prepare("UPDATE journey_resources SET json=? WHERE journey_id=? AND kind=? AND id=?").run(json, resource.journeyId, resource.kind, key);
3609
3609
  return;
3610
3610
  }
3611
- if (old["json"] !== json) throw new ApplicationError("OPERATION_CONFLICT");
3611
+ if (old["json"] !== json) throw new ApplicationError("OPERATION_CONFLICT", void 0, { cause: new Error(JSON.stringify({
3612
+ operation: "journey.saveResource",
3613
+ kind: resource.kind,
3614
+ journeyId: resource.journeyId,
3615
+ resourceKey: key,
3616
+ ..."workId" in resource ? { workId: resource.workId } : {},
3617
+ ..."inputRevision" in resource ? { inputRevision: resource.inputRevision } : {},
3618
+ ..."revision" in resource ? { revision: resource.revision } : {}
3619
+ })) });
3612
3620
  return;
3613
3621
  }
3614
3622
  db.prepare("INSERT INTO journey_resources VALUES(?,?,?,?)").run(resource.journeyId, resource.kind, key, json);
@@ -6988,6 +6996,7 @@ function isOperationName(value) {
6988
6996
  }
6989
6997
  //#endregion
6990
6998
  //#region packages/local-host/src/store/worker/protocol.ts
6999
+ const maximumErrorStackLength = 16384;
6991
7000
  const encodedErrorSchema = z.lazy(() => z.object({
6992
7001
  kind: z.enum([
6993
7002
  "store",
@@ -6998,6 +7007,7 @@ const encodedErrorSchema = z.lazy(() => z.object({
6998
7007
  ]),
6999
7008
  name: z.string(),
7000
7009
  message: z.string(),
7010
+ stack: z.string().max(maximumErrorStackLength).nullable(),
7001
7011
  code: z.string().nullable(),
7002
7012
  errcode: z.number().nullable(),
7003
7013
  errstr: z.string().nullable(),
@@ -7107,8 +7117,8 @@ function dropsAnchor(error) {
7107
7117
  return typeof code === "string" && (code.startsWith("STALE_") || code === "RESET_INCOMPLETE" || code === "STATE_CLOSE_FAILED");
7108
7118
  }
7109
7119
  var ProtocolError = class extends Error {
7110
- constructor(message) {
7111
- super(message);
7120
+ constructor(message, options) {
7121
+ super(message, options);
7112
7122
  this.name = "ProtocolError";
7113
7123
  }
7114
7124
  };
@@ -7122,7 +7132,7 @@ function field(value, key) {
7122
7132
  function text(value) {
7123
7133
  return typeof value === "string" ? value : null;
7124
7134
  }
7125
- /** Keeps codes and causes that classification depends on; no stack crosses the thread. */
7135
+ /** Keeps classification and bounded original stacks for private diagnostics across the Worker. */
7126
7136
  function encodeError(error, depth = 0) {
7127
7137
  const code = text(field(error, "code"));
7128
7138
  const errcode = field(error, "errcode");
@@ -7132,6 +7142,7 @@ function encodeError(error, depth = 0) {
7132
7142
  kind: error instanceof StoreError ? "store" : error instanceof ApplicationError ? "application" : error instanceof ProtocolError ? "protocol" : typeof errcode === "number" ? "sqlite" : "error",
7133
7143
  name: error instanceof Error ? error.name : "Error",
7134
7144
  message: error instanceof Error ? error.message : "Non-error value thrown",
7145
+ stack: text(field(error, "stack"))?.slice(0, 16384) ?? null,
7135
7146
  code,
7136
7147
  errcode: typeof errcode === "number" ? errcode : null,
7137
7148
  errstr: text(field(error, "errstr")),
@@ -7148,7 +7159,7 @@ function decodeError(encoded) {
7148
7159
  let error;
7149
7160
  if (encoded.kind === "store" && isStoreErrorCode(encoded.code)) error = new StoreError(encoded.code, encoded.message, options);
7150
7161
  else if (encoded.kind === "application" && encoded.code !== null) error = new ApplicationError(encoded.code, encoded.field ?? void 0, options);
7151
- else if (encoded.kind === "protocol") error = new ProtocolError(encoded.message);
7162
+ else if (encoded.kind === "protocol") error = new ProtocolError(encoded.message, options);
7152
7163
  else if (encoded.errors.length > 0) error = new AggregateError(encoded.errors.map(decodeError), encoded.message, options);
7153
7164
  else error = new Error(encoded.message, options);
7154
7165
  if (encoded.kind === "error" || encoded.kind === "sqlite") error.name = encoded.name;
@@ -7157,6 +7168,8 @@ function decodeError(encoded) {
7157
7168
  ...encoded.errcode === null ? {} : { errcode: encoded.errcode },
7158
7169
  ...encoded.errstr === null ? {} : { errstr: encoded.errstr }
7159
7170
  });
7171
+ if (encoded.stack === null) delete error.stack;
7172
+ else error.stack = encoded.stack;
7160
7173
  return error;
7161
7174
  }
7162
7175
  //#endregion
@@ -1,7 +1,7 @@
1
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-p_uJNjV3.mjs";
2
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
3
  import { $ as settingsBatchSchema, $r as journeyPreviewSchema, B as inspectionStartSchema, C as rebindReviewOverlay, Ct as sendPrepareSchema, D as staticallyHiddenFindings, Dn as termHideAdditions, Dr as nativeGetSchema, E as guardedFindingText, Er as nativeEventsSchema, It as journeyReviewStorageQuerySchema, Ln as confirmedHideGroupIds, Mr as staticSessionResourceSchema, On as addHideIndexTokens, Or as nativeRespondSchema, Qn as reviewRepairResourceSchema, Qr as journeyFindingsSchema, Qt as journeyPolicyRespondSchema, S as rebindReviewAlignment, Sn as confirmedHideAdditions, Sr as journeyClassificationSessionsSchema, St as sendChoiceSchema, T as reviewBatchReuse, Tn as renderedHideValue, Tt as sendStartSchema, Un as maskedHitsStale, Ut as reviewCompileSchema, W as inspectionQuerySchema, Wt as journeyContextQuerySchema, Xn as reviewCandidateResourceSchema, Yn as reviewCandidateInputSchema, Zn as reviewRepairInputSchema, Zr as journeyFindingImpactSchema, _n as sessionUsefulnessInputSchema, a as bCrossSegmentReviewSchema, ai as selectionSchema, an as reviewAttemptResourceSchema, b as isGenericPublicTerm, bt as replaceSensitiveTermsSchema, c as reconstructBFields, ci as stateSchema, cn as sessionReconcileInputSchema, ct as resolveFailureLocation, dn as sessionRereadInputSchema, ei as journeyRenderInputSchema, en as journeyResourceQuerySchema, er as bReviewDigest, et as settingsQuerySchema, f as selectedValueMembers, ft as manualUploadChoiceSchema, hi as selectFrozenConfiguration, ht as manualUploadStartSchema, i as validateBCrossSegmentReview, ii as selectionBatchSchema, jn as packHideIndex, kn as hideKeyId, mi as freezeConfiguration, mn as sessionReviewQuerySchema, n as scanBatchEquivalenceDigest, ni as commandSchema, nr as planBRepair, o as bRereadDigest, p as splitSelectorValues, pi as defaultScopedSettings, pn as sessionReviewInputSchema, pr as journeyInventoryQuerySchema, pt as manualUploadPrepareSchema, r as locateTermEvidence, ri as packageCommandSchema, rn as journeyPlaceSchema, s as reconcileBSession, si as producerVersion, t as scanBatchContextDigest, ti as journeyRenderSchema, tt as readWorkspaceOutcomes, ut as manualUploadActionSchema, vt as maximumTermsFileBytes, w as rebindReviewSubmit, wn as readConfirmedHideChange, wt as sendRequestSchema, x as bReviewScope, xt as sendActionSchema, z as inspectionCancelSchema } from "./src-d7n58sbH.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-DFHajqf2.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-DsE74_-n.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";
@@ -1,4 +1,4 @@
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-D2L1WzCS.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-CaBXQlpF.mjs";
2
2
  import { $t as safeField, Qt as safeCode, Xt as ApplicationError } from "./locate-BWkblijS.mjs";
3
3
  import "./src-d7n58sbH.mjs";
4
4
  import { z } from "zod";
@@ -1,9 +1,9 @@
1
1
  import { $ as createCleanup, B as parallelismLimits, C as readOriginalSearchFields, F as SessionWorkerError, G as processJourneyMetadataFields, H as privateJourneyDirectory, I as sessionWorkerFailure, K as staticMaskCategory, O as captureLogicalJourneySources, P as createSharedSessionPool, Q as removeNamedTemporarySpools, R as defaultParallelism, T as createCollectionArtifacts, U as readLogicalJourneyFinalMasks, W as readConfiguredOutputInfo, Z as createTemporary, _ as processJourneyMetadata, a as scanReviewFields, at as windowsOwnerOnly, c as readSessionScanRecords, g as readCapturedOriginalRows, i as buildWorkScanBatches, it as restrictToOwner, j as runConfiguredSessionJob, k as capturedJourneyScope, l as scanPreparedSession, m as openConfiguredUpload, n as verifyPreparedSessionSources, nt as makePrivateDirectory, o as createWorkPieces, ot as isWindowsAclFailure, p as configuredSessionUploads, q as readWorkspacePair, r as prepareSessionScans, rt as openPrivateFile, s as readSessionScanFields, st as windowsAclCodes, t as preparedScanConfiguration, v as readStaticSessionMasks, w as readConfiguredSearchFields, y as staticSessionJobs, z as gitSeedsProvider } from "./src-p_uJNjV3.mjs";
2
- import { A as createExecutionPort, C as saveRemoteState, D as createPackagingProgressPort, E as exportDelivery, F as loadDeliveryResults, L as inBackgroundStoreLane, M as withStateMutex, N as createDeliveryService, O as createStore, P as preflight, R as isBackgroundStatusPoll, S as readRemoteState, T as collectRemoteWorkers, _ as staticBaseProduction, a as writeJourneyOutput, b as workApproval, c as mergeHideIndexTokens, f as writeJourneyBase, g as staticBaseInputs, h as staticSessions, l as packRenderHideIndex, m as saveStaticSession, o as createHideIndexTokens, p as readStaticResult, s as hideIndexTexts, t as journeyOutputJob, u as journeyBaseJob, v as readSelectedCaptures, w as journeyDirectory, x as isRemoteImport, y as prepareSourcePlan, z as retrySharingViolation } from "./job-DiewDY_E.mjs";
2
+ import { A as createExecutionPort, C as saveRemoteState, D as createPackagingProgressPort, E as exportDelivery, F as loadDeliveryResults, L as inBackgroundStoreLane, M as withStateMutex, N as createDeliveryService, O as createStore, P as preflight, R as isBackgroundStatusPoll, S as readRemoteState, T as collectRemoteWorkers, _ as staticBaseProduction, a as writeJourneyOutput, b as workApproval, c as mergeHideIndexTokens, f as writeJourneyBase, g as staticBaseInputs, h as staticSessions, l as packRenderHideIndex, m as saveStaticSession, o as createHideIndexTokens, p as readStaticResult, s as hideIndexTexts, t as journeyOutputJob, u as journeyBaseJob, v as readSelectedCaptures, w as journeyDirectory, x as isRemoteImport, y as prepareSourcePlan, z as retrySharingViolation } from "./job-CeSf9UCC.mjs";
3
3
  import { $t as safeField, Bt as sessionPeriodSchema, Dn as createStaticProcessor, Fn as entityDictionaryVersion, Ft as termTypeInfo, Gt as ownerProfileSchema, Kt as passportAddressSchema, Ot as privacyTermKey, Qt as safeCode, Sn as currentDetectorVersion, T as bLiteralTerms, Un as frameRecords, Wt as mergeOwnerProfile, Xt as ApplicationError, Zt as UnfinishedJourneyError, an as observeSource, ar as admitCustomTerm, c as textDigest, ir as createEntityMatcher, nn as reviewFamilies, or as admitGitName, qt as profileHasChoices, tn as familySelected, ur as ProcessingError, zt as filterInventoryByPeriod } from "./locate-BWkblijS.mjs";
4
4
  import { a as mainTextChunks, c as previewInWorker, i as nearestSortingRepository, l as createNativeAdapters, n as createProjectEvidenceCollector, o as mainTextFields, r as sortingRepositoryId, s as textChunks, t as createHarnesses, u as createGitNameSeedProvider } from "./src-BBjnljUs.mjs";
5
5
  import { $ as settingsBatchSchema, A as deviceAuthorizationSchema, Ar as staticReviewDigest, B as inspectionStartSchema, Br as sendResolutionSchema, Bt as classificationWorks, Ct as sendPrepareSchema, Dt as currentJourneyAdapters, Fn as bTermMatcher, Fr as agentSourcesSchema, Gn as retireWorkDescription, Gr as isReadingComplete, Hn as journeyConfirmedHides, Hr as hasCompleteWorkDescription, Ht as newJourneyWork, Ir as journeySendSchema, Jn as workCorrectionBinding, Kn as workDecisionDigest, Kr as isSelectedWork, Lr as sendArtifactSchema, M as profileUrlMatchesIdentity, N as readAccountAvatarUrl, O as createAccount, Ot as obsoleteJourney, P as storedCredentialSchema, Pr as agentSourceSchema, Pt as applyClassification, R as createApplication, Rr as sendReceiptSchema, St as sendChoiceSchema, Tr as privacyDecisionDigest, Tt as sendStartSchema, Ur as isClassifying, V as validateInspectionBatch, Vr as sendSettingsSchema, Vt as retireScanGeneration, W as inspectionQuerySchema, Wr as isIncludedWork, Yr as withReadingProgress, Yt as journeySearchResultSchema, Zt as searchScopeDigest, _ as changeJourney, _r as emptyPreparationFacts, _t as emptyTermsRevision, ai as selectionSchema, ar as scanPreparationDigest, bt as replaceSensitiveTermsSchema, cr as scanGitSeedsResource, et as settingsQuerySchema, ft as manualUploadChoiceSchema, h as hideScopeDigest, ht as manualUploadStartSchema, ii as selectionBatchSchema, j as deviceProfileScopeSchema, k as accountProfileSchema, kr as hasCurrentStaticReview, lr as verifiedScanGitSeeds, lt as validateFailureLocation, m as activeJourneyTerms, mt as manualUploadSchema, ni as commandSchema, or as scanSessionResourceSchema, pt as manualUploadPrepareSchema, ri as packageCommandSchema, rt as appendSensitiveTerms, si as producerVersion, sr as scanGitSeedsId, st as artifactFailureDetailSchema, ui as recommendParallelism, ur as scanExclusionResourceSchema, ut as manualUploadActionSchema, wr as assertJourneyPrivacyReady, wt as sendRequestSchema, xt as sendActionSchema, yt as normalizeSensitiveTerms, z as inspectionCancelSchema, zn as confirmedHideKinds, zr as sendReplaceResultSchema, zt as classificationPartition } from "./src-d7n58sbH.mjs";
6
- import { _t as isCoordinationBusy } from "./heap-DFHajqf2.mjs";
6
+ import { _t as isCoordinationBusy } from "./heap-DsE74_-n.mjs";
7
7
  import { t as createAgentSetupPort } from "./agent-setup-YlFIJz-h.mjs";
8
8
  import { t as workerMessageSchema } from "./messages-D3m3bhva.mjs";
9
9
  import { constants, write } from "node:fs";
@@ -2947,11 +2947,12 @@ async function runWorkers(workers) {
2947
2947
  /** Package-only staging from the complete Track B base; scanning never calls this. */
2948
2948
  async function packageBase(storage, state, work, processing, directory, signal, readState = () => storage.current(state.journeyId), write = writeJourneyBase) {
2949
2949
  assertJourneyPrivacyReady(state, true);
2950
- const existing = (await storage.resources({
2950
+ const readBase = async () => (await storage.resources({
2951
2951
  journeyId: state.journeyId,
2952
2952
  kind: "base",
2953
2953
  id: `${work.id}:${work.inputRevision}`
2954
- })).find((item) => item.kind === "base" && item.workId === work.id && item.inputRevision === work.inputRevision);
2954
+ })).find((item) => item.kind === "base" && item.journeyId === state.journeyId && item.workId === work.id && item.inputRevision === work.inputRevision);
2955
+ const existing = await readBase();
2955
2956
  if (existing?.kind === "base") return existing;
2956
2957
  const inputs = await staticBaseInputs(storage, state, work);
2957
2958
  if (!inputs) throw new ApplicationError("ARTIFACT_EMPTY_SCOPE");
@@ -2961,12 +2962,26 @@ async function packageBase(storage, state, work, processing, directory, signal,
2961
2962
  directory,
2962
2963
  processing
2963
2964
  }, signal);
2964
- const after = await readState();
2965
- const current = after?.works.find((item) => item.id === work.id);
2966
- if (!after || after.snapshotId !== state.snapshotId || after.configurationId !== state.configurationId || current?.revision !== work.revision || current.inputRevision !== work.inputRevision || after.pendingHideId) throw new ApplicationError("REVISION_CONFLICT");
2967
- assertJourneyPrivacyReady(after, true);
2968
- await storage.saveResource(base);
2969
- return base;
2965
+ async function assertCurrent() {
2966
+ signal.throwIfAborted();
2967
+ const after = await readState();
2968
+ signal.throwIfAborted();
2969
+ const current = after?.works.find((item) => item.id === work.id);
2970
+ if (!after || after.snapshotId !== state.snapshotId || after.configurationId !== state.configurationId || current?.revision !== work.revision || current.inputRevision !== work.inputRevision || after.pendingHideId) throw new ApplicationError("REVISION_CONFLICT");
2971
+ if (after.phase === "paused") throw new ApplicationError("OPERATION_CANCELED");
2972
+ assertJourneyPrivacyReady(after, true);
2973
+ }
2974
+ await assertCurrent();
2975
+ try {
2976
+ await storage.saveResource(base);
2977
+ return base;
2978
+ } catch (error) {
2979
+ if (!(error instanceof ApplicationError && error.code === "OPERATION_CONFLICT")) throw error;
2980
+ const winner = await readBase();
2981
+ if (winner?.kind !== "base") throw error;
2982
+ await assertCurrent();
2983
+ return winner;
2984
+ }
2970
2985
  }
2971
2986
  //#endregion
2972
2987
  //#region apps/cli/src/journey/edits.ts
@@ -3751,7 +3766,11 @@ function createJourneyRenderer(options) {
3751
3766
  return {
3752
3767
  ...current,
3753
3768
  works,
3754
- phase: current.phase === "paused" ? "paused" : current.readingComplete && works.every((item) => !isIncludedWork(item) || item.status === "ready") ? "ready" : current.phase
3769
+ phase: [
3770
+ "paused",
3771
+ "sending",
3772
+ "completed"
3773
+ ].includes(current.phase) ? current.phase : current.readingComplete && works.every((item) => !isIncludedWork(item) || item.status === "ready") ? "ready" : current.phase
3755
3774
  };
3756
3775
  });
3757
3776
  }
@@ -6909,7 +6928,7 @@ function retryDelay(error, fallback, now) {
6909
6928
  const delay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(header) - now;
6910
6929
  return Number.isFinite(delay) ? Math.max(fallback, delay) : fallback;
6911
6930
  }
6912
- /** Reconcile first; only failed transfers that consumed bytes charge the durable budget. */
6931
+ /** Reconcile retained intents; only byte-started failures charge the durable budget. */
6913
6932
  async function attemptSession({ dependencies, original, session, key, remote, signal, guard, checkpoint }) {
6914
6933
  const previous = original.sessionUpload?.key === key && original.sessionUpload.sha256 === session.sha256 ? original.sessionUpload : null;
6915
6934
  let failures = previous?.attempt ?? 0;
@@ -6948,8 +6967,31 @@ async function attemptSession({ dependencies, original, session, key, remote, si
6948
6967
  await guard();
6949
6968
  await save();
6950
6969
  let lastReported = 0;
6970
+ const reserveUploadComplete = async () => {
6971
+ await guard();
6972
+ const reservation = await remote.reserve(input, signal);
6973
+ if (reservation.state === "awaiting_upload") {
6974
+ await guard();
6975
+ transfer.attempt = failures + 1;
6976
+ await session.upload(reservation, signal, async (bytes) => {
6977
+ const sent = Math.min(session.byteLength, Math.max(transfer.bytesSent, bytes));
6978
+ transfer.bytesAttempted += sent - transfer.bytesSent;
6979
+ transfer.bytesSent = sent;
6980
+ if (Date.now() - lastReported >= 250 || sent === session.byteLength) {
6981
+ report();
6982
+ lastReported = Date.now();
6983
+ }
6984
+ });
6985
+ await guard();
6986
+ await remote.complete({
6987
+ ...input,
6988
+ metadata: session.metadata
6989
+ }, signal);
6990
+ }
6991
+ };
6951
6992
  try {
6952
- try {
6993
+ if (previous === null) await reserveUploadComplete();
6994
+ else try {
6953
6995
  await remote.complete({
6954
6996
  ...input,
6955
6997
  metadata: session.metadata
@@ -6957,26 +6999,7 @@ async function attemptSession({ dependencies, original, session, key, remote, si
6957
6999
  } catch (error) {
6958
7000
  if (!(error instanceof JourneyRemoteError) || error.status !== 409 || error.code !== "upload_incomplete") throw error;
6959
7001
  if (failures >= 3) throw new ApplicationError("SESSION_UPLOAD_EXHAUSTED");
6960
- await guard();
6961
- const reservation = await remote.reserve(input, signal);
6962
- if (reservation.state === "awaiting_upload") {
6963
- await guard();
6964
- transfer.attempt = failures + 1;
6965
- await session.upload(reservation, signal, async (bytes) => {
6966
- const sent = Math.min(session.byteLength, Math.max(transfer.bytesSent, bytes));
6967
- transfer.bytesAttempted += sent - transfer.bytesSent;
6968
- transfer.bytesSent = sent;
6969
- if (Date.now() - lastReported >= 250 || sent === session.byteLength) {
6970
- report();
6971
- lastReported = Date.now();
6972
- }
6973
- });
6974
- await guard();
6975
- await remote.complete({
6976
- ...input,
6977
- metadata: session.metadata
6978
- }, signal);
6979
- }
7002
+ await reserveUploadComplete();
6980
7003
  }
6981
7004
  transfer.bytesAcknowledged = session.byteLength;
6982
7005
  await guard();
@@ -1,4 +1,4 @@
1
- import { i as createExecutor, t as assertStoreHeap } from "./heap-DFHajqf2.mjs";
1
+ import { i as createExecutor, t as assertStoreHeap } from "./heap-DsE74_-n.mjs";
2
2
  import { parentPort } from "node:worker_threads";
3
3
  //#region packages/local-host/src/store/worker/entry.ts
4
4
  if (!parentPort) throw new Error("STORE_WORKER_REQUIRED");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitroll/tacitt-cli",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "Private local session review and export for coding agents",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {