archctx 0.5.4 → 0.5.5
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/assets/catalog.yaml +1 -1
- package/bin/archctx.mjs +103 -104
- package/package.json +1 -1
package/assets/catalog.yaml
CHANGED
package/bin/archctx.mjs
CHANGED
|
@@ -1213,7 +1213,7 @@ function productVersionManifest() {
|
|
|
1213
1213
|
}
|
|
1214
1214
|
};
|
|
1215
1215
|
}
|
|
1216
|
-
var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.5.
|
|
1216
|
+
var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.5.5", ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.0", ARCHCONTEXT_NODE_RANGE = ">=22.22 <26", LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v1", ARCHCONTEXT_SCHEMA_SET_VERSION = "2026-07-11.explorer-view-v2";
|
|
1217
1217
|
|
|
1218
1218
|
// packages/contracts/src/refactor.ts
|
|
1219
1219
|
function refactorProposalDigest(proposal) {
|
|
@@ -40198,7 +40198,7 @@ async function runCliUnchecked(command2 = "help", args2 = [], cwd, deps = {}) {
|
|
|
40198
40198
|
case "status":
|
|
40199
40199
|
return (await runtime()).runtimeStatus(cwd);
|
|
40200
40200
|
case "projection":
|
|
40201
|
-
return runProjectionProtocolCommand(args2, cwd, await runtime());
|
|
40201
|
+
return await runProjectionProtocolCommand(args2, cwd, await runtime());
|
|
40202
40202
|
case "repo": {
|
|
40203
40203
|
const subcommand = args2[0] ?? "list";
|
|
40204
40204
|
if (subcommand === "add") {
|
|
@@ -40225,7 +40225,7 @@ async function runCliUnchecked(command2 = "help", args2 = [], cwd, deps = {}) {
|
|
|
40225
40225
|
case "ledger":
|
|
40226
40226
|
return runLedgerCommand(args2, cwd, runtime);
|
|
40227
40227
|
case "book":
|
|
40228
|
-
return runBookCommand(args2, cwd, await runtime());
|
|
40228
|
+
return await runBookCommand(args2, cwd, await runtime());
|
|
40229
40229
|
case "recommendations":
|
|
40230
40230
|
return runRecommendationsCommand(args2, cwd, await runtime());
|
|
40231
40231
|
case "refactor":
|
|
@@ -41133,7 +41133,7 @@ function architectureProjectionProfile(args2) {
|
|
|
41133
41133
|
}
|
|
41134
41134
|
return profile;
|
|
41135
41135
|
}
|
|
41136
|
-
async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projection3, profile, generatedAt, acceptedChange) {
|
|
41136
|
+
async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projection3, profile, generatedAt, acceptedChange, protocolRequest) {
|
|
41137
41137
|
if (profile !== REPO_HARNESS_PROJECTION_PROFILE) {
|
|
41138
41138
|
return errorEnvelope("docs.adopt", "AC_SCHEMA_INVALID", `docs adopt requires --profile ${REPO_HARNESS_PROJECTION_PROFILE}`);
|
|
41139
41139
|
}
|
|
@@ -41172,15 +41172,20 @@ async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projectio
|
|
|
41172
41172
|
return errorEnvelope("docs.adopt", "AC_PRECONDITION_FAILED", "projection-adoption-preview-mismatch");
|
|
41173
41173
|
}
|
|
41174
41174
|
const simulatedByPath = new Map(projection3.loaded.existingFiles.map((file) => [file.path, file]));
|
|
41175
|
-
for (const file of [...projection3.
|
|
41175
|
+
for (const file of [...projection3.files, ...adoption2.files])
|
|
41176
41176
|
simulatedByPath.set(file.path, file);
|
|
41177
|
-
const canonicalFirst = buildArchitectureDocsProjection(root, generatedAt, profile, [...simulatedByPath.values()]
|
|
41177
|
+
const canonicalFirst = buildArchitectureDocsProjection(root, generatedAt, profile, [...simulatedByPath.values()]);
|
|
41178
41178
|
const canonicalExistingByPath = new Map(simulatedByPath);
|
|
41179
41179
|
for (const file of canonicalFirst.files)
|
|
41180
41180
|
canonicalExistingByPath.set(file.path, file);
|
|
41181
|
-
const canonical = buildArchitectureDocsProjection(root, generatedAt, profile, [...canonicalExistingByPath.values()]
|
|
41181
|
+
const canonical = buildArchitectureDocsProjection(root, generatedAt, profile, [...canonicalExistingByPath.values()]);
|
|
41182
41182
|
if (!canonical.plan.drift.ok || canonical.plan.rejected.length > 0 || canonical.plan.projectionDigest !== canonicalFirst.plan.projectionDigest) {
|
|
41183
|
-
|
|
41183
|
+
const reasons = canonical.plan.rejected.map((entry) => entry.reasonCode).join(",") || "none";
|
|
41184
|
+
const drift = canonical.plan.drift.diffs.map((entry) => `${entry.path}:${entry.reasonCode}`).join(",") || "none";
|
|
41185
|
+
return errorEnvelope("docs.adopt", "AC_PRECONDITION_FAILED", `projection-adoption-fixed-point-unproven: drift=${drift}; rejected=${reasons}; digest=${canonical.plan.projectionDigest === canonicalFirst.plan.projectionDigest ? "stable" : "changed"}`);
|
|
41186
|
+
}
|
|
41187
|
+
if (protocolRequest) {
|
|
41188
|
+
return applyProjectionProtocolFixedPoint(protocolRequest, projection3, canonical, adoption2.changeSetId, root, daemon);
|
|
41184
41189
|
}
|
|
41185
41190
|
const filesByPath = new Map;
|
|
41186
41191
|
for (const file of canonical.files)
|
|
@@ -41204,6 +41209,93 @@ async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projectio
|
|
|
41204
41209
|
apply: applied.data
|
|
41205
41210
|
});
|
|
41206
41211
|
}
|
|
41212
|
+
async function applyProjectionProtocolFixedPoint(request, input, fixedPoint, changeSetId, root, daemon) {
|
|
41213
|
+
const committedFiles = projectionProtocolFilesForExpectedOutput(root, fixedPoint);
|
|
41214
|
+
const committedSignals = request.acceptedChange ? input.plan.refreshSignals.map((signal) => ({
|
|
41215
|
+
...signal,
|
|
41216
|
+
resultingDigests: fixedPoint.plan.architectureDigests
|
|
41217
|
+
})) : fixedPoint.plan.refreshSignals;
|
|
41218
|
+
const applyIdentity = request.acceptedChange ? createProjectionApplyIdentity({
|
|
41219
|
+
repositoryId: request.expected.repositoryId,
|
|
41220
|
+
workspaceId: request.expected.workspaceId,
|
|
41221
|
+
acceptedChange: request.acceptedChange,
|
|
41222
|
+
changeSetId,
|
|
41223
|
+
idempotencyKey: `idem_${changeSetId}`,
|
|
41224
|
+
files: committedFiles,
|
|
41225
|
+
refreshSignals: committedSignals
|
|
41226
|
+
}) : undefined;
|
|
41227
|
+
const appliedResult = projectionProtocolResult(request, input, "applied", fixedPoint, applyIdentity, {
|
|
41228
|
+
files: committedFiles,
|
|
41229
|
+
refreshSignals: committedSignals
|
|
41230
|
+
});
|
|
41231
|
+
let recoveryBinding;
|
|
41232
|
+
if (applyIdentity) {
|
|
41233
|
+
try {
|
|
41234
|
+
recoveryBinding = createProjectionApplyRecoveryBinding(request, fixedPoint, appliedResult);
|
|
41235
|
+
} catch (error) {
|
|
41236
|
+
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
|
|
41237
|
+
}
|
|
41238
|
+
}
|
|
41239
|
+
const applyReceipt = applyIdentity ? {
|
|
41240
|
+
schemaVersion: "archcontext.projection-apply-receipt/v1",
|
|
41241
|
+
identity: applyIdentity,
|
|
41242
|
+
result: appliedResult,
|
|
41243
|
+
recovery: recoveryBinding
|
|
41244
|
+
} : undefined;
|
|
41245
|
+
const planned = await daemon.planUpdate(root, {
|
|
41246
|
+
id: changeSetId,
|
|
41247
|
+
reason: { taskSessionId: request.requestId },
|
|
41248
|
+
operations: [architectureDocsRenderProjectionOperation(root, fixedPoint.files)],
|
|
41249
|
+
worktreeDigestPrecondition: {
|
|
41250
|
+
profile: "architecture-documentation-projection",
|
|
41251
|
+
expectedDigest: request.expected.worktreeDigest
|
|
41252
|
+
}
|
|
41253
|
+
});
|
|
41254
|
+
if (!planned.ok)
|
|
41255
|
+
return planned;
|
|
41256
|
+
const applied = await daemon.applyUpdate(root, {
|
|
41257
|
+
id: changeSetId,
|
|
41258
|
+
approved: true,
|
|
41259
|
+
expectedWorktreeDigest: request.expected.worktreeDigest,
|
|
41260
|
+
worktreeDigestProfile: "architecture-documentation-projection",
|
|
41261
|
+
...applyReceipt ? { projectionApplyReceipt: applyReceipt } : {}
|
|
41262
|
+
});
|
|
41263
|
+
if (!applied.ok)
|
|
41264
|
+
return applied;
|
|
41265
|
+
if (!applyReceipt)
|
|
41266
|
+
return projectionProtocolResultEnvelope(appliedResult);
|
|
41267
|
+
let postApplyMatches = false;
|
|
41268
|
+
try {
|
|
41269
|
+
postApplyMatches = architectureDocumentationProjectionWorktreeDigest(root, loadNativeModelFromArchContext(root)) === request.expected.worktreeDigest;
|
|
41270
|
+
if (!postApplyMatches) {
|
|
41271
|
+
process.stderr.write(`warning: projection post-apply worktree digest diverged from the accepted snapshot; refresh delivery deferred to reconcile
|
|
41272
|
+
`);
|
|
41273
|
+
}
|
|
41274
|
+
} catch (error) {
|
|
41275
|
+
process.stderr.write(`warning: projection post-apply verification failed: ${error instanceof Error ? error.message : String(error)}
|
|
41276
|
+
`);
|
|
41277
|
+
postApplyMatches = false;
|
|
41278
|
+
}
|
|
41279
|
+
if (!postApplyMatches) {
|
|
41280
|
+
return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied-reconcile-required", []));
|
|
41281
|
+
}
|
|
41282
|
+
const delivery = await daemon.recoverProjectionApply(root, {
|
|
41283
|
+
schemaVersion: PROJECTION_APPLY_RECOVERY_INTENT_SCHEMA_VERSION,
|
|
41284
|
+
requestId: request.requestId,
|
|
41285
|
+
profile: REPO_HARNESS_PROJECTION_PROFILE,
|
|
41286
|
+
receipt: {
|
|
41287
|
+
lookupKey: applyReceipt.identity.lookupKey,
|
|
41288
|
+
applyId: applyReceipt.identity.applyId
|
|
41289
|
+
}
|
|
41290
|
+
});
|
|
41291
|
+
if (!delivery.ok)
|
|
41292
|
+
return delivery;
|
|
41293
|
+
const delivered = delivery.data;
|
|
41294
|
+
if (delivered.found !== true || delivered.refreshSignalsDelivered !== true) {
|
|
41295
|
+
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", "committed projection apply receipt was not available for first delivery");
|
|
41296
|
+
}
|
|
41297
|
+
return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied", delivered.receipt.result.refreshSignals, request.requestId));
|
|
41298
|
+
}
|
|
41207
41299
|
async function runProjectionProtocolCommand(args2, cwd, daemon) {
|
|
41208
41300
|
const subcommand = args2[0] ?? "run";
|
|
41209
41301
|
if (subcommand === "recover")
|
|
@@ -41261,19 +41353,10 @@ async function runProjectionProtocolCommand(args2, cwd, daemon) {
|
|
|
41261
41353
|
expectedWorktreeDigest,
|
|
41262
41354
|
"--task-session-id",
|
|
41263
41355
|
request.requestId
|
|
41264
|
-
], root, daemon, projection3, REPO_HARNESS_PROJECTION_PROFILE, generatedAt, request.acceptedChange);
|
|
41356
|
+
], root, daemon, projection3, REPO_HARNESS_PROJECTION_PROFILE, generatedAt, request.acceptedChange, request);
|
|
41265
41357
|
if (!adopted.ok)
|
|
41266
41358
|
return adopted;
|
|
41267
|
-
|
|
41268
|
-
try {
|
|
41269
|
-
output = buildArchitectureDocsProjection(root, generatedAt, REPO_HARNESS_PROJECTION_PROFILE, undefined, request.acceptedChange);
|
|
41270
|
-
if (!output.plan.drift.ok || output.plan.rejected.length > 0) {
|
|
41271
|
-
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", "projection adoption did not reach the architecture-docs fixed point");
|
|
41272
|
-
}
|
|
41273
|
-
} catch (error) {
|
|
41274
|
-
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
|
|
41275
|
-
}
|
|
41276
|
-
return projectionProtocolEnvelope(request, projection3, "applied", output);
|
|
41359
|
+
return adopted;
|
|
41277
41360
|
}
|
|
41278
41361
|
if (request.mode === "apply" && !projection3.plan.drift.ok) {
|
|
41279
41362
|
const changeSetId = `changeset.docs-projection-${projection3.plan.projectionDigest.replace(/^sha256:/, "").slice(0, 16)}`;
|
|
@@ -41286,91 +41369,7 @@ async function runProjectionProtocolCommand(args2, cwd, daemon) {
|
|
|
41286
41369
|
} catch (error) {
|
|
41287
41370
|
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
|
|
41288
41371
|
}
|
|
41289
|
-
|
|
41290
|
-
const committedSignals = request.acceptedChange ? projection3.plan.refreshSignals.map((signal) => ({
|
|
41291
|
-
...signal,
|
|
41292
|
-
resultingDigests: fixedPointProjection.plan.architectureDigests
|
|
41293
|
-
})) : fixedPointProjection.plan.refreshSignals;
|
|
41294
|
-
const applyIdentity = request.acceptedChange ? createProjectionApplyIdentity({
|
|
41295
|
-
repositoryId: request.expected.repositoryId,
|
|
41296
|
-
workspaceId: request.expected.workspaceId,
|
|
41297
|
-
acceptedChange: request.acceptedChange,
|
|
41298
|
-
changeSetId,
|
|
41299
|
-
idempotencyKey: `idem_${changeSetId}`,
|
|
41300
|
-
files: committedFiles,
|
|
41301
|
-
refreshSignals: committedSignals
|
|
41302
|
-
}) : undefined;
|
|
41303
|
-
const appliedResult = projectionProtocolResult(request, projection3, "applied", fixedPointProjection, applyIdentity, {
|
|
41304
|
-
files: committedFiles,
|
|
41305
|
-
refreshSignals: committedSignals
|
|
41306
|
-
});
|
|
41307
|
-
let recoveryBinding;
|
|
41308
|
-
if (applyIdentity) {
|
|
41309
|
-
try {
|
|
41310
|
-
recoveryBinding = createProjectionApplyRecoveryBinding(request, fixedPointProjection, appliedResult);
|
|
41311
|
-
} catch (error) {
|
|
41312
|
-
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
|
|
41313
|
-
}
|
|
41314
|
-
}
|
|
41315
|
-
const applyReceipt = applyIdentity ? {
|
|
41316
|
-
schemaVersion: "archcontext.projection-apply-receipt/v1",
|
|
41317
|
-
identity: applyIdentity,
|
|
41318
|
-
result: appliedResult,
|
|
41319
|
-
recovery: recoveryBinding
|
|
41320
|
-
} : undefined;
|
|
41321
|
-
const planned = await daemon.planUpdate(root, {
|
|
41322
|
-
id: changeSetId,
|
|
41323
|
-
reason: { taskSessionId: request.requestId },
|
|
41324
|
-
operations: [architectureDocsRenderProjectionOperation(root, fixedPointProjection.files)],
|
|
41325
|
-
worktreeDigestPrecondition: {
|
|
41326
|
-
profile: "architecture-documentation-projection",
|
|
41327
|
-
expectedDigest: request.expected.worktreeDigest
|
|
41328
|
-
}
|
|
41329
|
-
});
|
|
41330
|
-
if (!planned.ok)
|
|
41331
|
-
return planned;
|
|
41332
|
-
const applied = await daemon.applyUpdate(root, {
|
|
41333
|
-
id: changeSetId,
|
|
41334
|
-
approved: true,
|
|
41335
|
-
expectedWorktreeDigest: request.expected.worktreeDigest,
|
|
41336
|
-
worktreeDigestProfile: "architecture-documentation-projection",
|
|
41337
|
-
...applyReceipt ? { projectionApplyReceipt: applyReceipt } : {}
|
|
41338
|
-
});
|
|
41339
|
-
if (!applied.ok)
|
|
41340
|
-
return applied;
|
|
41341
|
-
if (!applyReceipt)
|
|
41342
|
-
return projectionProtocolResultEnvelope(appliedResult);
|
|
41343
|
-
let postApplyMatches = false;
|
|
41344
|
-
try {
|
|
41345
|
-
postApplyMatches = architectureDocumentationProjectionWorktreeDigest(root, loadNativeModelFromArchContext(root)) === request.expected.worktreeDigest;
|
|
41346
|
-
if (!postApplyMatches) {
|
|
41347
|
-
process.stderr.write(`warning: projection post-apply worktree digest diverged from the accepted snapshot; refresh delivery deferred to reconcile
|
|
41348
|
-
`);
|
|
41349
|
-
}
|
|
41350
|
-
} catch (error) {
|
|
41351
|
-
process.stderr.write(`warning: projection post-apply verification failed: ${error instanceof Error ? error.message : String(error)}
|
|
41352
|
-
`);
|
|
41353
|
-
postApplyMatches = false;
|
|
41354
|
-
}
|
|
41355
|
-
if (!postApplyMatches) {
|
|
41356
|
-
return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied-reconcile-required", []));
|
|
41357
|
-
}
|
|
41358
|
-
const delivery = await daemon.recoverProjectionApply(root, {
|
|
41359
|
-
schemaVersion: PROJECTION_APPLY_RECOVERY_INTENT_SCHEMA_VERSION,
|
|
41360
|
-
requestId: request.requestId,
|
|
41361
|
-
profile: REPO_HARNESS_PROJECTION_PROFILE,
|
|
41362
|
-
receipt: {
|
|
41363
|
-
lookupKey: applyReceipt.identity.lookupKey,
|
|
41364
|
-
applyId: applyReceipt.identity.applyId
|
|
41365
|
-
}
|
|
41366
|
-
});
|
|
41367
|
-
if (!delivery.ok)
|
|
41368
|
-
return delivery;
|
|
41369
|
-
const delivered = delivery.data;
|
|
41370
|
-
if (delivered.found !== true || delivered.refreshSignalsDelivered !== true) {
|
|
41371
|
-
return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", "committed projection apply receipt was not available for first delivery");
|
|
41372
|
-
}
|
|
41373
|
-
return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied", delivered.receipt.result.refreshSignals, request.requestId));
|
|
41372
|
+
return applyProjectionProtocolFixedPoint(request, projection3, fixedPointProjection, changeSetId, root, daemon);
|
|
41374
41373
|
}
|
|
41375
41374
|
const status = projection3.plan.drift.ok ? "noop" : "planned";
|
|
41376
41375
|
return projectionProtocolEnvelope(request, projection3, status);
|