@akagilnc/pi-workflow-roles 0.1.5207 → 0.1.5216

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.
@@ -15038,7 +15038,6 @@ var init_sitian_facade = __esm({
15038
15038
  var init_ticket_provenance = __esm({
15039
15039
  "src/ticket-provenance.ts"() {
15040
15040
  "use strict";
15041
- init_activation_ledger_git();
15042
15041
  init_activation_ledger_topology();
15043
15042
  init_ledger_session_read();
15044
15043
  init_run_ticket_number();
@@ -18101,7 +18101,6 @@ function appendSitianRecord(input) {
18101
18101
  identity,
18102
18102
  ...input.subject === void 0 ? {} : { subject: input.subject },
18103
18103
  ...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
18104
- ...input.priorEventId === void 0 ? {} : { priorEventId: input.priorEventId },
18105
18104
  timestamp: timestamp2,
18106
18105
  host,
18107
18106
  ...input.source === void 0 ? {} : { source: input.source },
@@ -19273,7 +19272,6 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
19273
19272
  var init_ticket_provenance = __esm({
19274
19273
  "src/ticket-provenance.ts"() {
19275
19274
  "use strict";
19276
- init_activation_ledger_git();
19277
19275
  init_activation_ledger_topology();
19278
19276
  init_ledger_session_read();
19279
19277
  init_run_ticket_number();
@@ -240,7 +240,6 @@ function appendSitianRecord(input) {
240
240
  identity,
241
241
  ...input.subject === void 0 ? {} : { subject: input.subject },
242
242
  ...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
243
- ...input.priorEventId === void 0 ? {} : { priorEventId: input.priorEventId },
244
243
  timestamp,
245
244
  host,
246
245
  ...input.source === void 0 ? {} : { source: input.source },
@@ -312,26 +312,14 @@ export async function readLatestSubmissionOutcome(cwd, runId, homeOrScope) {
312
312
  }
313
313
  async function restoreState(cwd, runId, scope) {
314
314
  const located = await readOwnedSubmissionRecords(cwd, runId, scope);
315
- // Unknown-run empty set: no prior chain. Owned rows without a file are an internal bug.
316
315
  if (located.file === undefined) {
317
316
  if (located.owned.length !== 0) {
318
317
  throw new Error(`submission ledger invariant: owned rows present without recordFile for run ${runId}`);
319
318
  }
320
319
  return { sequence: 0 };
321
320
  }
322
- const { file, owned } = located;
323
- const last = owned.at(-1);
321
+ const { owned } = located;
324
322
  return {
325
- ...(last === undefined
326
- ? {}
327
- : {
328
- prior: {
329
- identity: last.identity,
330
- recordFile: file,
331
- kind: last.kind,
332
- level: last.level,
333
- },
334
- }),
335
323
  sequence: owned.reduce((maximum, record) => {
336
324
  const payload = record.payload;
337
325
  return payload?.type === "candidate" && typeof payload.sequence === "number"
@@ -362,7 +350,7 @@ function homeFromHostContext(context, home) {
362
350
  }
363
351
  /**
364
352
  * #959: seal one accepted submission without a model tool call.
365
- * Same ledger row shape and priorEventId chain as the terminating-tool wrap.
353
+ * Same ledger row shape as the terminating-tool wrap.
366
354
  * Used when a prose-exit seat (navigator) harvests the final assistant text.
367
355
  */
368
356
  export async function sealAcceptedSubmission(options) {
@@ -370,15 +358,10 @@ export async function sealAcceptedSubmission(options) {
370
358
  const attemptId = attemptIdentity(options.context, runId);
371
359
  const sessionParent = sessionParentFromHostContext(options.context);
372
360
  const home = homeFromHostContext(options.context, options.home);
373
- const state = await restoreState(options.context.cwd, runId, {
374
- ...(home === undefined ? {} : { home }),
375
- ...(sessionParent === undefined ? {} : { sessionParent }),
376
- });
377
- const pointer = sitianReport({
361
+ sitianReport({
378
362
  level: "event",
379
363
  kind: "sealed",
380
364
  subject: { runId, attemptId },
381
- ...(state.prior === undefined ? {} : { priorEventId: state.prior.identity }),
382
365
  payload: {
383
366
  type: "sealed",
384
367
  attemptId,
@@ -391,7 +374,6 @@ export async function sealAcceptedSubmission(options) {
391
374
  ...(home !== undefined ? { home } : {}),
392
375
  ...(sessionParent === undefined ? {} : { sessionParent }),
393
376
  });
394
- state.prior = pointer;
395
377
  }
396
378
  /**
397
379
  * Submission ledger host — record only (#836).
@@ -412,31 +394,28 @@ export function createSubmissionLedgerHost(host, outputTools, failInfrastructure
412
394
  states.set(runId, pending);
413
395
  return pending;
414
396
  })();
415
- const appendFor = (state, context, runId, attemptId, event) => {
397
+ const appendFor = (context, runId, attemptId, event) => {
416
398
  const home = resolveHomeFromContext(context);
417
399
  const sessionParent = sessionParentFromHostContext(context);
418
- const pointer = sitianReport({
400
+ return sitianReport({
419
401
  level: "event",
420
402
  kind: event.type,
421
403
  subject: { runId, attemptId },
422
- ...(state.prior === undefined ? {} : { priorEventId: state.prior.identity }),
423
404
  payload: event,
424
405
  source: "role-runtime",
425
406
  cwd: context.cwd,
426
407
  ...(home !== undefined ? { home } : {}),
427
408
  ...(sessionParent === undefined ? {} : { sessionParent }),
428
409
  });
429
- state.prior = pointer;
430
- return pointer;
431
410
  };
432
411
  host.on("turn_end", async (event, context) => {
433
412
  try {
434
413
  const runId = runIdentity(context);
435
414
  const attemptId = attemptIdentity(context, runId);
436
- const state = await stateFor(context, runId);
437
415
  const calls = event.calls.map(({ toolCallId: id, toolName: name }) => ({ id, name }));
438
416
  if (calls.length > 0) {
439
- appendFor(state, context, runId, attemptId, { type: "roundContext", attemptId, calls });
417
+ await stateFor(context, runId);
418
+ appendFor(context, runId, attemptId, { type: "roundContext", attemptId, calls });
440
419
  }
441
420
  }
442
421
  catch (error) {
@@ -465,7 +444,7 @@ export function createSubmissionLedgerHost(host, outputTools, failInfrastructure
465
444
  const runId = runIdentity(context);
466
445
  const attemptId = attemptIdentity(context, runId);
467
446
  const state = await stateFor(context, runId);
468
- const append = (event) => appendFor(state, context, runId, attemptId, event);
447
+ const append = (event) => appendFor(context, runId, attemptId, event);
469
448
  // #541 / #575: shared infra-declaration fail lives on the ledger seam.
470
449
  // #641 chain②: seats may bounce a misdeclared infrastructure failure
471
450
  // as correctable (2.1/2.2/2.3 keep paths).
@@ -1,10 +1,9 @@
1
1
  /**
2
- * 起居录(ticket-provenance)typed 形状 —— ADR 0075「2026-09-14 修订」/ #901 / #918。
2
+ * 起居录(ticket-provenance)typed 形状 —— ADR 0075 / ADR 0081 / #1090。
3
3
  *
4
- * 一册=一个追加式 records.jsonl;逻辑册子头与对话由读取时折叠不可变投影提交得到。
5
- * 既有「首行册子头+裸对话行」snapshot 向后可读,后续提交不回写旧行。
6
- * sessions 为 prior ∪ 各轮累计并集(遗漏不删除),已结转正文不因历史源重读而改。
7
- * 交卷 `sessions` 输入语义仍是「本轮对话边界」;累计并集是机械合并,不是角色交什么。
4
+ * 一册=一个追加式 records.jsonl。每轮交卷的 `sessions`=本轮对话边界;
5
+ * 成录接缝按该边界从宿主卷投影并追加,不回读已成录历史去重或折叠。
6
+ * 既有「首行册子头+裸对话行」snapshot 仍可读;后续提交不回写旧行。
8
7
  */
9
8
  /** Sitian kind for per-ticket court diary volumes. */
10
9
  export const TICKET_PROVENANCE_KIND = "ticket-provenance";
@@ -21,19 +20,6 @@ function positiveInteger(value) {
21
20
  }
22
21
  return undefined;
23
22
  }
24
- function nonNegativeInteger(value) {
25
- if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0)
26
- return value;
27
- if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) {
28
- const parsed = Number(value);
29
- if (Number.isSafeInteger(parsed))
30
- return parsed;
31
- }
32
- return undefined;
33
- }
34
- function projectSpeaker(value) {
35
- return value === "owner" || value === "runner" ? value : undefined;
36
- }
37
23
  function projectBound(value) {
38
24
  if (!isRecord(value))
39
25
  return undefined;
@@ -102,27 +88,3 @@ export function projectTicketProvenanceHeader(value) {
102
88
  sessions,
103
89
  };
104
90
  }
105
- /** 读回一条对话行。 */
106
- export function projectTicketProvenanceLine(value) {
107
- if (!isRecord(value))
108
- return undefined;
109
- const speaker = projectSpeaker(value.speaker);
110
- const s = nonNegativeInteger(value.s);
111
- if (speaker === undefined || s === undefined)
112
- return undefined;
113
- if (typeof value.text !== "string")
114
- return undefined;
115
- const sourcePosition = nonNegativeInteger(value.sourcePosition);
116
- const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== ""
117
- ? value.sourceIdentity
118
- : undefined;
119
- const id = typeof value.id === "string" && value.id !== "" ? value.id : undefined;
120
- return {
121
- speaker,
122
- s,
123
- ...(sourcePosition === undefined ? {} : { sourcePosition }),
124
- ...(sourceIdentity === undefined ? {} : { sourceIdentity }),
125
- ...(id === undefined ? {} : { id }),
126
- text: value.text,
127
- };
128
- }