@akagilnc/pi-workflow-roles 0.1.4802 → 0.1.4874

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 (142) hide show
  1. package/dist/acp-host/production-host.js +19434 -18218
  2. package/dist/analyst-book-key.js +63 -0
  3. package/dist/analyst-cohort.js +167 -0
  4. package/dist/analyst-entry.js +320 -0
  5. package/dist/analyst-index.js +247 -0
  6. package/dist/analyst-ledger.js +561 -0
  7. package/dist/analyst-median.js +16 -0
  8. package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
  9. package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
  10. package/dist/analyst-metric-families/gate-cycles.js +77 -0
  11. package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
  12. package/dist/analyst-metric-families/round-timeline.js +126 -0
  13. package/dist/analyst-metric-families.js +23 -0
  14. package/dist/analyst-metric-family.js +11 -0
  15. package/dist/analyst-model-groups.js +135 -0
  16. package/dist/analyst-page.js +182 -0
  17. package/dist/atomic-write.js +23 -0
  18. package/dist/auditor-soul.js +1 -1
  19. package/dist/countersign-contracts.js +0 -2
  20. package/dist/diarist-contracts.js +0 -1
  21. package/dist/doctor-contracts.js +2 -2
  22. package/dist/gatekeeper-role.js +15 -16
  23. package/dist/gleaner-left-contracts.js +0 -2
  24. package/dist/headless-host/production-host.js +16967 -15749
  25. package/dist/host-contracts.js +0 -4
  26. package/dist/inspector-contracts.js +0 -2
  27. package/dist/institutional-resolution.js +4 -2
  28. package/dist/merger-contracts.js +0 -2
  29. package/dist/migrate-book-topology.js +3908 -3089
  30. package/dist/navigator-public-session.js +4 -3
  31. package/dist/notary-contracts.js +0 -2
  32. package/dist/package-contracts/auditor-output.js +0 -1
  33. package/dist/package-contracts/collector-output.js +0 -2
  34. package/dist/package-contracts/fixer-output.js +0 -2
  35. package/dist/package-contracts/gatekeeper-output.js +0 -2
  36. package/dist/package-contracts/judge-output.js +0 -2
  37. package/dist/package-contracts/navigator-output.js +0 -2
  38. package/dist/package-contracts/reviewer-output.js +0 -2
  39. package/dist/package-contracts/terminating-tools.js +32 -92
  40. package/dist/package-contracts/worker-output.js +0 -4
  41. package/dist/packaged-role-registry.js +518 -36
  42. package/dist/pi/role-turn-host.js +2 -1
  43. package/dist/public-cli/analyst-run.js +185 -0
  44. package/dist/public-cli/cli.js +885 -0
  45. package/dist/public-cli/config.js +12 -9
  46. package/dist/public-cli/countersign-run.js +4 -311
  47. package/dist/public-cli/instruction-seat-run.js +628 -158
  48. package/dist/public-cli/invocation.js +806 -1550
  49. package/dist/public-cli/main.js +6962 -9882
  50. package/dist/public-cli/option-definitions.js +51 -99
  51. package/dist/public-cli/post-admission.js +30 -2
  52. package/dist/public-cli/run-lifecycle.js +234 -353
  53. package/dist/public-cli/seat-ticket-binding.js +6 -0
  54. package/dist/public-cli/settlement.js +261 -675
  55. package/dist/public-cli/turn-request.js +76 -0
  56. package/dist/public-role-summons.js +38 -112
  57. package/dist/role-activation-flags.js +23 -45
  58. package/dist/secretariat-contracts.js +0 -2
  59. package/dist/session-identity.js +17 -8
  60. package/dist/session-opening-materials.js +3 -2
  61. package/extensions/role-runtime.ts +6 -80
  62. package/package.json +1 -1
  63. package/src/acp-host/role-turn-host.ts +4 -1
  64. package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
  65. package/src/auditor-role.ts +1 -2
  66. package/src/auditor-soul.ts +1 -1
  67. package/src/collector-role.ts +2 -2
  68. package/src/countersign-contracts.ts +0 -1
  69. package/src/countersign-role.ts +1 -1
  70. package/src/diarist-contracts.ts +0 -1
  71. package/src/diarist-role.ts +0 -1
  72. package/src/doctor-auditor.ts +1 -2
  73. package/src/doctor-contracts.ts +1 -1
  74. package/src/doctor-role.ts +3 -2
  75. package/src/external-host-turn-loop.ts +1 -1
  76. package/src/factory-board.ts +10 -7
  77. package/src/gatekeeper-role.ts +16 -10
  78. package/src/gleaner-left-contracts.ts +0 -1
  79. package/src/gleaner-left-role.ts +0 -1
  80. package/src/headless-host/role-turn-host.ts +7 -1
  81. package/src/host-contracts.ts +10 -6
  82. package/src/inspector-contracts.ts +0 -1
  83. package/src/inspector-role.ts +0 -2
  84. package/src/institutional-resolution.ts +6 -4
  85. package/src/judge-role.ts +3 -3
  86. package/src/merger-contracts.ts +0 -1
  87. package/src/merger-role.ts +2 -2
  88. package/src/navigator-public-session.ts +7 -6
  89. package/src/navigator-work-context.ts +6 -8
  90. package/src/notary-contracts.ts +0 -1
  91. package/src/notary-role.ts +2 -3
  92. package/src/package-contracts/auditor-output.ts +0 -1
  93. package/src/package-contracts/collector-output.ts +0 -1
  94. package/src/package-contracts/fixer-output.ts +0 -1
  95. package/src/package-contracts/gatekeeper-output.ts +0 -1
  96. package/src/package-contracts/judge-output.ts +0 -1
  97. package/src/package-contracts/navigator-output.ts +0 -1
  98. package/src/package-contracts/reviewer-output.ts +0 -1
  99. package/src/package-contracts/terminating-tools.ts +27 -99
  100. package/src/package-contracts/worker-output.ts +0 -2
  101. package/src/packaged-role-registry.ts +604 -35
  102. package/src/pi/role-turn-host.ts +2 -1
  103. package/src/public-cli/cli.ts +64 -259
  104. package/src/public-cli/config.ts +18 -10
  105. package/src/public-cli/countersign-run.ts +14 -449
  106. package/src/public-cli/instruction-seat-run.ts +758 -277
  107. package/src/public-cli/invocation.ts +1097 -2051
  108. package/src/public-cli/option-definitions.ts +62 -127
  109. package/src/public-cli/post-admission.ts +47 -2
  110. package/src/public-cli/run-lifecycle.ts +303 -613
  111. package/src/public-cli/seat-ticket-binding.ts +6 -0
  112. package/src/public-cli/settlement.ts +399 -1185
  113. package/src/public-cli/turn-request.ts +92 -1
  114. package/src/public-role-summons.ts +44 -128
  115. package/src/reviewer-role.ts +3 -2
  116. package/src/role-activation-flags.ts +20 -41
  117. package/src/role-runtime-dependencies.ts +25 -26
  118. package/src/role-runtime.ts +121 -232
  119. package/src/secretariat-contracts.ts +0 -1
  120. package/src/secretariat-role.ts +0 -2
  121. package/src/session-identity.ts +23 -8
  122. package/src/session-opening-materials.ts +2 -1
  123. package/src/worker-role.ts +3 -4
  124. package/dist/doctor-auditor.js +0 -25
  125. package/dist/public-cli/diarist-run.js +0 -130
  126. package/dist/public-cli/doctor-run.js +0 -87
  127. package/dist/public-cli/inspector-run.js +0 -151
  128. package/dist/public-cli/judge-run.js +0 -114
  129. package/dist/public-cli/notary-run.js +0 -174
  130. package/dist/public-cli/reviewer-run.js +0 -339
  131. package/src/public-cli/coder-run.ts +0 -255
  132. package/src/public-cli/collector-run.ts +0 -189
  133. package/src/public-cli/diarist-run.ts +0 -233
  134. package/src/public-cli/doctor-run.ts +0 -167
  135. package/src/public-cli/fixer-run.ts +0 -265
  136. package/src/public-cli/gleaner-left-run.ts +0 -167
  137. package/src/public-cli/inspector-run.ts +0 -261
  138. package/src/public-cli/judge-run.ts +0 -196
  139. package/src/public-cli/merger-run.ts +0 -294
  140. package/src/public-cli/notary-run.ts +0 -279
  141. package/src/public-cli/reviewer-run.ts +0 -480
  142. package/src/public-cli/secretariat-run.ts +0 -265
