@narumitw/pi-subagents 2.1.4 → 3.0.0
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/README.md +187 -1228
- package/dist/child-communication-bridge.ts +136 -0
- package/dist/child-communication-bridge.ts.map +7 -0
- package/dist/chunks/chunk-UKTWUQRM.js +667 -0
- package/dist/chunks/chunk-UKTWUQRM.js.map +7 -0
- package/dist/index.ts +1448 -1614
- package/dist/index.ts.map +4 -4
- package/docs/design-principles.md +31 -0
- package/docs/ipc-transport-idea.md +103 -0
- package/docs/tools.md +109 -0
- package/package.json +11 -19
- package/src/broker-credentials.ts +71 -0
- package/src/child-communication-bridge.ts +153 -0
- package/src/child-communication-tools.ts +147 -0
- package/src/completion-renderer.ts +60 -0
- package/src/index.ts +1 -1
- package/src/message-broker.ts +628 -0
- package/src/model-output.ts +42 -0
- package/src/process.ts +688 -0
- package/src/runtime.ts +538 -0
- package/src/subagents.ts +33 -34
- package/src/tools.ts +416 -0
- package/src/types.ts +85 -0
- package/src/widget.ts +130 -0
- package/dist/chunks/auto-transport-FUUKFDIG.ts +0 -109
- package/dist/chunks/auto-transport-FUUKFDIG.ts.map +0 -7
- package/dist/chunks/capability-grant-PR72SWWS.ts +0 -19
- package/dist/chunks/capability-grant-PR72SWWS.ts.map +0 -7
- package/dist/chunks/child-peer-bridge.ts +0 -108
- package/dist/chunks/child-peer-bridge.ts.map +0 -7
- package/dist/chunks/chunk-2LMJU25E.ts +0 -1641
- package/dist/chunks/chunk-2LMJU25E.ts.map +0 -7
- package/dist/chunks/chunk-47SK2QYC.ts +0 -56
- package/dist/chunks/chunk-47SK2QYC.ts.map +0 -7
- package/dist/chunks/chunk-4AQSF7AS.ts +0 -29
- package/dist/chunks/chunk-4AQSF7AS.ts.map +0 -7
- package/dist/chunks/chunk-5DGRMKNV.ts +0 -126
- package/dist/chunks/chunk-5DGRMKNV.ts.map +0 -7
- package/dist/chunks/chunk-6H6TBBED.ts +0 -108
- package/dist/chunks/chunk-6H6TBBED.ts.map +0 -7
- package/dist/chunks/chunk-6KJ34M6S.ts +0 -159
- package/dist/chunks/chunk-6KJ34M6S.ts.map +0 -7
- package/dist/chunks/chunk-6NSJVPXX.ts +0 -480
- package/dist/chunks/chunk-6NSJVPXX.ts.map +0 -7
- package/dist/chunks/chunk-7AAJEUSL.ts +0 -238
- package/dist/chunks/chunk-7AAJEUSL.ts.map +0 -7
- package/dist/chunks/chunk-BFK2Z4ZF.ts +0 -189
- package/dist/chunks/chunk-BFK2Z4ZF.ts.map +0 -7
- package/dist/chunks/chunk-BOAXY55Y.ts +0 -153
- package/dist/chunks/chunk-BOAXY55Y.ts.map +0 -7
- package/dist/chunks/chunk-D4CR7T73.ts +0 -353
- package/dist/chunks/chunk-D4CR7T73.ts.map +0 -7
- package/dist/chunks/chunk-FEVPWRMU.ts +0 -300
- package/dist/chunks/chunk-FEVPWRMU.ts.map +0 -7
- package/dist/chunks/chunk-G6VZTCFH.ts +0 -70
- package/dist/chunks/chunk-G6VZTCFH.ts.map +0 -7
- package/dist/chunks/chunk-H3FP6DLR.ts +0 -160
- package/dist/chunks/chunk-H3FP6DLR.ts.map +0 -7
- package/dist/chunks/chunk-HA36LPCO.ts +0 -130
- package/dist/chunks/chunk-HA36LPCO.ts.map +0 -7
- package/dist/chunks/chunk-HOP5FXDT.ts +0 -27
- package/dist/chunks/chunk-HOP5FXDT.ts.map +0 -7
- package/dist/chunks/chunk-IGAMVWFN.ts +0 -139
- package/dist/chunks/chunk-IGAMVWFN.ts.map +0 -7
- package/dist/chunks/chunk-ILEQ27AL.ts +0 -45
- package/dist/chunks/chunk-ILEQ27AL.ts.map +0 -7
- package/dist/chunks/chunk-ITVWPNU4.ts +0 -819
- package/dist/chunks/chunk-ITVWPNU4.ts.map +0 -7
- package/dist/chunks/chunk-IWC32VPY.ts +0 -172
- package/dist/chunks/chunk-IWC32VPY.ts.map +0 -7
- package/dist/chunks/chunk-JSZIP73U.ts +0 -362
- package/dist/chunks/chunk-JSZIP73U.ts.map +0 -7
- package/dist/chunks/chunk-JU6LUNLP.ts +0 -380
- package/dist/chunks/chunk-JU6LUNLP.ts.map +0 -7
- package/dist/chunks/chunk-KMGKCEO4.ts +0 -38
- package/dist/chunks/chunk-KMGKCEO4.ts.map +0 -7
- package/dist/chunks/chunk-LASD73CM.ts +0 -339
- package/dist/chunks/chunk-LASD73CM.ts.map +0 -7
- package/dist/chunks/chunk-LEOYDZI3.ts +0 -22
- package/dist/chunks/chunk-LEOYDZI3.ts.map +0 -7
- package/dist/chunks/chunk-LL4LP2T7.ts +0 -737
- package/dist/chunks/chunk-LL4LP2T7.ts.map +0 -7
- package/dist/chunks/chunk-N2T5IN4X.ts +0 -18
- package/dist/chunks/chunk-N2T5IN4X.ts.map +0 -7
- package/dist/chunks/chunk-N7BLVXKK.ts +0 -73
- package/dist/chunks/chunk-N7BLVXKK.ts.map +0 -7
- package/dist/chunks/chunk-NLT67IZS.ts +0 -322
- package/dist/chunks/chunk-NLT67IZS.ts.map +0 -7
- package/dist/chunks/chunk-NTRPLF46.ts +0 -63
- package/dist/chunks/chunk-NTRPLF46.ts.map +0 -7
- package/dist/chunks/chunk-ONDTY4EL.ts +0 -91
- package/dist/chunks/chunk-ONDTY4EL.ts.map +0 -7
- package/dist/chunks/chunk-OVPHFGKO.ts +0 -1769
- package/dist/chunks/chunk-OVPHFGKO.ts.map +0 -7
- package/dist/chunks/chunk-P7OH4XMF.ts +0 -60
- package/dist/chunks/chunk-P7OH4XMF.ts.map +0 -7
- package/dist/chunks/chunk-PBZMBTNJ.ts +0 -422
- package/dist/chunks/chunk-PBZMBTNJ.ts.map +0 -7
- package/dist/chunks/chunk-PGLSFLYW.ts +0 -52
- package/dist/chunks/chunk-PGLSFLYW.ts.map +0 -7
- package/dist/chunks/chunk-RRR66UWR.ts +0 -28
- package/dist/chunks/chunk-RRR66UWR.ts.map +0 -7
- package/dist/chunks/chunk-RSUXZD6S.ts +0 -275
- package/dist/chunks/chunk-RSUXZD6S.ts.map +0 -7
- package/dist/chunks/chunk-RTCVYIZA.ts +0 -221
- package/dist/chunks/chunk-RTCVYIZA.ts.map +0 -7
- package/dist/chunks/chunk-RY2AEGMZ.ts +0 -34
- package/dist/chunks/chunk-RY2AEGMZ.ts.map +0 -7
- package/dist/chunks/chunk-SWGQLFSD.ts +0 -60
- package/dist/chunks/chunk-SWGQLFSD.ts.map +0 -7
- package/dist/chunks/chunk-TM2R67J3.ts +0 -52
- package/dist/chunks/chunk-TM2R67J3.ts.map +0 -7
- package/dist/chunks/chunk-TMZRHIIK.ts +0 -497
- package/dist/chunks/chunk-TMZRHIIK.ts.map +0 -7
- package/dist/chunks/chunk-TZ34IQ3M.ts +0 -59
- package/dist/chunks/chunk-TZ34IQ3M.ts.map +0 -7
- package/dist/chunks/chunk-UMBPMVJW.ts +0 -22
- package/dist/chunks/chunk-UMBPMVJW.ts.map +0 -7
- package/dist/chunks/chunk-VDG7LTYE.ts +0 -80
- package/dist/chunks/chunk-VDG7LTYE.ts.map +0 -7
- package/dist/chunks/chunk-X4NMONPE.ts +0 -73
- package/dist/chunks/chunk-X4NMONPE.ts.map +0 -7
- package/dist/chunks/chunk-YPJEN6NU.ts +0 -65
- package/dist/chunks/chunk-YPJEN6NU.ts.map +0 -7
- package/dist/chunks/chunk-YU53SHA7.ts +0 -328
- package/dist/chunks/chunk-YU53SHA7.ts.map +0 -7
- package/dist/chunks/completion-delivery-RSJU6BXL.ts +0 -17
- package/dist/chunks/completion-delivery-RSJU6BXL.ts.map +0 -7
- package/dist/chunks/config-status-FKGDECZ3.ts +0 -35
- package/dist/chunks/config-status-FKGDECZ3.ts.map +0 -7
- package/dist/chunks/config-ui-ABHYNGQ7.ts +0 -1212
- package/dist/chunks/config-ui-ABHYNGQ7.ts.map +0 -7
- package/dist/chunks/consult-LJU3IQY5.ts +0 -519
- package/dist/chunks/consult-LJU3IQY5.ts.map +0 -7
- package/dist/chunks/context-QDKLVQXE.ts +0 -11
- package/dist/chunks/context-QDKLVQXE.ts.map +0 -7
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts +0 -130
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts.map +0 -7
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts +0 -17
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +0 -7
- package/dist/chunks/delegation-contract-LA56I5DT.ts +0 -24
- package/dist/chunks/delegation-contract-LA56I5DT.ts.map +0 -7
- package/dist/chunks/discovery-MIFB2U4Y.ts +0 -12
- package/dist/chunks/discovery-MIFB2U4Y.ts.map +0 -7
- package/dist/chunks/execution-Q2JZLKJA.ts +0 -4037
- package/dist/chunks/execution-Q2JZLKJA.ts.map +0 -7
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts +0 -39
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts.map +0 -7
- package/dist/chunks/inspect-UH2TKH6E.ts +0 -634
- package/dist/chunks/inspect-UH2TKH6E.ts.map +0 -7
- package/dist/chunks/peer-communication-KL36Z6CO.ts +0 -294
- package/dist/chunks/peer-communication-KL36Z6CO.ts.map +0 -7
- package/dist/chunks/persistence-UY3PY6E5.ts +0 -348
- package/dist/chunks/persistence-UY3PY6E5.ts.map +0 -7
- package/dist/chunks/registry-BT54L6CY.ts +0 -1445
- package/dist/chunks/registry-BT54L6CY.ts.map +0 -7
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts +0 -81
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts.map +0 -7
- package/dist/chunks/rpc-transport-7R7DVCEB.ts +0 -1222
- package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +0 -7
- package/dist/chunks/runtime-policy-5YELCOVC.ts +0 -15
- package/dist/chunks/runtime-policy-5YELCOVC.ts.map +0 -7
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +0 -19
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +0 -7
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts +0 -13
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts.map +0 -7
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +0 -15
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +0 -7
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts +0 -160
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +0 -7
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +0 -164
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +0 -7
- package/dist/chunks/workspace-WDKLN72J.ts +0 -11
- package/dist/chunks/workspace-WDKLN72J.ts.map +0 -7
- package/docs/async-runtime-protocol.md +0 -84
- package/docs/implementation-notes/pi-subagents-capability-matrix.md +0 -62
- package/docs/implementation-notes/pi-subagents-current-direction.md +0 -99
- package/docs/implementation-notes/pi-subagents-rpc-v1.md +0 -139
- package/docs/pi-subagents-diagrams.md +0 -183
- package/src/adaptive-scheduler.ts +0 -224
- package/src/admission-policy.ts +0 -78
- package/src/agent-projection.ts +0 -53
- package/src/agents/built-ins.ts +0 -71
- package/src/agents/catalog.ts +0 -241
- package/src/agents/discovery.ts +0 -265
- package/src/agents/types.ts +0 -100
- package/src/agents.ts +0 -51
- package/src/auto-transport.ts +0 -121
- package/src/blocking-status.ts +0 -63
- package/src/cached-module-loader.ts +0 -18
- package/src/capabilities.ts +0 -145
- package/src/capability-grant.ts +0 -115
- package/src/capability-router.ts +0 -107
- package/src/child-peer-bridge.ts +0 -124
- package/src/child-peer-tools.ts +0 -132
- package/src/completion-delivery.ts +0 -409
- package/src/completion-render.ts +0 -190
- package/src/completion-requirement.ts +0 -479
- package/src/completion-routing.ts +0 -24
- package/src/config-registration.ts +0 -114
- package/src/config-status.ts +0 -217
- package/src/config-ui.ts +0 -983
- package/src/consult-policy.ts +0 -15
- package/src/consult-registration.ts +0 -125
- package/src/consult-render.ts +0 -194
- package/src/consult-resources.ts +0 -51
- package/src/consult-tool.ts +0 -95
- package/src/consult.ts +0 -566
- package/src/context.ts +0 -126
- package/src/create-stateful-transport.ts +0 -157
- package/src/cwd-policy.ts +0 -183
- package/src/delegation-contract.ts +0 -463
- package/src/execution/budget.ts +0 -56
- package/src/execution/runtime-policy.ts +0 -19
- package/src/execution-plan.ts +0 -322
- package/src/execution-ui.ts +0 -259
- package/src/execution.ts +0 -1679
- package/src/in-process-transport.ts +0 -941
- package/src/inspect-registration.ts +0 -64
- package/src/inspect-render.ts +0 -334
- package/src/inspect-tool.ts +0 -45
- package/src/inspect.ts +0 -769
- package/src/integration-controller.ts +0 -98
- package/src/limits.ts +0 -75
- package/src/orchestration-metrics.ts +0 -116
- package/src/outcome.ts +0 -61
- package/src/panel-child-group.ts +0 -35
- package/src/panel-contract.ts +0 -343
- package/src/panel-evidence.ts +0 -59
- package/src/panel-execution.ts +0 -769
- package/src/panel-failure.ts +0 -56
- package/src/panel-planning.ts +0 -175
- package/src/panel-presets.ts +0 -3
- package/src/panel-prompts.ts +0 -132
- package/src/panel-reconciliation.ts +0 -57
- package/src/panel-render.ts +0 -103
- package/src/parallel-limit-ui.ts +0 -113
- package/src/params.ts +0 -278
- package/src/peer-communication.ts +0 -352
- package/src/peer-transport.ts +0 -49
- package/src/persistence.ts +0 -522
- package/src/pi-args.ts +0 -43
- package/src/pi-invocation.ts +0 -168
- package/src/process-control.ts +0 -43
- package/src/prompt-resources.ts +0 -38
- package/src/prompt-source-safety.ts +0 -48
- package/src/protocol.ts +0 -76
- package/src/registry-types.ts +0 -204
- package/src/registry.ts +0 -1698
- package/src/render-common.ts +0 -252
- package/src/render.ts +0 -704
- package/src/result-contract.ts +0 -431
- package/src/retained-semantic-state.ts +0 -100
- package/src/rpc-timeout-finalization.ts +0 -207
- package/src/rpc-transport-metadata.ts +0 -65
- package/src/rpc-transport.ts +0 -1035
- package/src/rpc-turn-capture.ts +0 -217
- package/src/runner-outcome.ts +0 -31
- package/src/runner-result.ts +0 -55
- package/src/runner-types.ts +0 -102
- package/src/runner-usage.ts +0 -48
- package/src/runner.ts +0 -866
- package/src/safe-text.ts +0 -67
- package/src/semantic-snapshot.ts +0 -214
- package/src/session-guidance-contract.ts +0 -399
- package/src/settings/inspection.ts +0 -302
- package/src/settings/schema.ts +0 -195
- package/src/settings-reader.ts +0 -215
- package/src/settings.ts +0 -452
- package/src/spawn-idempotency.ts +0 -68
- package/src/stateful-agent-view.ts +0 -85
- package/src/stateful-config.ts +0 -13
- package/src/stateful-guidance.ts +0 -29
- package/src/stateful-lifecycle.ts +0 -74
- package/src/stateful-limit-ui.ts +0 -249
- package/src/stateful-limits.ts +0 -96
- package/src/stateful-prompt.ts +0 -49
- package/src/stateful-registration.ts +0 -1320
- package/src/stateful-render.ts +0 -318
- package/src/stateful-safety.ts +0 -47
- package/src/stateful-tool-params.ts +0 -215
- package/src/stateful.ts +0 -12
- package/src/subagent-details.ts +0 -43
- package/src/subagents-extension.ts +0 -372
- package/src/subprocess-transport.ts +0 -145
- package/src/supervision.ts +0 -104
- package/src/task-path.ts +0 -65
- package/src/timeout-checkpoint.ts +0 -305
- package/src/timeout-finalization.ts +0 -75
- package/src/tool-schema-compatibility.ts +0 -73
- package/src/transport-types.ts +0 -74
- package/src/transport-ui.ts +0 -135
- package/src/transport.ts +0 -43
- package/src/turn-budget.ts +0 -109
- package/src/usage-format.ts +0 -42
- package/src/usage-recording-config.ts +0 -13
- package/src/usage-recording-store.ts +0 -183
- package/src/usage-recording.ts +0 -478
- package/src/verification-harness.ts +0 -516
- package/src/verification-policy.ts +0 -67
- package/src/verification-receipt.ts +0 -275
- package/src/verified-execution-benchmark.ts +0 -86
- package/src/verified-execution-contract.ts +0 -191
- package/src/verified-execution-schema.ts +0 -32
- package/src/work-item-ledger.ts +0 -1404
- package/src/work-item-persistence.ts +0 -254
- package/src/workflow-completion-controller.ts +0 -397
- package/src/workflow-planning.ts +0 -172
- package/src/workflow-tree-identity.ts +0 -289
- package/src/workflow-ui.ts +0 -69
- package/src/workflow-verification.ts +0 -296
- package/src/workspace.ts +0 -174
package/src/panel-contract.ts
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { redactPrivateText } from "./context.js";
|
|
2
|
-
import { DEFAULT_MAX_OUTPUT_BYTES, truncateUtf8 } from "./limits.js";
|
|
3
|
-
|
|
4
|
-
export const PANEL_REVIEW_VERSION = "pi-subagents:panel-review:v1" as const;
|
|
5
|
-
export const PANEL_SYNTHESIS_VERSION = "pi-subagents:panel-synthesis:v1" as const;
|
|
6
|
-
export const PANEL_DISPOSITIONS = ["pass", "fail", "partial"] as const;
|
|
7
|
-
export const PANEL_SEVERITIES = ["critical", "high", "medium", "low", "info"] as const;
|
|
8
|
-
|
|
9
|
-
export type PanelDisposition = (typeof PANEL_DISPOSITIONS)[number];
|
|
10
|
-
export type PanelSeverity = (typeof PANEL_SEVERITIES)[number];
|
|
11
|
-
|
|
12
|
-
export interface PanelFinding {
|
|
13
|
-
id: string;
|
|
14
|
-
severity: PanelSeverity;
|
|
15
|
-
title: string;
|
|
16
|
-
claim: string;
|
|
17
|
-
evidence: string[];
|
|
18
|
-
verification?: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface PanelReviewProvenance {
|
|
22
|
-
reviewerId: string;
|
|
23
|
-
agent?: string;
|
|
24
|
-
model?: string;
|
|
25
|
-
taskGeneration: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface PanelReview {
|
|
29
|
-
version: typeof PANEL_REVIEW_VERSION;
|
|
30
|
-
reviewerId: string;
|
|
31
|
-
disposition: PanelDisposition;
|
|
32
|
-
blocking: boolean;
|
|
33
|
-
findings: PanelFinding[];
|
|
34
|
-
missingChecks: string[];
|
|
35
|
-
limitations: string[];
|
|
36
|
-
provenance?: PanelReviewProvenance;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface PanelDisagreement {
|
|
40
|
-
summary: string;
|
|
41
|
-
reviewerIds: string[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface PanelObjectionResolution {
|
|
45
|
-
reviewerId: string;
|
|
46
|
-
findingId: string;
|
|
47
|
-
resolution: "resolved" | "unresolved";
|
|
48
|
-
evidence: string[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface PanelSynthesis {
|
|
52
|
-
version: typeof PANEL_SYNTHESIS_VERSION;
|
|
53
|
-
disposition: PanelDisposition;
|
|
54
|
-
summary: string;
|
|
55
|
-
validReviewerIds: string[];
|
|
56
|
-
failedReviewerIds: string[];
|
|
57
|
-
agreements: string[];
|
|
58
|
-
disagreements: PanelDisagreement[];
|
|
59
|
-
objections: PanelObjectionResolution[];
|
|
60
|
-
limitations: string[];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const MAX_TEXT_BYTES = 8 * 1024;
|
|
64
|
-
const MAX_ID_BYTES = 256;
|
|
65
|
-
const MAX_ITEMS = 50;
|
|
66
|
-
|
|
67
|
-
export function panelReviewInstruction(reviewerId: string): string {
|
|
68
|
-
return [
|
|
69
|
-
"Return one JSON object and no surrounding prose.",
|
|
70
|
-
`Use exactly version "${PANEL_REVIEW_VERSION}" and reviewerId "${boundedId(reviewerId)}".`,
|
|
71
|
-
"Required fields are disposition, blocking, findings, missingChecks, and limitations.",
|
|
72
|
-
`disposition must be one of ${PANEL_DISPOSITIONS.join(", ")}; blocking must be a JSON boolean.`,
|
|
73
|
-
`Each finding must contain a unique id, severity (${PANEL_SEVERITIES.join(", ")}), title, claim, evidence as an array of strings, and optional verification as an array of strings.`,
|
|
74
|
-
`Use this exact shape: {"version":"${PANEL_REVIEW_VERSION}","reviewerId":"${boundedId(reviewerId)}","disposition":"pass","blocking":false,"findings":[{"id":"F1","severity":"info","title":"title","claim":"claim","evidence":["source or check"],"verification":[]}],"missingChecks":[],"limitations":[]}.`,
|
|
75
|
-
"Set blocking only for an objection that prevents a correctness, safety, security, or explicit-requirement pass.",
|
|
76
|
-
"Do not infer consensus or include other reviewers' identities or outputs.",
|
|
77
|
-
].join(" ");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function panelSynthesisInstruction(
|
|
81
|
-
reviewerIds: readonly string[],
|
|
82
|
-
failedReviewerIds: readonly string[],
|
|
83
|
-
): string {
|
|
84
|
-
return [
|
|
85
|
-
"Return one JSON object and no surrounding prose.",
|
|
86
|
-
`Use exactly version "${PANEL_SYNTHESIS_VERSION}".`,
|
|
87
|
-
`validReviewerIds must contain exactly: ${reviewerIds.join(", ") || "none"}.`,
|
|
88
|
-
`failedReviewerIds must contain exactly: ${failedReviewerIds.join(", ") || "none"}.`,
|
|
89
|
-
"Required fields are disposition, summary, validReviewerIds, failedReviewerIds, agreements, disagreements, objections, and limitations.",
|
|
90
|
-
`Use this exact shape: {"version":"${PANEL_SYNTHESIS_VERSION}","disposition":"pass","summary":"summary","validReviewerIds":${JSON.stringify(reviewerIds)},"failedReviewerIds":${JSON.stringify(failedReviewerIds)},"agreements":[],"disagreements":[],"objections":[],"limitations":[]}.`,
|
|
91
|
-
"Preserve every blocking objection by reviewerId and findingId.",
|
|
92
|
-
"A resolved objection requires concrete evidence; votes, reviewer count, and model confidence are not verification.",
|
|
93
|
-
].join(" ");
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function parsePanelReview(
|
|
97
|
-
text: string,
|
|
98
|
-
expectedReviewerId: string,
|
|
99
|
-
provenance: Partial<Omit<PanelReviewProvenance, "reviewerId">> = {},
|
|
100
|
-
): PanelReview | undefined {
|
|
101
|
-
const value = parseJsonObject(text);
|
|
102
|
-
if (
|
|
103
|
-
!value ||
|
|
104
|
-
!hasOnlyKeys(value, [
|
|
105
|
-
"version",
|
|
106
|
-
"reviewerId",
|
|
107
|
-
"disposition",
|
|
108
|
-
"blocking",
|
|
109
|
-
"findings",
|
|
110
|
-
"missingChecks",
|
|
111
|
-
"limitations",
|
|
112
|
-
]) ||
|
|
113
|
-
value.version !== PANEL_REVIEW_VERSION ||
|
|
114
|
-
value.reviewerId !== expectedReviewerId ||
|
|
115
|
-
typeof value.disposition !== "string" ||
|
|
116
|
-
!PANEL_DISPOSITIONS.includes(value.disposition as PanelDisposition) ||
|
|
117
|
-
typeof value.blocking !== "boolean"
|
|
118
|
-
) {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
const findings = objectArray(value.findings, parseFinding);
|
|
122
|
-
const missingChecks = stringArray(value.missingChecks);
|
|
123
|
-
const limitations = stringArray(value.limitations);
|
|
124
|
-
if (!findings || !missingChecks || !limitations) return undefined;
|
|
125
|
-
if (new Set(findings.map((finding) => finding.id)).size !== findings.length) return undefined;
|
|
126
|
-
if (value.blocking && (findings.length === 0 || value.disposition === "pass")) return undefined;
|
|
127
|
-
return {
|
|
128
|
-
version: PANEL_REVIEW_VERSION,
|
|
129
|
-
reviewerId: boundedId(expectedReviewerId),
|
|
130
|
-
disposition: value.disposition as PanelDisposition,
|
|
131
|
-
blocking: value.blocking,
|
|
132
|
-
findings,
|
|
133
|
-
missingChecks,
|
|
134
|
-
limitations,
|
|
135
|
-
provenance: {
|
|
136
|
-
reviewerId: boundedId(expectedReviewerId),
|
|
137
|
-
...(provenance.agent ? { agent: boundedId(provenance.agent) } : {}),
|
|
138
|
-
...(provenance.model ? { model: boundedId(provenance.model) } : {}),
|
|
139
|
-
taskGeneration: provenance.taskGeneration ?? 0,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function parsePanelSynthesis(
|
|
145
|
-
text: string,
|
|
146
|
-
reviews: readonly PanelReview[],
|
|
147
|
-
failedReviewerIds: readonly string[],
|
|
148
|
-
): PanelSynthesis | undefined {
|
|
149
|
-
const value = parseJsonObject(text);
|
|
150
|
-
if (
|
|
151
|
-
!value ||
|
|
152
|
-
!hasOnlyKeys(value, [
|
|
153
|
-
"version",
|
|
154
|
-
"disposition",
|
|
155
|
-
"summary",
|
|
156
|
-
"validReviewerIds",
|
|
157
|
-
"failedReviewerIds",
|
|
158
|
-
"agreements",
|
|
159
|
-
"disagreements",
|
|
160
|
-
"objections",
|
|
161
|
-
"limitations",
|
|
162
|
-
]) ||
|
|
163
|
-
value.version !== PANEL_SYNTHESIS_VERSION ||
|
|
164
|
-
typeof value.disposition !== "string" ||
|
|
165
|
-
!PANEL_DISPOSITIONS.includes(value.disposition as PanelDisposition) ||
|
|
166
|
-
typeof value.summary !== "string"
|
|
167
|
-
) {
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
170
|
-
const validReviewerIds = idArray(value.validReviewerIds);
|
|
171
|
-
const parsedFailedReviewerIds = idArray(value.failedReviewerIds);
|
|
172
|
-
const agreements = stringArray(value.agreements);
|
|
173
|
-
const disagreements = objectArray(value.disagreements, parseDisagreement);
|
|
174
|
-
const objections = objectArray(value.objections, parseObjection);
|
|
175
|
-
const limitations = stringArray(value.limitations);
|
|
176
|
-
if (
|
|
177
|
-
!validReviewerIds ||
|
|
178
|
-
!parsedFailedReviewerIds ||
|
|
179
|
-
!agreements ||
|
|
180
|
-
!disagreements ||
|
|
181
|
-
!objections ||
|
|
182
|
-
!limitations
|
|
183
|
-
) {
|
|
184
|
-
return undefined;
|
|
185
|
-
}
|
|
186
|
-
const expectedValid = reviews.map((review) => review.reviewerId);
|
|
187
|
-
if (!sameIds(validReviewerIds, expectedValid)) return undefined;
|
|
188
|
-
if (!sameIds(parsedFailedReviewerIds, failedReviewerIds)) return undefined;
|
|
189
|
-
const validSet = new Set(expectedValid);
|
|
190
|
-
if (disagreements.some((item) => item.reviewerIds.some((id) => !validSet.has(id))))
|
|
191
|
-
return undefined;
|
|
192
|
-
const blockers = reviews.flatMap((review) =>
|
|
193
|
-
review.blocking
|
|
194
|
-
? review.findings.map((finding) => `${review.reviewerId}\u0000${finding.id}`)
|
|
195
|
-
: [],
|
|
196
|
-
);
|
|
197
|
-
const objectionKeys = objections.map((item) => `${item.reviewerId}\u0000${item.findingId}`);
|
|
198
|
-
if (new Set(objectionKeys).size !== objectionKeys.length) return undefined;
|
|
199
|
-
if (blockers.some((key) => !objectionKeys.includes(key))) return undefined;
|
|
200
|
-
if (objections.some((item) => !validSet.has(item.reviewerId))) return undefined;
|
|
201
|
-
if (objections.some((item) => item.resolution === "resolved" && item.evidence.length === 0)) {
|
|
202
|
-
return undefined;
|
|
203
|
-
}
|
|
204
|
-
if (value.disposition === "pass" && objections.some((item) => item.resolution === "unresolved")) {
|
|
205
|
-
return undefined;
|
|
206
|
-
}
|
|
207
|
-
return {
|
|
208
|
-
version: PANEL_SYNTHESIS_VERSION,
|
|
209
|
-
disposition: value.disposition as PanelDisposition,
|
|
210
|
-
summary: boundedText(value.summary),
|
|
211
|
-
validReviewerIds,
|
|
212
|
-
failedReviewerIds: parsedFailedReviewerIds,
|
|
213
|
-
agreements,
|
|
214
|
-
disagreements,
|
|
215
|
-
objections,
|
|
216
|
-
limitations,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function parseFinding(value: Record<string, unknown>): PanelFinding | undefined {
|
|
221
|
-
if (
|
|
222
|
-
!hasOnlyKeys(value, ["id", "severity", "title", "claim", "evidence", "verification"]) ||
|
|
223
|
-
typeof value.id !== "string" ||
|
|
224
|
-
typeof value.severity !== "string" ||
|
|
225
|
-
!PANEL_SEVERITIES.includes(value.severity as PanelSeverity) ||
|
|
226
|
-
typeof value.title !== "string" ||
|
|
227
|
-
typeof value.claim !== "string"
|
|
228
|
-
) {
|
|
229
|
-
return undefined;
|
|
230
|
-
}
|
|
231
|
-
const id = boundedId(value.id);
|
|
232
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(id)) return undefined;
|
|
233
|
-
const evidence = stringArray(value.evidence);
|
|
234
|
-
const verification =
|
|
235
|
-
value.verification === undefined ? undefined : stringArray(value.verification);
|
|
236
|
-
if (!evidence || (value.verification !== undefined && !verification)) return undefined;
|
|
237
|
-
return {
|
|
238
|
-
id,
|
|
239
|
-
severity: value.severity as PanelSeverity,
|
|
240
|
-
title: boundedText(value.title),
|
|
241
|
-
claim: boundedText(value.claim),
|
|
242
|
-
evidence,
|
|
243
|
-
...(verification ? { verification } : {}),
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function parseDisagreement(value: Record<string, unknown>): PanelDisagreement | undefined {
|
|
248
|
-
if (!hasOnlyKeys(value, ["summary", "reviewerIds"]) || typeof value.summary !== "string") {
|
|
249
|
-
return undefined;
|
|
250
|
-
}
|
|
251
|
-
const reviewerIds = idArray(value.reviewerIds);
|
|
252
|
-
if (!reviewerIds || reviewerIds.length < 2) return undefined;
|
|
253
|
-
return { summary: boundedText(value.summary), reviewerIds };
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function parseObjection(value: Record<string, unknown>): PanelObjectionResolution | undefined {
|
|
257
|
-
if (
|
|
258
|
-
!hasOnlyKeys(value, ["reviewerId", "findingId", "resolution", "evidence"]) ||
|
|
259
|
-
typeof value.reviewerId !== "string" ||
|
|
260
|
-
typeof value.findingId !== "string" ||
|
|
261
|
-
(value.resolution !== "resolved" && value.resolution !== "unresolved")
|
|
262
|
-
) {
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
const evidence = stringArray(value.evidence);
|
|
266
|
-
if (!evidence) return undefined;
|
|
267
|
-
return {
|
|
268
|
-
reviewerId: boundedId(value.reviewerId),
|
|
269
|
-
findingId: boundedId(value.findingId),
|
|
270
|
-
resolution: value.resolution,
|
|
271
|
-
evidence,
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function parseJsonObject(text: string): Record<string, unknown> | undefined {
|
|
276
|
-
if (Buffer.byteLength(text, "utf8") > DEFAULT_MAX_OUTPUT_BYTES) return undefined;
|
|
277
|
-
const source = text
|
|
278
|
-
.trim()
|
|
279
|
-
.replace(/^```(?:json)?\s*/u, "")
|
|
280
|
-
.replace(/\s*```$/u, "")
|
|
281
|
-
.trim();
|
|
282
|
-
if (!source.startsWith("{") || !source.endsWith("}")) return undefined;
|
|
283
|
-
try {
|
|
284
|
-
const parsed: unknown = JSON.parse(source);
|
|
285
|
-
return isPlainObject(parsed) ? parsed : undefined;
|
|
286
|
-
} catch {
|
|
287
|
-
return undefined;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function stringArray(value: unknown): string[] | undefined {
|
|
292
|
-
if (
|
|
293
|
-
!Array.isArray(value) ||
|
|
294
|
-
value.length > MAX_ITEMS ||
|
|
295
|
-
value.some((item) => typeof item !== "string")
|
|
296
|
-
) {
|
|
297
|
-
return undefined;
|
|
298
|
-
}
|
|
299
|
-
return value.map((item) => boundedText(item as string));
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function idArray(value: unknown): string[] | undefined {
|
|
303
|
-
const values = stringArray(value)?.map(boundedId);
|
|
304
|
-
if (!values || new Set(values).size !== values.length || values.some((id) => !id))
|
|
305
|
-
return undefined;
|
|
306
|
-
return values;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function objectArray<T>(
|
|
310
|
-
value: unknown,
|
|
311
|
-
parser: (value: Record<string, unknown>) => T | undefined,
|
|
312
|
-
): T[] | undefined {
|
|
313
|
-
if (!Array.isArray(value) || value.length > MAX_ITEMS) return undefined;
|
|
314
|
-
const parsed: T[] = [];
|
|
315
|
-
for (const item of value) {
|
|
316
|
-
if (!isPlainObject(item)) return undefined;
|
|
317
|
-
const result = parser(item);
|
|
318
|
-
if (!result) return undefined;
|
|
319
|
-
parsed.push(result);
|
|
320
|
-
}
|
|
321
|
-
return parsed;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function hasOnlyKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {
|
|
325
|
-
const allowed = new Set(keys);
|
|
326
|
-
return Object.keys(value).every((key) => allowed.has(key));
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
330
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function boundedText(value: string): string {
|
|
334
|
-
return truncateUtf8(redactPrivateText(value), MAX_TEXT_BYTES).text;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function boundedId(value: string): string {
|
|
338
|
-
return truncateUtf8(redactPrivateText(value), MAX_ID_BYTES).text.trim();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function sameIds(actual: readonly string[], expected: readonly string[]): boolean {
|
|
342
|
-
return actual.length === expected.length && actual.every((id) => expected.includes(id));
|
|
343
|
-
}
|
package/src/panel-evidence.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { PanelReview } from "./panel-contract.js";
|
|
2
|
-
|
|
3
|
-
const MAX_PANEL_EVIDENCE_BYTES = 24 * 1024;
|
|
4
|
-
export interface PanelEvidenceArtifact {
|
|
5
|
-
panelId: string;
|
|
6
|
-
reviewerId: string;
|
|
7
|
-
revision: number;
|
|
8
|
-
review: PanelReview;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class PanelEvidenceLedger {
|
|
12
|
-
private readonly latestByReviewer = new Map<string, PanelEvidenceArtifact>();
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
private readonly panelId: string,
|
|
16
|
-
private readonly maxArtifacts: number,
|
|
17
|
-
) {}
|
|
18
|
-
|
|
19
|
-
publish(review: PanelReview, revision: number): boolean {
|
|
20
|
-
if (!Number.isSafeInteger(revision) || revision < 1) return false;
|
|
21
|
-
const current = this.latestByReviewer.get(review.reviewerId);
|
|
22
|
-
if (
|
|
23
|
-
current &&
|
|
24
|
-
current.review.provenance?.taskGeneration !== review.provenance?.taskGeneration
|
|
25
|
-
) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if ((!current && revision !== 1) || (current && revision !== current.revision + 1))
|
|
29
|
-
return false;
|
|
30
|
-
if (!current && this.latestByReviewer.size >= this.maxArtifacts) return false;
|
|
31
|
-
const artifact = {
|
|
32
|
-
panelId: this.panelId,
|
|
33
|
-
reviewerId: review.reviewerId,
|
|
34
|
-
revision,
|
|
35
|
-
review: structuredClone(review),
|
|
36
|
-
};
|
|
37
|
-
const candidate = [
|
|
38
|
-
...[...this.latestByReviewer.values()].filter(
|
|
39
|
-
(item) => item.reviewerId !== review.reviewerId,
|
|
40
|
-
),
|
|
41
|
-
artifact,
|
|
42
|
-
];
|
|
43
|
-
if (Buffer.byteLength(JSON.stringify(candidate), "utf8") > MAX_PANEL_EVIDENCE_BYTES)
|
|
44
|
-
return false;
|
|
45
|
-
this.latestByReviewer.set(review.reviewerId, artifact);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
latest(reviewerId: string): PanelEvidenceArtifact | undefined {
|
|
50
|
-
const artifact = this.latestByReviewer.get(reviewerId);
|
|
51
|
-
return artifact ? structuredClone(artifact) : undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
snapshot(): PanelEvidenceArtifact[] {
|
|
55
|
-
return [...this.latestByReviewer.values()]
|
|
56
|
-
.sort((left, right) => left.reviewerId.localeCompare(right.reviewerId))
|
|
57
|
-
.map((artifact) => structuredClone(artifact));
|
|
58
|
-
}
|
|
59
|
-
}
|