@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.
- package/dist/acp-host/production-host.js +19434 -18218
- package/dist/analyst-book-key.js +63 -0
- package/dist/analyst-cohort.js +167 -0
- package/dist/analyst-entry.js +320 -0
- package/dist/analyst-index.js +247 -0
- package/dist/analyst-ledger.js +561 -0
- package/dist/analyst-median.js +16 -0
- package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
- package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
- package/dist/analyst-metric-families/gate-cycles.js +77 -0
- package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
- package/dist/analyst-metric-families/round-timeline.js +126 -0
- package/dist/analyst-metric-families.js +23 -0
- package/dist/analyst-metric-family.js +11 -0
- package/dist/analyst-model-groups.js +135 -0
- package/dist/analyst-page.js +182 -0
- package/dist/atomic-write.js +23 -0
- package/dist/auditor-soul.js +1 -1
- package/dist/countersign-contracts.js +0 -2
- package/dist/diarist-contracts.js +0 -1
- package/dist/doctor-contracts.js +2 -2
- package/dist/gatekeeper-role.js +15 -16
- package/dist/gleaner-left-contracts.js +0 -2
- package/dist/headless-host/production-host.js +16967 -15749
- package/dist/host-contracts.js +0 -4
- package/dist/inspector-contracts.js +0 -2
- package/dist/institutional-resolution.js +4 -2
- package/dist/merger-contracts.js +0 -2
- package/dist/migrate-book-topology.js +3908 -3089
- package/dist/navigator-public-session.js +4 -3
- package/dist/notary-contracts.js +0 -2
- package/dist/package-contracts/auditor-output.js +0 -1
- package/dist/package-contracts/collector-output.js +0 -2
- package/dist/package-contracts/fixer-output.js +0 -2
- package/dist/package-contracts/gatekeeper-output.js +0 -2
- package/dist/package-contracts/judge-output.js +0 -2
- package/dist/package-contracts/navigator-output.js +0 -2
- package/dist/package-contracts/reviewer-output.js +0 -2
- package/dist/package-contracts/terminating-tools.js +32 -92
- package/dist/package-contracts/worker-output.js +0 -4
- package/dist/packaged-role-registry.js +518 -36
- package/dist/pi/role-turn-host.js +2 -1
- package/dist/public-cli/analyst-run.js +185 -0
- package/dist/public-cli/cli.js +885 -0
- package/dist/public-cli/config.js +12 -9
- package/dist/public-cli/countersign-run.js +4 -311
- package/dist/public-cli/instruction-seat-run.js +628 -158
- package/dist/public-cli/invocation.js +806 -1550
- package/dist/public-cli/main.js +6962 -9882
- package/dist/public-cli/option-definitions.js +51 -99
- package/dist/public-cli/post-admission.js +30 -2
- package/dist/public-cli/run-lifecycle.js +234 -353
- package/dist/public-cli/seat-ticket-binding.js +6 -0
- package/dist/public-cli/settlement.js +261 -675
- package/dist/public-cli/turn-request.js +76 -0
- package/dist/public-role-summons.js +38 -112
- package/dist/role-activation-flags.js +23 -45
- package/dist/secretariat-contracts.js +0 -2
- package/dist/session-identity.js +17 -8
- package/dist/session-opening-materials.js +3 -2
- package/extensions/role-runtime.ts +6 -80
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +4 -1
- package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
- package/src/auditor-role.ts +1 -2
- package/src/auditor-soul.ts +1 -1
- package/src/collector-role.ts +2 -2
- package/src/countersign-contracts.ts +0 -1
- package/src/countersign-role.ts +1 -1
- package/src/diarist-contracts.ts +0 -1
- package/src/diarist-role.ts +0 -1
- package/src/doctor-auditor.ts +1 -2
- package/src/doctor-contracts.ts +1 -1
- package/src/doctor-role.ts +3 -2
- package/src/external-host-turn-loop.ts +1 -1
- package/src/factory-board.ts +10 -7
- package/src/gatekeeper-role.ts +16 -10
- package/src/gleaner-left-contracts.ts +0 -1
- package/src/gleaner-left-role.ts +0 -1
- package/src/headless-host/role-turn-host.ts +7 -1
- package/src/host-contracts.ts +10 -6
- package/src/inspector-contracts.ts +0 -1
- package/src/inspector-role.ts +0 -2
- package/src/institutional-resolution.ts +6 -4
- package/src/judge-role.ts +3 -3
- package/src/merger-contracts.ts +0 -1
- package/src/merger-role.ts +2 -2
- package/src/navigator-public-session.ts +7 -6
- package/src/navigator-work-context.ts +6 -8
- package/src/notary-contracts.ts +0 -1
- package/src/notary-role.ts +2 -3
- package/src/package-contracts/auditor-output.ts +0 -1
- package/src/package-contracts/collector-output.ts +0 -1
- package/src/package-contracts/fixer-output.ts +0 -1
- package/src/package-contracts/gatekeeper-output.ts +0 -1
- package/src/package-contracts/judge-output.ts +0 -1
- package/src/package-contracts/navigator-output.ts +0 -1
- package/src/package-contracts/reviewer-output.ts +0 -1
- package/src/package-contracts/terminating-tools.ts +27 -99
- package/src/package-contracts/worker-output.ts +0 -2
- package/src/packaged-role-registry.ts +604 -35
- package/src/pi/role-turn-host.ts +2 -1
- package/src/public-cli/cli.ts +64 -259
- package/src/public-cli/config.ts +18 -10
- package/src/public-cli/countersign-run.ts +14 -449
- package/src/public-cli/instruction-seat-run.ts +758 -277
- package/src/public-cli/invocation.ts +1097 -2051
- package/src/public-cli/option-definitions.ts +62 -127
- package/src/public-cli/post-admission.ts +47 -2
- package/src/public-cli/run-lifecycle.ts +303 -613
- package/src/public-cli/seat-ticket-binding.ts +6 -0
- package/src/public-cli/settlement.ts +399 -1185
- package/src/public-cli/turn-request.ts +92 -1
- package/src/public-role-summons.ts +44 -128
- package/src/reviewer-role.ts +3 -2
- package/src/role-activation-flags.ts +20 -41
- package/src/role-runtime-dependencies.ts +25 -26
- package/src/role-runtime.ts +121 -232
- package/src/secretariat-contracts.ts +0 -1
- package/src/secretariat-role.ts +0 -2
- package/src/session-identity.ts +23 -8
- package/src/session-opening-materials.ts +2 -1
- package/src/worker-role.ts +3 -4
- package/dist/doctor-auditor.js +0 -25
- package/dist/public-cli/diarist-run.js +0 -130
- package/dist/public-cli/doctor-run.js +0 -87
- package/dist/public-cli/inspector-run.js +0 -151
- package/dist/public-cli/judge-run.js +0 -114
- package/dist/public-cli/notary-run.js +0 -174
- package/dist/public-cli/reviewer-run.js +0 -339
- package/src/public-cli/coder-run.ts +0 -255
- package/src/public-cli/collector-run.ts +0 -189
- package/src/public-cli/diarist-run.ts +0 -233
- package/src/public-cli/doctor-run.ts +0 -167
- package/src/public-cli/fixer-run.ts +0 -265
- package/src/public-cli/gleaner-left-run.ts +0 -167
- package/src/public-cli/inspector-run.ts +0 -261
- package/src/public-cli/judge-run.ts +0 -196
- package/src/public-cli/merger-run.ts +0 -294
- package/src/public-cli/notary-run.ts +0 -279
- package/src/public-cli/reviewer-run.ts +0 -480
- package/src/public-cli/secretariat-run.ts +0 -265
|
@@ -10,7 +10,8 @@ import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:pa
|
|
|
10
10
|
import { platform } from "node:process";
|
|
11
11
|
import { promisify } from "node:util";
|
|
12
12
|
import { randomUUID } from "node:crypto";
|
|
13
|
-
import { ExplicitInternalActivationError
|
|
13
|
+
import { ExplicitInternalActivationError } from "../host-contracts.js";
|
|
14
|
+
import { isOfficerReviewSeat } from "../packaged-role-registry.js";
|
|
14
15
|
import { applyEngineChildEnv, ENGINE_MODEL_FLAG_NAME, normalizeEngineName } from "../engine-detour.js";
|
|
15
16
|
import { projectActivationFlags } from "../role-activation-flags.js";
|
|
16
17
|
import { encodeUserDialogueStdin } from "../user-dialogue-stdin.js";
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public analyst adapter (#336/#337/#338/#399): argv → typed query → runAnalyst family.
|
|
3
|
+
* Deterministic analysis seat — no Pi runner, no admission lease.
|
|
4
|
+
* Reuses existing CLI failure envelope (CliUsageError + structural reject +
|
|
5
|
+
* ControlledFailure).
|
|
6
|
+
* #399: issue query = book (cwd git common-dir) × optional --ticket N.
|
|
7
|
+
* Bare call = whole book; --project-root deleted; --model-groups public face disabled;
|
|
8
|
+
* no library-index bootstrap. Library model-groups kernel retained for follow-up.
|
|
9
|
+
* #337 sweep: exactly one typed JSON attachment → AnalystSweepModeInput → #329 kernel.
|
|
10
|
+
* #338: issue/cohort (+ library model-groups); sync compute-if-missing; whole-compute failure →
|
|
11
|
+
* ControlledFailure terminal (code/projectRoot/issueNumber/real cause).
|
|
12
|
+
* "Unobtrusive" binds #337 merge auto-trigger only, not this user-initiated query.
|
|
13
|
+
*/
|
|
14
|
+
import { readFile } from "node:fs/promises";
|
|
15
|
+
import { isAbsolute, resolve } from "node:path";
|
|
16
|
+
import { Value } from "typebox/value";
|
|
17
|
+
import { ActivationGitRepositoryRequiredError, resolveBookKeyFromGit, } from "../activation-ledger-git.js";
|
|
18
|
+
import { errnoCode, physicalPathIdentity, resolveActivationLedgerHome, } from "../activation-ledger-topology.js";
|
|
19
|
+
import { exactUtf8 } from "../exact-utf8.js";
|
|
20
|
+
import { readOrComputeAnalystIssuePage, runAnalyst, analystSweepModeInputSchema, AnalystIssueComputeError, } from "../analyst-entry.js";
|
|
21
|
+
import { CliUsageError } from "./cli-errors.js";
|
|
22
|
+
import { presentControlledFailure, presentStructuralRejection } from "./settlement.js";
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the issue-query book from cwd git common-dir (same owner as record layer).
|
|
25
|
+
* Non-git cwd fails loud — bare / --ticket both require a book identity.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
28
|
+
try {
|
|
29
|
+
return resolveBookKeyFromGit(cwd);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error instanceof ActivationGitRepositoryRequiredError) {
|
|
33
|
+
throw new CliUsageError("analyst issue query requires a git repository cwd (book = git common-dir); run inside a repository (bare = whole book, or --ticket N)", { cause: error });
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build the sole library issue-mode input from public argv faces (#399).
|
|
40
|
+
* - bare → whole book from cwd git common-dir
|
|
41
|
+
* - --ticket N → issueNumber = ticketNumber = N inside that book (strict; no index)
|
|
42
|
+
* - --project-root rejected at parse (deleted unconditionally)
|
|
43
|
+
*/
|
|
44
|
+
export async function buildAnalystIssueModeInputFromPublicArgv(parsed, _ledgerHome) {
|
|
45
|
+
const cwd = process.cwd();
|
|
46
|
+
const bookKey = resolveAnalystIssueBookKeyFromCwd(cwd);
|
|
47
|
+
const projectRoot = physicalPathIdentity(cwd);
|
|
48
|
+
const ticket = parsed.ticket;
|
|
49
|
+
if (ticket === undefined) {
|
|
50
|
+
return {
|
|
51
|
+
mode: "issue",
|
|
52
|
+
bookKey,
|
|
53
|
+
projectRoot,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
mode: "issue",
|
|
58
|
+
bookKey,
|
|
59
|
+
projectRoot,
|
|
60
|
+
ticketNumber: ticket,
|
|
61
|
+
issueNumber: ticket,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Attachment JSON → library AnalystSweepModeInput via the sole schema (#337).
|
|
66
|
+
* No parallel hand shape; rejects missing/extra/wrong-type fields only.
|
|
67
|
+
*/
|
|
68
|
+
export function parseAnalystSweepModeInputFromJsonValue(value) {
|
|
69
|
+
if (!Value.Check(analystSweepModeInputSchema, value)) {
|
|
70
|
+
throw new CliUsageError("analyst sweep attachment must match AnalystSweepModeInput");
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Load sweep typed input from exactly one public CLI attachment path.
|
|
76
|
+
* Rejects: wrong cardinality, unreadable path, non-UTF-8, JSON fail, field contract.
|
|
77
|
+
* Zero ledger writes — read-only path resolve + parse.
|
|
78
|
+
*/
|
|
79
|
+
export async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
80
|
+
if (attachmentPaths.length !== 1) {
|
|
81
|
+
throw new CliUsageError("analyst sweep requires exactly one --attach typed JSON attachment");
|
|
82
|
+
}
|
|
83
|
+
const sourcePath = attachmentPaths[0];
|
|
84
|
+
const absolute = isAbsolute(sourcePath) ? sourcePath : resolve(sourcePath);
|
|
85
|
+
let bytes;
|
|
86
|
+
try {
|
|
87
|
+
bytes = await readFile(absolute);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new CliUsageError(`analyst sweep attachment is not a readable regular file: ${sourcePath}`, { cause: error });
|
|
91
|
+
}
|
|
92
|
+
let text;
|
|
93
|
+
try {
|
|
94
|
+
text = exactUtf8(bytes, "analyst sweep attachment");
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
98
|
+
throw new CliUsageError(detail, { cause: error });
|
|
99
|
+
}
|
|
100
|
+
let parsed;
|
|
101
|
+
try {
|
|
102
|
+
parsed = JSON.parse(text);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw new CliUsageError("analyst sweep attachment is not valid JSON", { cause: error });
|
|
106
|
+
}
|
|
107
|
+
return parseAnalystSweepModeInputFromJsonValue(parsed);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Public analyst run path — parse → resolve → query → typed receipt on stdout.
|
|
111
|
+
* Issue (#336/#338 compute-if-missing), sweep (#337), cohort (#338).
|
|
112
|
+
* model-groups public face disabled at parse (#399); library kernel retained.
|
|
113
|
+
*/
|
|
114
|
+
export async function runPublicAnalyst(argv, _env, io, parseAnalystArgv) {
|
|
115
|
+
try {
|
|
116
|
+
const parsed = parseAnalystArgv(argv);
|
|
117
|
+
// Machine home is package-owned (ADR 0048) — caller may supply explicit home in env.
|
|
118
|
+
const ledgerHome = resolveActivationLedgerHome(_env.home);
|
|
119
|
+
if (parsed.query === "sweep") {
|
|
120
|
+
const input = await buildAnalystSweepModeInputFromAttachmentPaths(parsed.attachmentPaths);
|
|
121
|
+
const result = await runAnalyst(input, { home: _env.home });
|
|
122
|
+
io.stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
123
|
+
return { exitCode: 0 };
|
|
124
|
+
}
|
|
125
|
+
if (parsed.query === "cohort") {
|
|
126
|
+
// #412: bare N → cwd book (same口径 as #399 --ticket); book:N stays explicit.
|
|
127
|
+
// No cross-book silent scan — callers pass book:N for another repo's issues.
|
|
128
|
+
// Cwd book resolution is lazy and resolved at most once: an all-book:N
|
|
129
|
+
// cohort never touches cwd Git, so a non-git cwd cannot reject a purely
|
|
130
|
+
// explicit cross-book query.
|
|
131
|
+
let defaultBookKey;
|
|
132
|
+
const resolveIssue = (token) => {
|
|
133
|
+
if (token.kind === "book-qualified") {
|
|
134
|
+
return { bookKey: token.bookKey, issueNumber: token.issueNumber };
|
|
135
|
+
}
|
|
136
|
+
defaultBookKey ??= resolveAnalystIssueBookKeyFromCwd();
|
|
137
|
+
return { bookKey: defaultBookKey, issueNumber: token.issueNumber };
|
|
138
|
+
};
|
|
139
|
+
const result = await runAnalyst({
|
|
140
|
+
mode: "cohort",
|
|
141
|
+
groups: [
|
|
142
|
+
{
|
|
143
|
+
groupLabel: parsed.groups[0].groupLabel,
|
|
144
|
+
issues: parsed.groups[0].issues.map(resolveIssue),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
groupLabel: parsed.groups[1].groupLabel,
|
|
148
|
+
issues: parsed.groups[1].issues.map(resolveIssue),
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
}, { home: _env.home });
|
|
152
|
+
io.stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
153
|
+
return { exitCode: 0 };
|
|
154
|
+
}
|
|
155
|
+
// issue query — compute-if-missing (#338); sole kernel on miss.
|
|
156
|
+
const input = await buildAnalystIssueModeInputFromPublicArgv(parsed, ledgerHome);
|
|
157
|
+
const result = await readOrComputeAnalystIssuePage(input, { home: _env.home });
|
|
158
|
+
io.stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
159
|
+
return { exitCode: 0 };
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if (error instanceof CliUsageError) {
|
|
163
|
+
presentStructuralRejection(error, io);
|
|
164
|
+
return { exitCode: 2 };
|
|
165
|
+
}
|
|
166
|
+
if (error instanceof AnalystIssueComputeError) {
|
|
167
|
+
// Existing ControlledFailure: details carry code/projectRoot/issueNumber;
|
|
168
|
+
// identity.code carries distinguishable real cause (errno). No parallel schema.
|
|
169
|
+
const code = errnoCode(error.cause);
|
|
170
|
+
presentControlledFailure({
|
|
171
|
+
cause: "output",
|
|
172
|
+
diagnostic: error.message,
|
|
173
|
+
...(code === undefined ? {} : { identity: { code } }),
|
|
174
|
+
details: {
|
|
175
|
+
code: error.code,
|
|
176
|
+
bookKey: error.bookKey,
|
|
177
|
+
projectRoot: error.projectRoot,
|
|
178
|
+
...(error.issueNumber === undefined ? {} : { issueNumber: error.issueNumber }),
|
|
179
|
+
},
|
|
180
|
+
}, io);
|
|
181
|
+
return { exitCode: 1 };
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|