@@ -11,6 +11,7 @@
11
11
  * tokens or add parallel repeatability / requiredness branches.
12
12
  */
13
13
  import { CliUsageError } from "./cli-errors.js";
14
+ import { PUBLIC_CALLABLE_ROLES } from "./registry.js";
14
15
  /**
15
16
  * Cross-field at-least-one rules for analyst modes.
16
17
  * #399: issue bare call is lawful (whole book from cwd) — no require-any-of on issue.
@@ -281,10 +282,28 @@ const SHARED_ATTACH_SEMANTICS = {
281
282
  function bindOwner(owner, semantics) {
282
283
  return { ...semantics, owner };
283
284
  }
284
- const JUDGE_OPTIONS = [
285
- bindOwner("judge", SHARED_PROJECT_SEMANTICS),
286
- bindOwner("judge", SHARED_ATTACH_SEMANTICS),
287
- ];
285
+ /** Seats whose public face is only project + attach. Unique rows stay explicit. */
286
+ function projectAndAttach(owner) {
287
+ return [
288
+ bindOwner(owner, SHARED_PROJECT_SEMANTICS),
289
+ bindOwner(owner, SHARED_ATTACH_SEMANTICS),
290
+ ];
291
+ }
292
+ const SHARED_PHASE_SEMANTICS = {
293
+ id: "phase",
294
+ canonical: "plan|apply",
295
+ aliases: ["plan", "apply"],
296
+ valueMetavar: null,
297
+ required: false,
298
+ repeatable: false,
299
+ defaultValue: "apply",
300
+ form: "positional",
301
+ phases: ["plan", "apply"],
302
+ description: {
303
+ en: "Optional phase token before the instruction; defaults to apply.",
304
+ zh: "指令前可选 phase 词元;默认 apply。",
305
+ },
306
+ };
288
307
  const GLEANER_LEFT_OPTIONS = [
289
308
  bindOwner("gleaner-left", SHARED_PROJECT_SEMANTICS),
290
309
  // Unanchored seat: no --attach face (self-fetches the merge-candidate diff).
@@ -303,21 +322,8 @@ const GLEANER_LEFT_OPTIONS = [
303
322
  },
304
323
  },
