@akagilnc/pi-workflow-roles 0.1.6111 → 0.1.6115
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/acp-host/production-host.js +88 -29
- package/dist/headless-host/production-host.js +88 -29
- package/dist/migrate-book-topology.js +3 -0
- package/dist/package-contracts/fixer-output.js +3 -0
- package/dist/public-cli/instruction-seat-run.js +50 -8
- package/dist/public-cli/invocation.js +22 -12
- package/dist/public-cli/main.js +88 -29
- package/dist/ticket-progress.js +59 -14
- package/package.json +1 -1
- package/src/package-contracts/fixer-output.ts +4 -0
- package/src/public-cli/instruction-seat-run.ts +53 -6
- package/src/public-cli/invocation.ts +31 -16
- package/src/ticket-progress.ts +71 -15
package/dist/public-cli/main.js
CHANGED
|
@@ -9604,6 +9604,9 @@ var init_fixer_output = __esm({
|
|
|
9604
9604
|
classResults: typebox_exports.Unknown({
|
|
9605
9605
|
description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
|
|
9606
9606
|
}),
|
|
9607
|
+
for: typebox_exports.Unknown({
|
|
9608
|
+
description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
|
|
9609
|
+
}),
|
|
9607
9610
|
diffItems: diffItemsField,
|
|
9608
9611
|
testEvidence: typebox_exports.Unknown({
|
|
9609
9612
|
description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
|
|
@@ -13230,15 +13233,11 @@ import {
|
|
|
13230
13233
|
writeFileSync as writeFileSync2
|
|
13231
13234
|
} from "node:fs";
|
|
13232
13235
|
import { basename as basename7, dirname as dirname8, join as join12, relative as relative2, sep as sep3 } from "node:path";
|
|
13233
|
-
function
|
|
13234
|
-
if (
|
|
13236
|
+
function decodeProgressFile(path) {
|
|
13237
|
+
if (!existsSync3(path)) return { lines: [], malformed: [] };
|
|
13238
|
+
const text = readFileSync3(path, "utf8");
|
|
13239
|
+
if (text.trim() === "") return { lines: [], malformed: [] };
|
|
13235
13240
|
const { records, diagnostics } = parseSitianRecordText(text);
|
|
13236
|
-
for (const diagnostic of diagnostics) {
|
|
13237
|
-
process.stderr.write(
|
|
13238
|
-
`[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
|
|
13239
|
-
`
|
|
13240
|
-
);
|
|
13241
|
-
}
|
|
13242
13241
|
const lines = [];
|
|
13243
13242
|
for (const record of records) {
|
|
13244
13243
|
const parsed = record;
|
|
@@ -13246,11 +13245,20 @@ function parseProgressText(text, pathForDiagnostic) {
|
|
|
13246
13245
|
if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
|
|
13247
13246
|
lines.push(parsed);
|
|
13248
13247
|
}
|
|
13249
|
-
return
|
|
13248
|
+
return {
|
|
13249
|
+
lines,
|
|
13250
|
+
malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
|
|
13251
|
+
};
|
|
13250
13252
|
}
|
|
13251
13253
|
function readProgressFile(path) {
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
13255
|
+
for (const diagnostic of malformed) {
|
|
13256
|
+
process.stderr.write(
|
|
13257
|
+
`[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
|
|
13258
|
+
`
|
|
13259
|
+
);
|
|
13260
|
+
}
|
|
13261
|
+
return lines;
|
|
13254
13262
|
}
|
|
13255
13263
|
function readTicketProgressLines(subjectDirectory) {
|
|
13256
13264
|
if (basename7(subjectDirectory) === "unbound") {
|
|
@@ -13306,6 +13314,26 @@ function statusAndSummaryFromPayload(payload) {
|
|
|
13306
13314
|
...summary === void 0 ? {} : { summary }
|
|
13307
13315
|
};
|
|
13308
13316
|
}
|
|
13317
|
+
function readAuditedRound(auditedRunDirectory) {
|
|
13318
|
+
try {
|
|
13319
|
+
const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
|
|
13320
|
+
if (subjectDirectory === void 0) return {};
|
|
13321
|
+
const path = join12(subjectDirectory, CURRENT_FILENAME);
|
|
13322
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
13323
|
+
if (malformed.length > 0) {
|
|
13324
|
+
throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
|
|
13325
|
+
}
|
|
13326
|
+
const receipts = `runs/${basename7(auditedRunDirectory)}/`;
|
|
13327
|
+
const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
|
|
13328
|
+
return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
|
|
13329
|
+
} catch (error) {
|
|
13330
|
+
return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
|
|
13331
|
+
}
|
|
13332
|
+
}
|
|
13333
|
+
function forOfSealedRow(runDirectory, seat, payload) {
|
|
13334
|
+
const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
|
|
13335
|
+
return typeof reported === "string" ? reported : void 0;
|
|
13336
|
+
}
|
|
13309
13337
|
function captureWorktreeHead(projectRoot) {
|
|
13310
13338
|
try {
|
|
13311
13339
|
const result = spawnSync3("git", ["rev-parse", "HEAD"], {
|
|
@@ -13359,11 +13387,13 @@ function landTicketProgress(input) {
|
|
|
13359
13387
|
const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
|
|
13360
13388
|
const sessionRelative = input.sessionFile === void 0 ? "" : relative2(subjectDirectory, input.sessionFile).split(sep3).join("/");
|
|
13361
13389
|
const { status, summary } = statusAndSummaryFromPayload(input.accepted);
|
|
13390
|
+
const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
|
|
13362
13391
|
const instruction = input.instruction;
|
|
13363
13392
|
const line2 = {
|
|
13364
13393
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13365
13394
|
seat: input.role,
|
|
13366
13395
|
round,
|
|
13396
|
+
...reviewed === void 0 ? {} : { for: reviewed },
|
|
13367
13397
|
instruction,
|
|
13368
13398
|
head: input.sealHead.head,
|
|
13369
13399
|
...status === void 0 ? {} : { status },
|
|
@@ -15327,22 +15357,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
|
15327
15357
|
...fields
|
|
15328
15358
|
}));
|
|
15329
15359
|
}
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15360
|
+
function persistAdmittedAuditedLeg(runDirectory, audited) {
|
|
15361
|
+
const { sourceRunPath, auditorSubject } = audited;
|
|
15362
|
+
if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
|
|
15363
|
+
throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
|
|
15333
15364
|
}
|
|
15334
|
-
updateSectionSync(
|
|
15335
|
-
if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
15365
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
15366
|
+
if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
15336
15367
|
throw new Error(
|
|
15337
|
-
`
|
|
15368
|
+
`persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
15338
15369
|
);
|
|
15339
15370
|
}
|
|
15340
|
-
const
|
|
15341
|
-
if (
|
|
15371
|
+
const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
|
|
15372
|
+
if (unchanged) return void 0;
|
|
15373
|
+
const { for: _replaced, ...rest } = current;
|
|
15342
15374
|
return {
|
|
15343
|
-
...
|
|
15344
|
-
sourceRunPath,
|
|
15345
|
-
...auditorSubject === void 0 ? {} : { auditorSubject }
|
|
15375
|
+
...rest,
|
|
15376
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
15377
|
+
...auditorSubject === void 0 ? {} : { auditorSubject },
|
|
15378
|
+
...audited.for === void 0 ? {} : { for: audited.for }
|
|
15346
15379
|
};
|
|
15347
15380
|
});
|
|
15348
15381
|
}
|
|
@@ -20396,6 +20429,16 @@ async function runOmittedLensBatch(argv2, parsed, env, io) {
|
|
|
20396
20429
|
else io.stdout(formatTerminalResult(terminal));
|
|
20397
20430
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
20398
20431
|
}
|
|
20432
|
+
async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
|
|
20433
|
+
const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
|
|
20434
|
+
persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
|
|
20435
|
+
if (fault === void 0) return;
|
|
20436
|
+
await retainPackageFault({
|
|
20437
|
+
runDirectory: officerRunDirectory,
|
|
20438
|
+
diagnostic: fault,
|
|
20439
|
+
stderr: (text) => io.stderr(text)
|
|
20440
|
+
});
|
|
20441
|
+
}
|
|
20399
20442
|
function resumeSameParentInstructionSeat(input) {
|
|
20400
20443
|
return tryResumeSameTicketSeatRun({
|
|
20401
20444
|
home: input.env.home,
|
|
@@ -20415,7 +20458,8 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
20415
20458
|
...materials === void 0 ? {} : { summons: materials }
|
|
20416
20459
|
},
|
|
20417
20460
|
input.env,
|
|
20418
|
-
input.io
|
|
20461
|
+
input.io,
|
|
20462
|
+
input.parentRunPath
|
|
20419
20463
|
);
|
|
20420
20464
|
}
|
|
20421
20465
|
});
|
|
@@ -20491,7 +20535,9 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
20491
20535
|
);
|
|
20492
20536
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
20493
20537
|
if (gateParentRunPath !== void 0) {
|
|
20494
|
-
await
|
|
20538
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
|
|
20539
|
+
sourceRunPath: gateParentRunPath
|
|
20540
|
+
});
|
|
20495
20541
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
20496
20542
|
}
|
|
20497
20543
|
const turnProjection = roleTurnOptions(env, admitted, {
|
|
@@ -20700,12 +20746,21 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
20700
20746
|
throw error;
|
|
20701
20747
|
}
|
|
20702
20748
|
if (instructionSourceRunPath !== void 0) {
|
|
20703
|
-
await
|
|
20749
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
|
|
20750
|
+
sourceRunPath: instructionSourceRunPath
|
|
20751
|
+
});
|
|
20704
20752
|
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
|
|
20705
|
-
}
|
|
20706
|
-
|
|
20707
|
-
|
|
20753
|
+
} else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
20754
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
|
|
20755
|
+
sourceRunPath: auditorSource,
|
|
20756
|
+
auditorSubject
|
|
20757
|
+
});
|
|
20708
20758
|
admitted = { ...admitted, sourceRunPath: auditorSource };
|
|
20759
|
+
} else {
|
|
20760
|
+
const auditedRunDirectory = admittedSourceRunPath(admitted);
|
|
20761
|
+
if (auditedRunDirectory !== void 0) {
|
|
20762
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
|
|
20763
|
+
}
|
|
20709
20764
|
}
|
|
20710
20765
|
admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
|
|
20711
20766
|
const runAdmitted = async () => {
|
|
@@ -20780,7 +20835,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
|
|
|
20780
20835
|
await relocateAdmittedRunToTicket(admitted, authority);
|
|
20781
20836
|
return admitted;
|
|
20782
20837
|
}
|
|
20783
|
-
async function runPublicInstructionSeatResume(request, env, io) {
|
|
20838
|
+
async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
|
|
20784
20839
|
let selectedRequest = request;
|
|
20785
20840
|
const resume = async () => {
|
|
20786
20841
|
const held = [];
|
|
@@ -20811,6 +20866,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
20811
20866
|
return { ...loaded, admitted };
|
|
20812
20867
|
},
|
|
20813
20868
|
buildTurnRequest: async (admitted, effective) => {
|
|
20869
|
+
if (resummonedFor !== void 0) {
|
|
20870
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
|
|
20871
|
+
}
|
|
20814
20872
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
20815
20873
|
const projection = resumeTurnRequestProjectionOptions(
|
|
20816
20874
|
admitted,
|
|
@@ -21329,6 +21387,7 @@ var init_instruction_seat_run = __esm({
|
|
|
21329
21387
|
init_terminal();
|
|
21330
21388
|
init_turn_request();
|
|
21331
21389
|
init_countersign_run();
|
|
21390
|
+
init_ticket_progress();
|
|
21332
21391
|
init_unknown_value();
|
|
21333
21392
|
AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
|
|
21334
21393
|
SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
package/dist/ticket-progress.js
CHANGED
|
@@ -16,26 +16,25 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSyn
|
|
|
16
16
|
import { basename, dirname, join, relative, sep } from "node:path";
|
|
17
17
|
import { resolveHostDossierLandingPath } from "./host-session-record.js";
|
|
18
18
|
import { runDirectoryFromHostContext } from "./host-contracts.js";
|
|
19
|
-
import { receiptStatus } from "./packaged-role-registry.js";
|
|
19
|
+
import { packagedGateStageLabel, receiptStatus } from "./packaged-role-registry.js";
|
|
20
20
|
import { isUnboundRunDirectory, sessionDirectoryOf, sessionFileOf, subjectDirectoryOfRun, } from "./role-run-placement.js";
|
|
21
21
|
import { readPageSync } from "./run-dossier.js";
|
|
22
22
|
import { parseSitianRecordText } from "./sitian-reader.js";
|
|
23
|
-
import { isRecord } from "./unknown-value.js";
|
|
23
|
+
import { errorText, isRecord } from "./unknown-value.js";
|
|
24
24
|
const CURRENT_FILENAME = "current.jsonl";
|
|
25
25
|
const RECEIPTS_DIRNAME = "receipts";
|
|
26
26
|
const LEG_PROGRESS_FILENAME = "progress.jsonl";
|
|
27
27
|
/**
|
|
28
|
-
* Append-only progress JSONL
|
|
29
|
-
*
|
|
30
|
-
* on stderr and do not abort seal/relocate.
|
|
28
|
+
* Append-only progress JSONL through the sole Sitian decoder: reachable rows
|
|
29
|
+
* plus one diagnostic per malformed line.
|
|
31
30
|
*/
|
|
32
|
-
function
|
|
31
|
+
function decodeProgressFile(path) {
|
|
32
|
+
if (!existsSync(path))
|
|
33
|
+
return { lines: [], malformed: [] };
|
|
34
|
+
const text = readFileSync(path, "utf8");
|
|
33
35
|
if (text.trim() === "")
|
|
34
|
-
return [];
|
|
36
|
+
return { lines: [], malformed: [] };
|
|
35
37
|
const { records, diagnostics } = parseSitianRecordText(text);
|
|
36
|
-
for (const diagnostic of diagnostics) {
|
|
37
|
-
process.stderr.write(`[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}\n`);
|
|
38
|
-
}
|
|
39
38
|
const lines = [];
|
|
40
39
|
for (const record of records) {
|
|
41
40
|
const parsed = record;
|
|
@@ -45,12 +44,21 @@ function parseProgressText(text, pathForDiagnostic) {
|
|
|
45
44
|
continue;
|
|
46
45
|
lines.push(parsed);
|
|
47
46
|
}
|
|
48
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
lines,
|
|
49
|
+
malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`),
|
|
50
|
+
};
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Same posture as run-dossier row files: malformed lines leave diagnostics on
|
|
54
|
+
* stderr and do not abort seal/relocate.
|
|
55
|
+
*/
|
|
50
56
|
function readProgressFile(path) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
58
|
+
for (const diagnostic of malformed) {
|
|
59
|
+
process.stderr.write(`[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}\n`);
|
|
60
|
+
}
|
|
61
|
+
return lines;
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
64
|
* Read progress rows under a subject.
|
|
@@ -125,6 +133,41 @@ function statusAndSummaryFromPayload(payload) {
|
|
|
125
133
|
...(summary === undefined ? {} : { summary }),
|
|
126
134
|
};
|
|
127
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* #1200「审 谁#轮」as the ticket has it now: the audited leg's latest row. Read
|
|
138
|
+
* at the officer's admission, before the officer runs. An audited leg with no
|
|
139
|
+
* round yet (unbound, or no accepted receipt) has none. A progress file that
|
|
140
|
+
* cannot be read or has malformed rows has none either and returns the cause
|
|
141
|
+
* for the caller to retain — the officer still runs.
|
|
142
|
+
*/
|
|
143
|
+
export function readAuditedRound(auditedRunDirectory) {
|
|
144
|
+
try {
|
|
145
|
+
const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
|
|
146
|
+
if (subjectDirectory === undefined)
|
|
147
|
+
return {};
|
|
148
|
+
const path = join(subjectDirectory, CURRENT_FILENAME);
|
|
149
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
150
|
+
if (malformed.length > 0) {
|
|
151
|
+
throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
|
|
152
|
+
}
|
|
153
|
+
const receipts = `runs/${basename(auditedRunDirectory)}/`;
|
|
154
|
+
const latest = lines.filter((line) => line.receipt.startsWith(receipts)).at(-1);
|
|
155
|
+
return latest === undefined ? {} : { for: `${latest.seat}#${latest.round}` };
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The row's `for`: gate officers copy the admission pin; the fixer's receipt
|
|
163
|
+
* reports its own (copied when it is a string, never checked). No other seat has one.
|
|
164
|
+
*/
|
|
165
|
+
function forOfSealedRow(runDirectory, seat, payload) {
|
|
166
|
+
const reported = packagedGateStageLabel(seat) !== undefined
|
|
167
|
+
? readPageSync(runDirectory, "admitted")?.for
|
|
168
|
+
: seat === "fixer" && isRecord(payload) ? payload.for : undefined;
|
|
169
|
+
return typeof reported === "string" ? reported : undefined;
|
|
170
|
+
}
|
|
128
171
|
/** Worktree HEAD at seal. On failure head is empty and fault carries the true cause. */
|
|
129
172
|
export function captureWorktreeHead(projectRoot) {
|
|
130
173
|
try {
|
|
@@ -239,11 +282,13 @@ export function landTicketProgress(input) {
|
|
|
239
282
|
? ""
|
|
240
283
|
: relative(subjectDirectory, input.sessionFile).split(sep).join("/");
|
|
241
284
|
const { status, summary } = statusAndSummaryFromPayload(input.accepted);
|
|
285
|
+
const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
|
|
242
286
|
const instruction = input.instruction;
|
|
243
287
|
const line = {
|
|
244
288
|
at: new Date().toISOString(),
|
|
245
289
|
seat: input.role,
|
|
246
290
|
round,
|
|
291
|
+
...(reviewed === undefined ? {} : { for: reviewed }),
|
|
247
292
|
instruction,
|
|
248
293
|
head: input.sealHead.head,
|
|
249
294
|
...(status === undefined ? {} : { status }),
|
package/package.json
CHANGED
|
@@ -31,6 +31,9 @@ const fixerOutputObject = Type.Object({
|
|
|
31
31
|
description:
|
|
32
32
|
"各类 class 结算,原样留存。每类写 name、shape(错误形状一句)。按代码形状认的类写 search(实际跑的搜索命令,原样)、hits(命令输出的每个命中一行 { where: path:line, outcome: 已修 | 不同类:理由 });按情形认的类写 cases(每种前序经历一行 { case: 对象先经历了什么, entry: 从真实入口怎么走到它, before: 修前结果, after: 修后结果 })。删并类写 files(本票起点到 HEAD 的 git diff --name-status 里每个文件一行 { file, hits: 该类在此文件的命中 path:line 列表,没有为空, outcome: 已修 | 无:比对了哪几处、为什么不算 | 未修:理由 })。完成项的 disposition 为 completed,可写 commitSha。拒绝项的 disposition 为 refused,可写 remainingScope、blocker。",
|
|
33
33
|
}),
|
|
34
|
+
for: Type.Unknown({
|
|
35
|
+
description: "修的是哪份判词:<席>#<轮>,如 judge#5,原样落到进度行;没有就填 null。",
|
|
36
|
+
}),
|
|
34
37
|
diffItems: diffItemsField,
|
|
35
38
|
testEvidence: Type.Unknown({
|
|
36
39
|
description:
|
|
@@ -58,6 +61,7 @@ export type FixerOutput = {
|
|
|
58
61
|
readonly blocker?: unknown;
|
|
59
62
|
readonly reason?: unknown;
|
|
60
63
|
readonly classResults?: unknown;
|
|
64
|
+
readonly for?: unknown;
|
|
61
65
|
readonly testEvidence?: unknown;
|
|
62
66
|
readonly diffItems?: unknown;
|
|
63
67
|
};
|
|
@@ -46,8 +46,8 @@ import {
|
|
|
46
46
|
appendCallerFileFlagPaths,
|
|
47
47
|
buildInstructionTransportPrompt,
|
|
48
48
|
materializeCountersignInvocation,
|
|
49
|
+
persistAdmittedAuditedLeg,
|
|
49
50
|
persistAdmittedAuditedSubmissionToolCallId,
|
|
50
|
-
persistAdmittedSourceRunPath,
|
|
51
51
|
readAdmittedAuditedSubmissionToolCallId,
|
|
52
52
|
recordAdmittedCorrelation,
|
|
53
53
|
recordChildDiaristRun,
|
|
@@ -85,6 +85,7 @@ import {
|
|
|
85
85
|
ledgerReadScope,
|
|
86
86
|
presentStructuralRejection,
|
|
87
87
|
readBoundSessionEntries,
|
|
88
|
+
retainPackageFault,
|
|
88
89
|
trySettlePublicSeat,
|
|
89
90
|
type SettlementCourtScope,
|
|
90
91
|
} from "./settlement.ts";
|
|
@@ -106,6 +107,7 @@ import {
|
|
|
106
107
|
latestPayloadEscalated,
|
|
107
108
|
type CountersignRunEnv,
|
|
108
109
|
} from "./countersign-run.ts";
|
|
110
|
+
import { readAuditedRound } from "../ticket-progress.ts";
|
|
109
111
|
import { errorText } from "../unknown-value.ts";
|
|
110
112
|
|
|
111
113
|
export type InstructionSeatRunEnv = PostAdmissionEnv & Pick<
|
|
@@ -803,6 +805,30 @@ async function runOmittedLensBatch(
|
|
|
803
805
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
804
806
|
}
|
|
805
807
|
|
|
808
|
+
/**
|
|
809
|
+
* #1200: every officer admission that names an audited leg — gate summons and
|
|
810
|
+
* a caller's own `--source-run`, first mint and re-summons alike — pins
|
|
811
|
+
*「审 谁#轮」before the officer runs, in the same page write as the source
|
|
812
|
+
* path when this admission is the one that records it. A row that cannot be
|
|
813
|
+
* read keeps its cause on the officer run; the officer still runs and its rows
|
|
814
|
+
* carry no `for`.
|
|
815
|
+
*/
|
|
816
|
+
async function pinAuditedLegAtAdmission(
|
|
817
|
+
officerRunDirectory: string,
|
|
818
|
+
auditedRunDirectory: string,
|
|
819
|
+
io: CliIo,
|
|
820
|
+
source?: { readonly sourceRunPath: string; readonly auditorSubject?: "judge" | "doctor" | undefined },
|
|
821
|
+
): Promise<void> {
|
|
822
|
+
const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
|
|
823
|
+
persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
|
|
824
|
+
if (fault === undefined) return;
|
|
825
|
+
await retainPackageFault({
|
|
826
|
+
runDirectory: officerRunDirectory,
|
|
827
|
+
diagnostic: fault,
|
|
828
|
+
stderr: (text) => io.stderr(text),
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
|
|
806
832
|
/**
|
|
807
833
|
* One same-parent lookup. Seat branches still build their own summons.
|
|
808
834
|
* A found child resumes that child. No prior run, explicit new, or a typed
|
|
@@ -839,6 +865,7 @@ function resumeSameParentInstructionSeat(input: {
|
|
|
839
865
|
},
|
|
840
866
|
input.env,
|
|
841
867
|
input.io,
|
|
868
|
+
input.parentRunPath,
|
|
842
869
|
);
|
|
843
870
|
},
|
|
844
871
|
});
|
|
@@ -945,7 +972,9 @@ async function runCountersignBody(
|
|
|
945
972
|
);
|
|
946
973
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
947
974
|
if (gateParentRunPath !== undefined) {
|
|
948
|
-
await
|
|
975
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
|
|
976
|
+
sourceRunPath: gateParentRunPath,
|
|
977
|
+
});
|
|
949
978
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
950
979
|
}
|
|
951
980
|
// #1208 C1 / #1166 J11: one shared initial-prompt seam (incl. file flags).
|
|
@@ -1169,12 +1198,22 @@ export async function runPublicInstructionSeat(
|
|
|
1169
1198
|
}
|
|
1170
1199
|
|
|
1171
1200
|
if (instructionSourceRunPath !== undefined) {
|
|
1172
|
-
await
|
|
1201
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
|
|
1202
|
+
sourceRunPath: instructionSourceRunPath,
|
|
1203
|
+
});
|
|
1173
1204
|
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath } as AdmittedRoleInvocation;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1205
|
+
} else if (record.sameParent === "subject-source" && auditorSource !== undefined) {
|
|
1206
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
|
|
1207
|
+
sourceRunPath: auditorSource,
|
|
1208
|
+
auditorSubject,
|
|
1209
|
+
});
|
|
1177
1210
|
admitted = { ...admitted, sourceRunPath: auditorSource } as AdmittedRoleInvocation;
|
|
1211
|
+
} else {
|
|
1212
|
+
// The admission itself already recorded the source (source-locator seats).
|
|
1213
|
+
const auditedRunDirectory = admittedSourceRunPath(admitted);
|
|
1214
|
+
if (auditedRunDirectory !== undefined) {
|
|
1215
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
|
|
1216
|
+
}
|
|
1178
1217
|
}
|
|
1179
1218
|
// #1208 C2: same helper as resume — inherit the audited source's known ticket.
|
|
1180
1219
|
admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
|
|
@@ -1249,6 +1288,8 @@ export async function runPublicInstructionSeatResume(
|
|
|
1249
1288
|
request: PublicResumeRequest,
|
|
1250
1289
|
env: InstructionSeatRunEnv,
|
|
1251
1290
|
io: CliIo,
|
|
1291
|
+
/** #1200: the audited leg a same-parent re-summons names; absent on every other resume. */
|
|
1292
|
+
resummonedFor?: string,
|
|
1252
1293
|
): Promise<SeatRunResult> {
|
|
1253
1294
|
let selectedRequest = request;
|
|
1254
1295
|
const resume = async () => {
|
|
@@ -1286,6 +1327,12 @@ export async function runPublicInstructionSeatResume(
|
|
|
1286
1327
|
return { ...loaded, admitted };
|
|
1287
1328
|
},
|
|
1288
1329
|
buildTurnRequest: async (admitted, effective) => {
|
|
1330
|
+
// #1200: the turn is built once this leg has taken the summons — inside
|
|
1331
|
+
// its writer lease wherever the resume holds one — and before the host
|
|
1332
|
+
// turn. A summons the lease refuses never gets here and pins nothing.
|
|
1333
|
+
if (resummonedFor !== undefined) {
|
|
1334
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
|
|
1335
|
+
}
|
|
1289
1336
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
1290
1337
|
const projection = resumeTurnRequestProjectionOptions(
|
|
1291
1338
|
admitted, effective, env, summonsPrepared,
|
|
@@ -478,29 +478,44 @@ async function mergeInvocationIdentityPage(
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
/**
|
|
481
|
-
*
|
|
482
|
-
*
|
|
481
|
+
* What this officer audits, on its admitted section in one page write.
|
|
482
|
+
* `for` (#1200) is the audited leg's「席#轮」at this admission: a new value
|
|
483
|
+
* replaces the old one, none clears it. `sourceRunPath` (#747) is the parent
|
|
484
|
+
* --source-run path kept for officer resume lookup, given only by the admission
|
|
485
|
+
* that first records it; it reuses the existing notary key and is never replaced.
|
|
483
486
|
*/
|
|
484
|
-
export
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
487
|
+
export function persistAdmittedAuditedLeg(
|
|
488
|
+
runDirectory: string,
|
|
489
|
+
audited: {
|
|
490
|
+
readonly for: string | undefined;
|
|
491
|
+
readonly sourceRunPath?: string;
|
|
492
|
+
readonly auditorSubject?: "judge" | "doctor" | undefined;
|
|
493
|
+
},
|
|
494
|
+
): void {
|
|
495
|
+
const { sourceRunPath, auditorSubject } = audited;
|
|
496
|
+
if (sourceRunPath !== undefined && sourceRunPath.trim() === "") {
|
|
497
|
+
throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
|
|
491
498
|
}
|
|
492
|
-
updateSectionSync(
|
|
493
|
-
if (
|
|
499
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
500
|
+
if (
|
|
501
|
+
sourceRunPath !== undefined
|
|
502
|
+
&& typeof current.sourceRunPath === "string"
|
|
503
|
+
&& current.sourceRunPath !== sourceRunPath
|
|
504
|
+
) {
|
|
494
505
|
throw new Error(
|
|
495
|
-
`
|
|
506
|
+
`persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`,
|
|
496
507
|
);
|
|
497
508
|
}
|
|
498
|
-
const
|
|
499
|
-
|
|
509
|
+
const unchanged = current.for === audited.for
|
|
510
|
+
&& (sourceRunPath === undefined || current.sourceRunPath === sourceRunPath)
|
|
511
|
+
&& (auditorSubject === undefined || current.auditorSubject === auditorSubject);
|
|
512
|
+
if (unchanged) return undefined;
|
|
513
|
+
const { for: _replaced, ...rest } = current;
|
|
500
514
|
return {
|
|
501
|
-
...
|
|
502
|
-
sourceRunPath,
|
|
515
|
+
...rest,
|
|
516
|
+
...(sourceRunPath === undefined ? {} : { sourceRunPath }),
|
|
503
517
|
...(auditorSubject === undefined ? {} : { auditorSubject }),
|
|
518
|
+
...(audited.for === undefined ? {} : { for: audited.for }),
|
|
504
519
|
};
|
|
505
520
|
});
|
|
506
521
|
}
|