305
324
  ];
306
- const INSPECTOR_OPTIONS = [
307
- bindOwner("inspector", SHARED_PROJECT_SEMANTICS),
308
- bindOwner("inspector", SHARED_ATTACH_SEMANTICS),
309
- ];
310
- const GATEKEEPER_OPTIONS = [
311
- bindOwner("gatekeeper", SHARED_PROJECT_SEMANTICS),
312
- bindOwner("gatekeeper", SHARED_ATTACH_SEMANTICS),
313
- ];
314
- const NAVIGATOR_OPTIONS = [
315
- bindOwner("navigator", SHARED_PROJECT_SEMANTICS),
316
- bindOwner("navigator", SHARED_ATTACH_SEMANTICS),
317
- ];
318
325
  const AUDITOR_OPTIONS = [
319
- bindOwner("auditor", SHARED_PROJECT_SEMANTICS),
320
- bindOwner("auditor", SHARED_ATTACH_SEMANTICS),
326
+ ...projectAndAttach("auditor"),
321
327
  {
322
328
  id: "subject",
323
329
  owner: "auditor",
@@ -347,57 +353,13 @@ const AUDITOR_OPTIONS = [
347
353
  },
348
354
  },
349
355
  ];
350
- const COUNTERSIGN_OPTIONS = [
351
- bindOwner("countersign", SHARED_PROJECT_SEMANTICS),
352
- bindOwner("countersign", SHARED_ATTACH_SEMANTICS),
353
- ];
354
- const DIARIST_OPTIONS = [
355
- bindOwner("diarist", SHARED_PROJECT_SEMANTICS),
356
- bindOwner("diarist", SHARED_ATTACH_SEMANTICS),
357
- ];
358
- const SECRETARIAT_OPTIONS = [
359
- bindOwner("secretariat", SHARED_PROJECT_SEMANTICS),
360
- bindOwner("secretariat", SHARED_ATTACH_SEMANTICS),
361
- ];
362
356
  const CODER_OPTIONS = [
363
- {
364
- id: "phase",
365
- owner: "coder",
366
- canonical: "plan|apply",
367
- aliases: ["plan", "apply"],
368
- valueMetavar: null,
369
- required: false,
370
- repeatable: false,
371
- defaultValue: "apply",
372
- form: "positional",
373
- phases: ["plan", "apply"],
374
- description: {
375
- en: "Optional phase token before the instruction; defaults to apply.",
376
- zh: "指令前可选 phase 词元;默认 apply。",
377
- },
378
- },
379
- bindOwner("coder", SHARED_PROJECT_SEMANTICS),
380
- bindOwner("coder", SHARED_ATTACH_SEMANTICS),
357
+ bindOwner("coder", SHARED_PHASE_SEMANTICS),
358
+ ...projectAndAttach("coder"),
381
359
  ];
382
360
  const FIXER_OPTIONS = [
383
- {
384
- id: "phase",
385
- owner: "fixer",
386
- canonical: "plan|apply",
387
- aliases: ["plan", "apply"],
388
- valueMetavar: null,
389
- required: false,
390
- repeatable: false,
391
- defaultValue: "apply",
392
- form: "positional",
393
- phases: ["plan", "apply"],
394
- description: {
395
- en: "Optional phase token before the instruction; defaults to apply.",
396
- zh: "指令前可选 phase 词元;默认 apply。",
397
- },
398
- },
399
- bindOwner("fixer", SHARED_PROJECT_SEMANTICS),
400
- bindOwner("fixer", SHARED_ATTACH_SEMANTICS),
361
+ bindOwner("fixer", SHARED_PHASE_SEMANTICS),
362
+ ...projectAndAttach("fixer"),
401
363
  {
402
364
  id: "prerequisites",
403
365
  owner: "fixer",
@@ -460,8 +422,7 @@ const REVIEWER_OPTIONS = [
460
422
  },
461
423
  ];
462
424
  const COLLECTOR_OPTIONS = [
463
- bindOwner("collector", SHARED_PROJECT_SEMANTICS),
464
- bindOwner("collector", SHARED_ATTACH_SEMANTICS),
425
+ ...projectAndAttach("collector"),
465
426
  {
466
427
  id: "pr",
467
428
  owner: "collector",
@@ -521,8 +482,7 @@ const COLLECTOR_OPTIONS = [
521
482
  },
522
483
  ];
523
484
  const DOCTOR_OPTIONS = [
524
- bindOwner("doctor", SHARED_PROJECT_SEMANTICS),
525
- bindOwner("doctor", SHARED_ATTACH_SEMANTICS),
485
+ ...projectAndAttach("doctor"),
526
486
  {
527
487
  id: "issue",
528
488
  owner: "doctor",
@@ -719,13 +679,10 @@ const ANALYST_OPTIONS = [
719
679
  },
720
680
  ];
721
681
  /**
722
- * Sole production option tables keyed by PUBLIC_ROLE_ARGV / global owner.
723
- * Rows are readonly definition lists — parsers look up spellings here.
682
+ * Seats whose public rows are not the shared project+attach face.
683
+ * A new project+attach seat needs no entry here.
724
684
  */
725
- export const PUBLIC_OPTION_TABLE = {
726
- global: GLOBAL_OPTIONS,
727
- judge: JUDGE_OPTIONS,
728
- countersign: COUNTERSIGN_OPTIONS,
685
+ const SEAT_OPTION_ROWS = {
729
686
  "gleaner-left": GLEANER_LEFT_OPTIONS,
730
687
  coder: CODER_OPTIONS,
731
688
  fixer: FIXER_OPTIONS,
@@ -734,32 +691,27 @@ export const PUBLIC_OPTION_TABLE = {
734
691
  doctor: DOCTOR_OPTIONS,
735
692
  merger: MERGER_OPTIONS,
736
693
  notary: NOTARY_OPTIONS,
737
- inspector: INSPECTOR_OPTIONS,
738
- gatekeeper: GATEKEEPER_OPTIONS,
739
- navigator: NAVIGATOR_OPTIONS,
740
694
  auditor: AUDITOR_OPTIONS,
741
- diarist: DIARIST_OPTIONS,
742
- secretariat: SECRETARIAT_OPTIONS,
743
- analyst: ANALYST_OPTIONS,
744
695
  };
745
- /** Role/deterministic owners that appear on PUBLIC_ROLE_ARGV. */
696
+ function seatOptionRows(role) {
697
+ return SEAT_OPTION_ROWS[role] ?? projectAndAttach(role);
698
+ }
699
+ /**
700
+ * Sole production option tables keyed by PUBLIC_ROLE_ARGV / global owner.
701
+ * Rows are readonly definition lists — parsers look up spellings here.
702
+ * Callable seats come from the composition root; only a different face is listed above.
703
+ */
704
+ function publicOptionTable() {
705
+ const roles = {};
706
+ for (const role of PUBLIC_CALLABLE_ROLES) {
707
+ roles[role] = seatOptionRows(role);
708
+ }
709
+ return { global: GLOBAL_OPTIONS, ...roles, analyst: ANALYST_OPTIONS };
710
+ }
711
+ export const PUBLIC_OPTION_TABLE = publicOptionTable();
712
+ /** Role/deterministic owners that appear on PUBLIC_ROLE_ARGV. Roles follow the composition root; analyst is the deterministic command. */
746
713
  export const PUBLIC_ROLE_OPTION_OWNERS = [
747
- "judge",
748
- "countersign",
749
- "gleaner-left",
750
- "coder",
751
- "fixer",
752
- "reviewer",
753
- "collector",
754
- "doctor",
755
- "merger",
756
- "notary",
757
- "inspector",
758
- "gatekeeper",
759
- "navigator",
760
- "auditor",
761
- "diarist",
762
- "secretariat",
714
+ ...PUBLIC_CALLABLE_ROLES,
763
715
  "analyst",
764
716
  ];
765
717
  export function optionsForOwner(owner) {
@@ -14,9 +14,9 @@ import { bindAdmittedTicketNumber, buildInstructionTransportPrompt, freezeAttach
14
14
  import { readRecordedSubmissionRows } from "../submission-ledger.js";
15
15
  import { pathContainedIn } from "../activation-ledger-topology.js";
16
16
  import { pickEngineAxis } from "../package-resources/engine-material.js";
17
- import { resolveHostAwareSessionAvailability } from "../session-identity.js";
17
+ import { readStoredHostSessionId, resolveHostAwareSessionAvailability } from "../session-identity.js";
18
18
  import { rewriteRunDirectoryPathValue } from "../role-run-relocation.js";
19
- import { isOfficerReviewSeat } from "../host-contracts.js";
19
+ import { isOfficerReviewSeat } from "../packaged-role-registry.js";
20
20
  import { deliverCaseDossierAsAttachment } from "./case-dossier-delivery.js";
21
21
  /** Original error bytes, never relabeled — a secondary fact riding beside a classified cause. */
22
22
  function describeCaughtError(error) {
@@ -875,6 +875,24 @@ export function resumeTurnRequestProjectionOptions(admitted, request, env, summo
875
875
  ...(env.stationChild === undefined ? {} : { stationChild: env.stationChild }),
876
876
  };
877
877
  }
878
+ /** Shared new-turn and in-call auto-resume projection. Seat code supplies prompt and activation. */
879
+ export function roleTurnOptions(env, admitted, continuation, extra) {
880
+ const correlationId = admitted.correlationId ?? env.correlationId;
881
+ return {
882
+ packageRoot: env.packageRoot,
883
+ home: env.home,
884
+ agentDir: env.agentDir,
885
+ ...(env.model === undefined ? {} : { model: env.model }),
886
+ ...pickEngineAxis(env),
887
+ ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
888
+ ...(correlationId === undefined || correlationId.trim() === ""
889
+ ? {}
890
+ : { correlationId }),
891
+ continuation,
892
+ ...(extra?.cwd === undefined ? {} : { cwd: extra.cwd }),
893
+ ...(env.stationChild === undefined ? {} : { stationChild: env.stationChild }),
894
+ };
895
+ }
878
896
  /**
879
897
  * Build the turn request, then hand off to dispatch. When a writer lease is
880
898
  * held, release it if build throws before handoff — dispatch's finally only
@@ -994,6 +1012,16 @@ export async function runPostAdmissionSeatResume(input) {
994
1012
  }
995
1013
  }
996
1014
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
1015
+ if (turnRequest.continuation.kind === "resume"
1016
+ && turnRequest.continuation.hostSessionId === undefined) {
1017
+ const hostSessionId = await readStoredHostSessionId(env.host, env.principalAuthority, admittedForBuild.principal);
1018
+ if (hostSessionId !== undefined) {
1019
+ turnRequest = {
1020
+ ...turnRequest,
1021
+ continuation: { ...turnRequest.continuation, hostSessionId },
1022
+ };
1023
+ }
1024
+ }
997
1025
  // Open court continue, or new court for summons / message re-review
998
1026
  // (clause 0 新庭可再交卷; #833). Bare resume without open court omits id.
999
1027
  if (openCourtAttemptId !== undefined ||