pi-daddy 0.49.4 → 0.50.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/CHANGELOG.md +56 -1
- package/README.md +218 -28
- package/dist/governance/initiative-coordinator.d.ts +58 -0
- package/dist/governance/initiative-coordinator.d.ts.map +1 -0
- package/dist/governance/initiative-coordinator.js +348 -0
- package/dist/governance/initiative-coordinator.js.map +1 -0
- package/dist/governance/initiative-effects.d.ts +20 -0
- package/dist/governance/initiative-effects.d.ts.map +1 -0
- package/dist/governance/initiative-effects.js +108 -0
- package/dist/governance/initiative-effects.js.map +1 -0
- package/dist/governance/initiative-state.d.ts +13 -0
- package/dist/governance/initiative-state.d.ts.map +1 -0
- package/dist/governance/initiative-state.js +122 -0
- package/dist/governance/initiative-state.js.map +1 -0
- package/dist/governance/operation-artifact-io.d.ts +8 -0
- package/dist/governance/operation-artifact-io.d.ts.map +1 -0
- package/dist/governance/operation-artifact-io.js +95 -0
- package/dist/governance/operation-artifact-io.js.map +1 -0
- package/dist/governance/operation-artifact-scan.d.ts +13 -0
- package/dist/governance/operation-artifact-scan.d.ts.map +1 -0
- package/dist/governance/operation-artifact-scan.js +71 -0
- package/dist/governance/operation-artifact-scan.js.map +1 -0
- package/dist/governance/operation-artifacts.d.ts +53 -0
- package/dist/governance/operation-artifacts.d.ts.map +1 -0
- package/dist/governance/operation-artifacts.js +309 -0
- package/dist/governance/operation-artifacts.js.map +1 -0
- package/dist/governance/runtime-settlement.d.ts +2 -0
- package/dist/governance/runtime-settlement.d.ts.map +1 -1
- package/dist/governance/runtime-settlement.js +26 -0
- package/dist/governance/runtime-settlement.js.map +1 -1
- package/dist/governance/workspace-acceptance.d.ts +5 -0
- package/dist/governance/workspace-acceptance.d.ts.map +1 -1
- package/dist/governance/workspace-acceptance.js +16 -0
- package/dist/governance/workspace-acceptance.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel/dashboard-observation.d.ts +76 -0
- package/dist/kernel/dashboard-observation.d.ts.map +1 -0
- package/dist/kernel/dashboard-observation.js +49 -0
- package/dist/kernel/dashboard-observation.js.map +1 -0
- package/dist/kernel/dispatch-operation.d.ts +2 -0
- package/dist/kernel/dispatch-operation.d.ts.map +1 -1
- package/dist/kernel/dispatch-operation.js.map +1 -1
- package/dist/kernel/initiative.d.ts +94 -0
- package/dist/kernel/initiative.d.ts.map +1 -0
- package/dist/kernel/initiative.js +38 -0
- package/dist/kernel/initiative.js.map +1 -0
- package/dist/kernel/operation-artifact.d.ts +49 -0
- package/dist/kernel/operation-artifact.d.ts.map +1 -0
- package/dist/kernel/operation-artifact.js +4 -0
- package/dist/kernel/operation-artifact.js.map +1 -0
- package/dist/kernel/principal-binding.d.ts +4 -0
- package/dist/kernel/principal-binding.d.ts.map +1 -0
- package/dist/kernel/principal-binding.js +94 -0
- package/dist/kernel/principal-binding.js.map +1 -0
- package/dist/kernel/project-paths.d.ts +6 -0
- package/dist/kernel/project-paths.d.ts.map +1 -1
- package/dist/kernel/project-paths.js +12 -0
- package/dist/kernel/project-paths.js.map +1 -1
- package/dist/kernel/selected-definitions.d.ts.map +1 -1
- package/dist/kernel/selected-definitions.js +5 -91
- package/dist/kernel/selected-definitions.js.map +1 -1
- package/dist/kernel/workspace-diagnostics.d.ts +24 -0
- package/dist/kernel/workspace-diagnostics.d.ts.map +1 -0
- package/dist/kernel/workspace-diagnostics.js +81 -0
- package/dist/kernel/workspace-diagnostics.js.map +1 -0
- package/dist/products/activity-storage.d.ts +2 -0
- package/dist/products/activity-storage.d.ts.map +1 -0
- package/dist/products/activity-storage.js +119 -0
- package/dist/products/activity-storage.js.map +1 -0
- package/dist/products/activity-timeline.d.ts +4 -0
- package/dist/products/activity-timeline.d.ts.map +1 -1
- package/dist/products/activity-timeline.js +12 -0
- package/dist/products/activity-timeline.js.map +1 -1
- package/dist/products/dashboard-cli.d.ts +2 -0
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +41 -9
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-display-controls.d.ts.map +1 -1
- package/dist/products/dashboard-display-controls.js +30 -0
- package/dist/products/dashboard-display-controls.js.map +1 -1
- package/dist/products/dashboard-file-cache.d.ts +10 -0
- package/dist/products/dashboard-file-cache.d.ts.map +1 -0
- package/dist/products/dashboard-file-cache.js +38 -0
- package/dist/products/dashboard-file-cache.js.map +1 -0
- package/dist/products/dashboard-panels.d.ts +6 -0
- package/dist/products/dashboard-panels.d.ts.map +1 -0
- package/dist/products/dashboard-panels.js +179 -0
- package/dist/products/dashboard-panels.js.map +1 -0
- package/dist/products/dashboard-screen.d.ts +8 -0
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +86 -15
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +16 -2
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +64 -11
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/dashboard-settings.d.ts.map +1 -1
- package/dist/products/dashboard-settings.js +4 -6
- package/dist/products/dashboard-settings.js.map +1 -1
- package/dist/products/ecosystem-versions.d.ts +1 -1
- package/dist/products/ecosystem-versions.d.ts.map +1 -1
- package/extensions/activity-timeline.ts +3 -1
- package/extensions/artifact-bridge.ts +130 -0
- package/extensions/dashboard-live.ts +63 -0
- package/extensions/dashboard-observation.ts +39 -0
- package/extensions/dashboard-session-server.ts +45 -3
- package/extensions/dashboard-sources.ts +124 -0
- package/extensions/delegation-artifacts.ts +125 -0
- package/extensions/delegation-operations.ts +100 -42
- package/extensions/ecosystem-versions.ts +12 -5
- package/extensions/grants-command.ts +34 -6
- package/extensions/grants.ts +9 -20
- package/extensions/initiative-dashboard.ts +143 -0
- package/extensions/initiative-runtime.ts +406 -0
- package/extensions/runtime-snapshot.ts +121 -2
- package/extensions/session-environment.ts +13 -1
- package/extensions/session.ts +28 -10
- package/extensions/workspace-diagnostics.ts +90 -0
- package/package.json +1 -1
- package/src/governance/initiative-coordinator.ts +400 -0
- package/src/governance/initiative-effects.ts +146 -0
- package/src/governance/initiative-state.ts +144 -0
- package/src/governance/operation-artifact-io.ts +103 -0
- package/src/governance/operation-artifact-scan.ts +77 -0
- package/src/governance/operation-artifacts.ts +363 -0
- package/src/governance/runtime-settlement.ts +28 -0
- package/src/governance/workspace-acceptance.ts +18 -0
- package/src/index.ts +13 -0
- package/src/kernel/dashboard-observation.ts +109 -0
- package/src/kernel/dispatch-operation.ts +2 -0
- package/src/kernel/initiative.ts +126 -0
- package/src/kernel/operation-artifact.ts +46 -0
- package/src/kernel/principal-binding.ts +104 -0
- package/src/kernel/project-paths.ts +16 -0
- package/src/kernel/selected-definitions.ts +5 -100
- package/src/kernel/workspace-diagnostics.ts +110 -0
- package/src/products/activity-storage.ts +128 -0
- package/src/products/activity-timeline.ts +11 -0
- package/src/products/dashboard-cli.ts +44 -9
- package/src/products/dashboard-display-controls.ts +27 -0
- package/src/products/dashboard-file-cache.ts +38 -0
- package/src/products/dashboard-panels.ts +217 -0
- package/src/products/dashboard-screen.ts +107 -17
- package/src/products/dashboard-session-client.ts +78 -14
- package/src/products/dashboard-settings.ts +4 -6
- package/src/products/ecosystem-versions.ts +2 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** Terminal-only producer observations. None of these fields confer authority or become tool input. */
|
|
2
|
+
export const DASHBOARD_SOURCE_EVENT = "pi-daddy:dashboard-source:v1";
|
|
3
|
+
export const DASHBOARD_SOURCE_LIMIT = 8;
|
|
4
|
+
export const DASHBOARD_SOURCE_BYTES = 4096;
|
|
5
|
+
export type DashboardContributionKind = "goal" | "next" | "work" | "review" | "evidence" | "status";
|
|
6
|
+
export type DashboardObservedState =
|
|
7
|
+
| "observed"
|
|
8
|
+
| "running"
|
|
9
|
+
| "dependency-wait"
|
|
10
|
+
| "approval-wait"
|
|
11
|
+
| "cancel-requested"
|
|
12
|
+
| "settled"
|
|
13
|
+
| "failed"
|
|
14
|
+
| "unknown"
|
|
15
|
+
| "unavailable";
|
|
16
|
+
export interface DashboardContribution {
|
|
17
|
+
id: string;
|
|
18
|
+
kind: DashboardContributionKind;
|
|
19
|
+
label: string;
|
|
20
|
+
state: DashboardObservedState;
|
|
21
|
+
details?: string[];
|
|
22
|
+
/** Display identity only. The terminal never dereferences or executes it. */
|
|
23
|
+
reference?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DashboardSourceUpdate {
|
|
26
|
+
sequence: number;
|
|
27
|
+
items: DashboardContribution[];
|
|
28
|
+
}
|
|
29
|
+
/** Trusted in-process registration. Callbacks are never serialized to a model or terminal client. */
|
|
30
|
+
export type DashboardSourceRegistrationReply =
|
|
31
|
+
| { version: 1; ok: false; reason: string }
|
|
32
|
+
| { version: 1; ok: true; generation: string; publish(update: DashboardSourceUpdate): boolean; close(): void };
|
|
33
|
+
export interface DashboardSourceRegistration {
|
|
34
|
+
version: 1;
|
|
35
|
+
sessionId: string;
|
|
36
|
+
cwd: string;
|
|
37
|
+
producer: string;
|
|
38
|
+
producerVersion: string;
|
|
39
|
+
reply(value: DashboardSourceRegistrationReply): void;
|
|
40
|
+
}
|
|
41
|
+
export interface DashboardSourceSnapshot extends DashboardSourceUpdate {
|
|
42
|
+
producer: string;
|
|
43
|
+
producerVersion: string;
|
|
44
|
+
generation: string;
|
|
45
|
+
observedAt: string;
|
|
46
|
+
staleAfterMs: number;
|
|
47
|
+
availability: "observed" | "closed";
|
|
48
|
+
}
|
|
49
|
+
export interface DashboardOwnerObservation {
|
|
50
|
+
version: 1;
|
|
51
|
+
sessionId: string;
|
|
52
|
+
cwd: string;
|
|
53
|
+
generation: string;
|
|
54
|
+
sequence: number;
|
|
55
|
+
observedAt: string;
|
|
56
|
+
sources: DashboardSourceSnapshot[];
|
|
57
|
+
logicalOwnerId?: string;
|
|
58
|
+
turn?: DashboardContribution;
|
|
59
|
+
activity?: DashboardContribution[];
|
|
60
|
+
artifacts?: Array<{ operationId: string; executionId: string; sha256: string }>;
|
|
61
|
+
resources: { scope: "owner-process"; sampledAt: string; rssBytes: number; hostHealth: "unknown" };
|
|
62
|
+
capture: { transcripts: boolean; diagnostics: boolean };
|
|
63
|
+
}
|
|
64
|
+
const object = (x: unknown): x is Record<string, unknown> => !!x && typeof x === "object" && !Array.isArray(x);
|
|
65
|
+
const bounded = (x: unknown, max: number): x is string => typeof x === "string" && x.length > 0 && x.length <= max;
|
|
66
|
+
export function validDashboardSourceUpdate(value: unknown): value is DashboardSourceUpdate {
|
|
67
|
+
if (
|
|
68
|
+
!object(value) ||
|
|
69
|
+
Object.keys(value).some((k) => !["sequence", "items"].includes(k)) ||
|
|
70
|
+
!Number.isSafeInteger(value.sequence) ||
|
|
71
|
+
Number(value.sequence) < 0 ||
|
|
72
|
+
!Array.isArray(value.items) ||
|
|
73
|
+
value.items.length > 8
|
|
74
|
+
)
|
|
75
|
+
return false;
|
|
76
|
+
const ids = new Set<string>();
|
|
77
|
+
for (const row of value.items) {
|
|
78
|
+
if (
|
|
79
|
+
!object(row) ||
|
|
80
|
+
Object.keys(row).some((k) => !["id", "kind", "label", "state", "details", "reference"].includes(k)) ||
|
|
81
|
+
!bounded(row.id, 160) ||
|
|
82
|
+
ids.has(row.id) ||
|
|
83
|
+
!bounded(row.label, 240) ||
|
|
84
|
+
!["goal", "next", "work", "review", "evidence", "status"].includes(String(row.kind)) ||
|
|
85
|
+
![
|
|
86
|
+
"observed",
|
|
87
|
+
"running",
|
|
88
|
+
"dependency-wait",
|
|
89
|
+
"approval-wait",
|
|
90
|
+
"cancel-requested",
|
|
91
|
+
"settled",
|
|
92
|
+
"failed",
|
|
93
|
+
"unknown",
|
|
94
|
+
"unavailable",
|
|
95
|
+
].includes(String(row.state)) ||
|
|
96
|
+
(row.reference !== undefined && !bounded(row.reference, 512)) ||
|
|
97
|
+
(row.details !== undefined &&
|
|
98
|
+
(!Array.isArray(row.details) || row.details.length > 6 || !row.details.every((x) => bounded(x, 240))))
|
|
99
|
+
)
|
|
100
|
+
return false;
|
|
101
|
+
ids.add(row.id);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
if (Buffer.byteLength(JSON.stringify(value)) > DASHBOARD_SOURCE_BYTES) return false;
|
|
105
|
+
} catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { OperationArtifactRef } from "./operation-artifact.ts";
|
|
1
2
|
/** Explicit operation identity prevents duplicate dispatch, never authorizes work or caches results. */
|
|
2
3
|
export interface OperationReference {
|
|
4
|
+
artifact?: OperationArtifactRef;
|
|
3
5
|
operationId: string;
|
|
4
6
|
executionId: string;
|
|
5
7
|
state: "admitting" | "running" | "settled" | "not-started" | "uncertain";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Cooperative local continuation identity; never a capability, task acceptance, or external-effect proof. */
|
|
2
|
+
import type { OperationArtifactOwner } from "./operation-artifact.ts";
|
|
3
|
+
export interface InitiativeTask {
|
|
4
|
+
taskId: string;
|
|
5
|
+
taskRevision: string;
|
|
6
|
+
effectScope: "local" | "external" | "unknown";
|
|
7
|
+
effectTarget?: InitiativeEffectTarget;
|
|
8
|
+
}
|
|
9
|
+
export interface InitiativeAttempt {
|
|
10
|
+
owner: OperationArtifactOwner;
|
|
11
|
+
operationId: string;
|
|
12
|
+
executionId: string;
|
|
13
|
+
requestDigest: string;
|
|
14
|
+
state: "pending" | "not-admitted";
|
|
15
|
+
effectReceipt?: InitiativeEffectReceipt;
|
|
16
|
+
}
|
|
17
|
+
export interface InitiativeTaskRecord extends InitiativeTask {
|
|
18
|
+
generation: number;
|
|
19
|
+
attempts: InitiativeAttempt[];
|
|
20
|
+
}
|
|
21
|
+
export interface InitiativeRecord {
|
|
22
|
+
version: 1;
|
|
23
|
+
initiativeId: string;
|
|
24
|
+
generation: number;
|
|
25
|
+
owner: OperationArtifactOwner;
|
|
26
|
+
state: "owned" | "released";
|
|
27
|
+
tasks: InitiativeTaskRecord[];
|
|
28
|
+
}
|
|
29
|
+
export interface InitiativeObservation {
|
|
30
|
+
status: "observed";
|
|
31
|
+
initiativeId: string;
|
|
32
|
+
taskId: string;
|
|
33
|
+
taskRevision: string;
|
|
34
|
+
ownerGeneration: number;
|
|
35
|
+
claim: "unclaimed" | "owned" | "other-owner" | "uncertain";
|
|
36
|
+
execution: "none" | "running" | "settled" | "unknown";
|
|
37
|
+
reconciliationRequired: boolean;
|
|
38
|
+
effectObservation?: InitiativeEffectObservation;
|
|
39
|
+
assertCurrent(): void | Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface InitiativeTaskIdentity {
|
|
42
|
+
initiativeId: string;
|
|
43
|
+
taskId: string;
|
|
44
|
+
taskRevision: string;
|
|
45
|
+
}
|
|
46
|
+
export const validInitiativeId = (v: unknown): v is string =>
|
|
47
|
+
typeof v === "string" && /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,255}$/.test(v);
|
|
48
|
+
export const validTaskId = validInitiativeId;
|
|
49
|
+
export const validTaskRevision = (v: unknown): v is string =>
|
|
50
|
+
typeof v === "string" && /^(?:sha256:)?[a-f0-9]{64}$/.test(v);
|
|
51
|
+
export function validInitiativeTask(v: unknown): v is InitiativeTask {
|
|
52
|
+
const t = v as InitiativeTask;
|
|
53
|
+
return (
|
|
54
|
+
!!t &&
|
|
55
|
+
validTaskId(t.taskId) &&
|
|
56
|
+
validTaskRevision(t.taskRevision) &&
|
|
57
|
+
["local", "external", "unknown"].includes(t.effectScope) &&
|
|
58
|
+
(t.effectTarget === undefined || validEffectTarget(t.effectTarget))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Exact selected canonical receipt. It records reconciliation, never task acceptance or a permission. */
|
|
63
|
+
export interface InitiativeEffectReceipt {
|
|
64
|
+
reference: string;
|
|
65
|
+
sha256: string;
|
|
66
|
+
observation?: InitiativeEffectReported;
|
|
67
|
+
}
|
|
68
|
+
export interface InitiativeEffectIdentity extends InitiativeTaskIdentity {
|
|
69
|
+
owner: OperationArtifactOwner;
|
|
70
|
+
operationId: string;
|
|
71
|
+
executionId: string;
|
|
72
|
+
effectScope: InitiativeTask["effectScope"];
|
|
73
|
+
}
|
|
74
|
+
export interface InitiativeEffectReconciliation extends InitiativeEffectIdentity {
|
|
75
|
+
receipt: InitiativeEffectReceipt;
|
|
76
|
+
}
|
|
77
|
+
export function validEffectReceipt(value: unknown): value is InitiativeEffectReceipt {
|
|
78
|
+
const r = value as InitiativeEffectReceipt;
|
|
79
|
+
return (
|
|
80
|
+
!!r &&
|
|
81
|
+
typeof r.reference === "string" &&
|
|
82
|
+
r.reference.length > 0 &&
|
|
83
|
+
r.reference.length <= 2048 &&
|
|
84
|
+
!/[\x00-\x1f\x7f]/.test(r.reference) &&
|
|
85
|
+
typeof r.sha256 === "string" &&
|
|
86
|
+
/^[a-f0-9]{64}$/.test(r.sha256) &&
|
|
87
|
+
(r.observation === undefined || validEffectReported(r.observation))
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Neutral target identity supplied by its responsible owner; Daddy does not interpret its domain. */
|
|
92
|
+
export interface InitiativeEffectTarget {
|
|
93
|
+
owner: string;
|
|
94
|
+
kind: string;
|
|
95
|
+
reference: string;
|
|
96
|
+
}
|
|
97
|
+
export interface InitiativeEffectReported {
|
|
98
|
+
target: InitiativeEffectTarget;
|
|
99
|
+
outcome: "applied" | "not-applied" | "unknown";
|
|
100
|
+
provenance: "operator-attested" | "owner-verified";
|
|
101
|
+
}
|
|
102
|
+
export interface InitiativeEffectObservation {
|
|
103
|
+
target: InitiativeEffectTarget;
|
|
104
|
+
outcome: "pending" | InitiativeEffectReported["outcome"];
|
|
105
|
+
provenance: "not-observed" | InitiativeEffectReported["provenance"];
|
|
106
|
+
receipt?: { reference: string; sha256: string };
|
|
107
|
+
attempt?: { owner: OperationArtifactOwner; operationId: string; executionId: string };
|
|
108
|
+
}
|
|
109
|
+
const displayIdentity = (v: unknown, max: number): v is string =>
|
|
110
|
+
typeof v === "string" && v.length > 0 && v.length <= max && !/[\x00-\x1f\x7f]/.test(v);
|
|
111
|
+
export function validEffectTarget(value: unknown): value is InitiativeEffectTarget {
|
|
112
|
+
const t = value as InitiativeEffectTarget;
|
|
113
|
+
return !!t && displayIdentity(t.owner, 48) && displayIdentity(t.kind, 80) && displayIdentity(t.reference, 2048);
|
|
114
|
+
}
|
|
115
|
+
export function sameEffectTarget(a?: InitiativeEffectTarget, b?: InitiativeEffectTarget) {
|
|
116
|
+
return !a || !b ? a === b : a.owner === b.owner && a.kind === b.kind && a.reference === b.reference;
|
|
117
|
+
}
|
|
118
|
+
export function validEffectReported(value: unknown): value is InitiativeEffectReported {
|
|
119
|
+
const o = value as InitiativeEffectReported;
|
|
120
|
+
return (
|
|
121
|
+
!!o &&
|
|
122
|
+
validEffectTarget(o.target) &&
|
|
123
|
+
["applied", "not-applied", "unknown"].includes(o.outcome) &&
|
|
124
|
+
["operator-attested", "owner-verified"].includes(o.provenance)
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Exact producer evidence. Retention is neither live authority nor semantic acceptance. */
|
|
2
|
+
import type { OperationReference, OperationRequest } from "./dispatch-operation.ts";
|
|
3
|
+
export const OPERATION_ARTIFACT_VERSION = 1;
|
|
4
|
+
export const MAX_OPERATION_ARTIFACT_BYTES = 4 * 1024 * 1024;
|
|
5
|
+
export const MAX_OPERATION_MANIFEST_BYTES = 64 * 1024;
|
|
6
|
+
export interface OperationArtifactOwner {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
cwd: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OperationArtifactContent {
|
|
11
|
+
path: string;
|
|
12
|
+
sha256: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
}
|
|
15
|
+
export interface OperationArtifactRef {
|
|
16
|
+
version: 1;
|
|
17
|
+
producer: "pi-daddy";
|
|
18
|
+
owner: OperationArtifactOwner;
|
|
19
|
+
operationId: string;
|
|
20
|
+
executionId: string;
|
|
21
|
+
manifest: OperationArtifactContent;
|
|
22
|
+
}
|
|
23
|
+
export interface RetainedOperationFinal {
|
|
24
|
+
state: "complete";
|
|
25
|
+
text: string;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
messageId: string;
|
|
28
|
+
leafId: string;
|
|
29
|
+
sha256: string;
|
|
30
|
+
}
|
|
31
|
+
export interface OperationArtifactManifest {
|
|
32
|
+
version: 1;
|
|
33
|
+
producer: "pi-daddy";
|
|
34
|
+
owner: OperationArtifactOwner;
|
|
35
|
+
request: OperationRequest;
|
|
36
|
+
operation: Omit<OperationReference, "artifact">;
|
|
37
|
+
observedAt: string;
|
|
38
|
+
final?: Omit<RetainedOperationFinal, "text"> & { content: OperationArtifactContent };
|
|
39
|
+
partial?: OperationArtifactContent;
|
|
40
|
+
}
|
|
41
|
+
export interface OperationArtifactOutcome {
|
|
42
|
+
operation: Omit<OperationReference, "artifact">;
|
|
43
|
+
final?: RetainedOperationFinal;
|
|
44
|
+
/** Available visible output only; never promoted to an exact native final. */
|
|
45
|
+
partial?: string;
|
|
46
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** Legacy Principal dual-definition binding. Ordinary selected inline roles do not need this adapter. */
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { realpath } from "node:fs/promises";
|
|
5
|
+
import { ceilingForDefinition, parseSkillDefinition, type SkillDefinition } from "./definitions.ts";
|
|
6
|
+
import { resolve } from "./resolve.ts";
|
|
7
|
+
import type { DefinitionSource } from "./definition-sources.ts";
|
|
8
|
+
const requiredPhases = ["plan", "build", "review", "debug", "investigate"];
|
|
9
|
+
const phases = [...requiredPhases, "test-review"];
|
|
10
|
+
const hash = (value: string) => createHash("sha256").update(value, "utf8").digest("hex");
|
|
11
|
+
const object = (x: unknown): x is Record<string, unknown> => !!x && typeof x === "object" && !Array.isArray(x);
|
|
12
|
+
const exact = (x: Record<string, unknown>, keys: string[]) =>
|
|
13
|
+
Object.keys(x).sort().join(",") === [...keys].sort().join(",");
|
|
14
|
+
export async function principalBinding(
|
|
15
|
+
path: string,
|
|
16
|
+
inline: SkillDefinition,
|
|
17
|
+
skillText: string,
|
|
18
|
+
sources: DefinitionSource[] | undefined,
|
|
19
|
+
read: (path: string, kind: DefinitionSource["kind"], sources?: DefinitionSource[]) => Promise<string>,
|
|
20
|
+
): Promise<SkillDefinition> {
|
|
21
|
+
const phase = inline.name;
|
|
22
|
+
const marked = inline.metadata?.["principal-package"] === "principal-pi-skills";
|
|
23
|
+
if (!phases.includes(phase) || path !== join(dirname(dirname(path)), phase, "SKILL.md")) {
|
|
24
|
+
if (marked) throw Error("marked Principal skill has a noncanonical phase or path");
|
|
25
|
+
return inline;
|
|
26
|
+
}
|
|
27
|
+
const root = dirname(dirname(path));
|
|
28
|
+
let packageText: string;
|
|
29
|
+
try {
|
|
30
|
+
packageText = await read(join(root, "package.json"), "package", sources);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT" && !marked) return inline;
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
const pkg: unknown = JSON.parse(packageText);
|
|
36
|
+
if (!object(pkg) || pkg.name !== "principal-pi-skills") {
|
|
37
|
+
if (marked) throw Error("marked Principal skill has missing or wrong package identity");
|
|
38
|
+
return inline;
|
|
39
|
+
}
|
|
40
|
+
const manifest: unknown = JSON.parse(await read(join(root, "principal-agents.json"), "binding-manifest", sources));
|
|
41
|
+
if (
|
|
42
|
+
!object(manifest) ||
|
|
43
|
+
!exact(manifest, ["version", "package", "bindings"]) ||
|
|
44
|
+
manifest.version !== 1 ||
|
|
45
|
+
manifest.package !== "principal-pi-skills" ||
|
|
46
|
+
!object(manifest.bindings) ||
|
|
47
|
+
!exact(manifest.bindings, Object.hasOwn(manifest.bindings, "test-review") ? phases : requiredPhases)
|
|
48
|
+
)
|
|
49
|
+
throw Error("invalid Principal binding manifest");
|
|
50
|
+
for (const name of Object.keys(manifest.bindings)) {
|
|
51
|
+
const row = manifest.bindings[name];
|
|
52
|
+
if (
|
|
53
|
+
!object(row) ||
|
|
54
|
+
!exact(row, ["skill", "agent", "skillSha256", "agentSha256"]) ||
|
|
55
|
+
row.skill !== `${name}/SKILL.md` ||
|
|
56
|
+
row.agent !== `agents/principal-${name}.md` ||
|
|
57
|
+
typeof row.skillSha256 !== "string" ||
|
|
58
|
+
!/^[a-f0-9]{64}$/.test(row.skillSha256) ||
|
|
59
|
+
typeof row.agentSha256 !== "string" ||
|
|
60
|
+
!/^[a-f0-9]{64}$/.test(row.agentSha256)
|
|
61
|
+
)
|
|
62
|
+
throw Error("invalid Principal binding row");
|
|
63
|
+
}
|
|
64
|
+
if (!Object.hasOwn(manifest.bindings, phase)) throw Error("selected Principal phase has no binding row");
|
|
65
|
+
const row = manifest.bindings[phase] as Record<string, string>;
|
|
66
|
+
const agentPath = join(root, row.agent);
|
|
67
|
+
if (
|
|
68
|
+
(await realpath(agentPath)) !== join(await realpath(root), row.agent) ||
|
|
69
|
+
(await realpath(path)) !== join(await realpath(root), row.skill)
|
|
70
|
+
)
|
|
71
|
+
throw Error("Principal binding path escaped its selected package");
|
|
72
|
+
const agentText = await read(agentPath, "delegated-agent", sources);
|
|
73
|
+
if (hash(skillText) !== row.skillSha256 || hash(agentText) !== row.agentSha256)
|
|
74
|
+
throw Error("Principal binding hash mismatch");
|
|
75
|
+
const agent = parseSkillDefinition(agentPath, agentText);
|
|
76
|
+
if (!agent) throw Error("Principal delegated definition is malformed");
|
|
77
|
+
const inlineCeiling = ceilingForDefinition(inline),
|
|
78
|
+
delegatedCeiling = ceilingForDefinition(agent);
|
|
79
|
+
if (
|
|
80
|
+
inlineCeiling.undeclared ||
|
|
81
|
+
delegatedCeiling.undeclared ||
|
|
82
|
+
inlineCeiling.patterns.length ||
|
|
83
|
+
delegatedCeiling.patterns.length
|
|
84
|
+
)
|
|
85
|
+
throw Error("Principal binding needs two declared pattern-free ceilings");
|
|
86
|
+
const ceiling = resolve({
|
|
87
|
+
requested: delegatedCeiling.capabilities,
|
|
88
|
+
parentGrant: inlineCeiling.capabilities,
|
|
89
|
+
subsumption: false,
|
|
90
|
+
}).effective;
|
|
91
|
+
const header = /^---\r?\n[\s\S]*?\r?\n---\r?\n?/.exec(agentText)!;
|
|
92
|
+
return {
|
|
93
|
+
...agent,
|
|
94
|
+
name: phase,
|
|
95
|
+
source: agentPath,
|
|
96
|
+
sourceHash: hash(agentText),
|
|
97
|
+
selectedSkillHash: hash(skillText),
|
|
98
|
+
body: agentText.slice(header[0].length),
|
|
99
|
+
allowedTools: ceiling.join(","),
|
|
100
|
+
runtimePreferences: agent.runtimePreferences ?? inline.runtimePreferences,
|
|
101
|
+
...(typeof pkg.version === "string" ? { packageVersion: pkg.version } : {}),
|
|
102
|
+
binding: Object.freeze({ package: "principal-pi-skills", phase }),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -50,6 +50,15 @@ export const PROJECT_GITIGNORE_CONTENT = `# Written by pi-daddy init. Only setti
|
|
|
50
50
|
!settings.json
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
|
+
/** Startup owns only these volatile paths. Preserve settings and unrelated project files. */
|
|
54
|
+
export const ACTIVITY_GITIGNORE_CONTENT = `# Pi Daddy volatile runtime files; settings.json remains reviewable.
|
|
55
|
+
/${PROJECT_FILES.activityTimeline}
|
|
56
|
+
/${PROJECT_FILES.activityTimeline}.lock
|
|
57
|
+
/content/
|
|
58
|
+
/${PROJECT_FILES.ledger}
|
|
59
|
+
/${PROJECT_FILES.ledger}.lock
|
|
60
|
+
`;
|
|
61
|
+
|
|
53
62
|
/** Is this path inside pi's per-project directory of any project? The private controller journals refuse such paths. */
|
|
54
63
|
export function isUnderPiProjectDir(path: string): boolean {
|
|
55
64
|
return path.split(/[\\/]/).includes(PI_PROJECT_DIR);
|
|
@@ -107,3 +116,10 @@ export const legacyUserApprovalsPath = (cwd: string, env?: NodeJS.ProcessEnv) =>
|
|
|
107
116
|
join(agentDir(env), "grants-approvals", projectFileName(cwd));
|
|
108
117
|
export const legacyProjectLedgerPath = (cwd: string) => join(piProjectDir(cwd), "grants.jsonl");
|
|
109
118
|
export const legacyGrantEnvPath = (cwd: string) => join(piProjectDir(cwd), "grants.env");
|
|
119
|
+
|
|
120
|
+
/** Private producer results, separate from optional execution diagnostics. */
|
|
121
|
+
export const operationArtifactsDir = (directory = agentDir()) =>
|
|
122
|
+
join(directory, PROJECT_STATE_DIRNAME, "operation-results");
|
|
123
|
+
|
|
124
|
+
/** One-host cooperative initiative ownership, separate from repository writer leases. */
|
|
125
|
+
export const initiativeStateDir = (directory = agentDir()) => join(directory, PROJECT_STATE_DIRNAME, "initiatives");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Selected Pi 1.0.4 resources, frozen once per extension instance. No independent resource scan. */
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import {
|
|
4
|
-
import { lstat
|
|
3
|
+
import { resolve as resolvePath } from "node:path";
|
|
4
|
+
import { lstat } from "node:fs/promises";
|
|
5
5
|
import { BoundedReadCleanupError, readBoundedBytes } from "./bounded-read.ts";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { parseSkillDefinition, type SkillDefinition } from "./definitions.ts";
|
|
7
|
+
import { principalBinding } from "./principal-binding.ts";
|
|
8
8
|
import type { DefinitionSource } from "./definition-sources.ts";
|
|
9
9
|
import type { CatalogEntry } from "./catalog.ts";
|
|
10
10
|
export interface SelectedCommand {
|
|
@@ -12,12 +12,7 @@ export interface SelectedCommand {
|
|
|
12
12
|
name: string;
|
|
13
13
|
sourceInfo?: { path?: string };
|
|
14
14
|
}
|
|
15
|
-
const requiredPhases = ["plan", "build", "review", "debug", "investigate"];
|
|
16
|
-
const phases = [...requiredPhases, "test-review"];
|
|
17
15
|
const hash = (value: string) => createHash("sha256").update(value, "utf8").digest("hex");
|
|
18
|
-
const object = (x: unknown): x is Record<string, unknown> => !!x && typeof x === "object" && !Array.isArray(x);
|
|
19
|
-
const exact = (x: Record<string, unknown>, keys: string[]) =>
|
|
20
|
-
Object.keys(x).sort().join(",") === [...keys].sort().join(",");
|
|
21
16
|
async function read(path: string, kind: DefinitionSource["kind"], sources?: DefinitionSource[]): Promise<string> {
|
|
22
17
|
if (!(await lstat(path)).isFile()) throw Error(`nonregular selected resource: ${path}`);
|
|
23
18
|
const result = await readBoundedBytes(path, { maxBytes: 1024 * 1024, timeoutMs: 3000 });
|
|
@@ -26,96 +21,6 @@ async function read(path: string, kind: DefinitionSource["kind"], sources?: Defi
|
|
|
26
21
|
sources?.push(Object.freeze({ kind, path, base64: result.bytes.toString("base64") }));
|
|
27
22
|
return text;
|
|
28
23
|
}
|
|
29
|
-
async function principalBinding(
|
|
30
|
-
path: string,
|
|
31
|
-
inline: SkillDefinition,
|
|
32
|
-
skillText: string,
|
|
33
|
-
sources?: DefinitionSource[],
|
|
34
|
-
): Promise<SkillDefinition> {
|
|
35
|
-
const phase = inline.name;
|
|
36
|
-
const marked = inline.metadata?.["principal-package"] === "principal-pi-skills";
|
|
37
|
-
if (!phases.includes(phase) || path !== join(dirname(dirname(path)), phase, "SKILL.md")) {
|
|
38
|
-
if (marked) throw Error("marked Principal skill has a noncanonical phase or path");
|
|
39
|
-
return inline;
|
|
40
|
-
}
|
|
41
|
-
const root = dirname(dirname(path));
|
|
42
|
-
let packageText: string;
|
|
43
|
-
try {
|
|
44
|
-
packageText = await read(join(root, "package.json"), "package", sources);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
if ((error as NodeJS.ErrnoException).code === "ENOENT" && !marked) return inline;
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
const pkg: unknown = JSON.parse(packageText);
|
|
50
|
-
if (!object(pkg) || pkg.name !== "principal-pi-skills") {
|
|
51
|
-
if (marked) throw Error("marked Principal skill has missing or wrong package identity");
|
|
52
|
-
return inline;
|
|
53
|
-
}
|
|
54
|
-
const manifest: unknown = JSON.parse(await read(join(root, "principal-agents.json"), "binding-manifest", sources));
|
|
55
|
-
if (
|
|
56
|
-
!object(manifest) ||
|
|
57
|
-
!exact(manifest, ["version", "package", "bindings"]) ||
|
|
58
|
-
manifest.version !== 1 ||
|
|
59
|
-
manifest.package !== "principal-pi-skills" ||
|
|
60
|
-
!object(manifest.bindings) ||
|
|
61
|
-
!exact(manifest.bindings, Object.hasOwn(manifest.bindings, "test-review") ? phases : requiredPhases)
|
|
62
|
-
)
|
|
63
|
-
throw Error("invalid Principal binding manifest");
|
|
64
|
-
for (const name of Object.keys(manifest.bindings)) {
|
|
65
|
-
const row = manifest.bindings[name];
|
|
66
|
-
if (
|
|
67
|
-
!object(row) ||
|
|
68
|
-
!exact(row, ["skill", "agent", "skillSha256", "agentSha256"]) ||
|
|
69
|
-
row.skill !== `${name}/SKILL.md` ||
|
|
70
|
-
row.agent !== `agents/principal-${name}.md` ||
|
|
71
|
-
typeof row.skillSha256 !== "string" ||
|
|
72
|
-
!/^[a-f0-9]{64}$/.test(row.skillSha256) ||
|
|
73
|
-
typeof row.agentSha256 !== "string" ||
|
|
74
|
-
!/^[a-f0-9]{64}$/.test(row.agentSha256)
|
|
75
|
-
)
|
|
76
|
-
throw Error("invalid Principal binding row");
|
|
77
|
-
}
|
|
78
|
-
if (!Object.hasOwn(manifest.bindings, phase)) throw Error("selected Principal phase has no binding row");
|
|
79
|
-
const row = manifest.bindings[phase] as Record<string, string>;
|
|
80
|
-
const agentPath = join(root, row.agent);
|
|
81
|
-
if (
|
|
82
|
-
(await realpath(agentPath)) !== join(await realpath(root), row.agent) ||
|
|
83
|
-
(await realpath(path)) !== join(await realpath(root), row.skill)
|
|
84
|
-
)
|
|
85
|
-
throw Error("Principal binding path escaped its selected package");
|
|
86
|
-
const agentText = await read(agentPath, "delegated-agent", sources);
|
|
87
|
-
if (hash(skillText) !== row.skillSha256 || hash(agentText) !== row.agentSha256)
|
|
88
|
-
throw Error("Principal binding hash mismatch");
|
|
89
|
-
const agent = parseSkillDefinition(agentPath, agentText);
|
|
90
|
-
if (!agent) throw Error("Principal delegated definition is malformed");
|
|
91
|
-
const inlineCeiling = ceilingForDefinition(inline),
|
|
92
|
-
delegatedCeiling = ceilingForDefinition(agent);
|
|
93
|
-
if (
|
|
94
|
-
inlineCeiling.undeclared ||
|
|
95
|
-
delegatedCeiling.undeclared ||
|
|
96
|
-
inlineCeiling.patterns.length ||
|
|
97
|
-
delegatedCeiling.patterns.length
|
|
98
|
-
)
|
|
99
|
-
throw Error("Principal binding needs two declared pattern-free ceilings");
|
|
100
|
-
const ceiling = resolve({
|
|
101
|
-
requested: delegatedCeiling.capabilities,
|
|
102
|
-
parentGrant: inlineCeiling.capabilities,
|
|
103
|
-
subsumption: false,
|
|
104
|
-
}).effective;
|
|
105
|
-
const header = /^---\r?\n[\s\S]*?\r?\n---\r?\n?/.exec(agentText)!;
|
|
106
|
-
return {
|
|
107
|
-
...agent,
|
|
108
|
-
name: phase,
|
|
109
|
-
source: agentPath,
|
|
110
|
-
sourceHash: hash(agentText),
|
|
111
|
-
selectedSkillHash: hash(skillText),
|
|
112
|
-
body: agentText.slice(header[0].length),
|
|
113
|
-
allowedTools: ceiling.join(","),
|
|
114
|
-
runtimePreferences: agent.runtimePreferences ?? inline.runtimePreferences,
|
|
115
|
-
...(typeof pkg.version === "string" ? { packageVersion: pkg.version } : {}),
|
|
116
|
-
binding: Object.freeze({ package: "principal-pi-skills", phase }),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
24
|
export async function selectedDefinitions(
|
|
120
25
|
commands: readonly SelectedCommand[],
|
|
121
26
|
captureSources = false,
|
|
@@ -144,7 +49,7 @@ export async function selectedDefinitions(
|
|
|
144
49
|
const text = await read(path, "selected-skill", sources);
|
|
145
50
|
const parsed = parseSkillDefinition(path, text);
|
|
146
51
|
if (!parsed || parsed.name !== name) throw Error("selected name/path does not match definition");
|
|
147
|
-
const bound = await principalBinding(path, parsed, text, sources);
|
|
52
|
+
const bound = await principalBinding(path, parsed, text, sources, read);
|
|
148
53
|
const definitionId = hash(
|
|
149
54
|
JSON.stringify({
|
|
150
55
|
name,
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Read-only routing observations. Reuse the dispatch owners; no lease, pin, acceptance or grant mutation. */
|
|
2
|
+
import { checkRoutingAuthority } from "./routing-authority.ts";
|
|
3
|
+
import { resolveWorkspace, type WorkspaceRegistryFile } from "./workspace.ts";
|
|
4
|
+
import type { Capability } from "./resolve.ts";
|
|
5
|
+
import type { WorkspacePins } from "./workspace-pin.ts";
|
|
6
|
+
import { GovernanceRefusal } from "./refusals.ts";
|
|
7
|
+
|
|
8
|
+
export interface WorkspaceRoutingObservation {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
state:
|
|
11
|
+
| "active"
|
|
12
|
+
| "pending-activation"
|
|
13
|
+
| "not-granted"
|
|
14
|
+
| "not-pinned"
|
|
15
|
+
| "not-registered"
|
|
16
|
+
| "destination-changed"
|
|
17
|
+
| "unavailable";
|
|
18
|
+
registered: boolean;
|
|
19
|
+
accepted: boolean | null;
|
|
20
|
+
capability: "held" | "missing";
|
|
21
|
+
pin: "matching" | "missing" | "moved" | "unchecked";
|
|
22
|
+
canonicalRoot?: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
recovery: string;
|
|
25
|
+
dispatchChecks: string;
|
|
26
|
+
}
|
|
27
|
+
export async function inspectWorkspaceRouting(input: {
|
|
28
|
+
workspaceId: string;
|
|
29
|
+
registry: WorkspaceRegistryFile;
|
|
30
|
+
accepted: boolean | null;
|
|
31
|
+
ownGrant: readonly Capability[];
|
|
32
|
+
pins?: WorkspacePins;
|
|
33
|
+
depth: number;
|
|
34
|
+
}): Promise<WorkspaceRoutingObservation> {
|
|
35
|
+
const { workspaceId, registry, accepted } = input;
|
|
36
|
+
const authority = checkRoutingAuthority(workspaceId, input.ownGrant);
|
|
37
|
+
const registered = Object.hasOwn(registry.workspaces, workspaceId);
|
|
38
|
+
const pinned = input.pins?.has(workspaceId) ?? false;
|
|
39
|
+
const result: WorkspaceRoutingObservation = {
|
|
40
|
+
workspaceId,
|
|
41
|
+
registered,
|
|
42
|
+
accepted,
|
|
43
|
+
capability: authority ? "missing" : "held",
|
|
44
|
+
pin: pinned ? "unchecked" : "missing",
|
|
45
|
+
state: "unavailable",
|
|
46
|
+
reason: "Routing has not been checked.",
|
|
47
|
+
recovery: "Inspect the exact registered workspace.",
|
|
48
|
+
dispatchChecks:
|
|
49
|
+
"Observed routing only; candidate, selected task/input scope, approvals, lease and native settlement " +
|
|
50
|
+
"are checked by their owners at dispatch.",
|
|
51
|
+
};
|
|
52
|
+
if (!registered)
|
|
53
|
+
return {
|
|
54
|
+
...result,
|
|
55
|
+
state: "not-registered",
|
|
56
|
+
reason: pinned
|
|
57
|
+
? "This session pinned the ID, but its registry entry has been removed."
|
|
58
|
+
: "The ID is absent from the current registry.",
|
|
59
|
+
recovery:
|
|
60
|
+
"Review the registry with the operator. A remembered or removed ID does not authorize another directory.",
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
const workspace = await resolveWorkspace(registry, workspaceId, { pins: input.pins ?? new Map() });
|
|
64
|
+
result.canonicalRoot = workspace.root;
|
|
65
|
+
result.pin = "matching";
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (!(error instanceof GovernanceRefusal)) throw error;
|
|
68
|
+
result.reason = error.message;
|
|
69
|
+
if (error.code === "WORKSPACE_NOT_AUTHORIZED" && typeof error.details?.resolved_root === "string") {
|
|
70
|
+
result.canonicalRoot = error.details.resolved_root;
|
|
71
|
+
if (pinned)
|
|
72
|
+
return {
|
|
73
|
+
...result,
|
|
74
|
+
pin: "moved",
|
|
75
|
+
state: "destination-changed",
|
|
76
|
+
recovery:
|
|
77
|
+
"The registered destination differs from this owner's pin. Review the change; reload cannot repin and no session is started automatically.",
|
|
78
|
+
};
|
|
79
|
+
result.state = accepted === true && input.depth === 0 ? "pending-activation" : "not-pinned";
|
|
80
|
+
result.recovery =
|
|
81
|
+
input.depth > 0
|
|
82
|
+
? "Ask the parent owner to select and grant the exact workspace. A descendant cannot mint its own pin."
|
|
83
|
+
: accepted === true
|
|
84
|
+
? "Already accepted, but absent from this owner's settled pin. " +
|
|
85
|
+
"Use an explicitly selected new root session after reviewing its destination; reload keeps the old pin."
|
|
86
|
+
: "Review workspace acceptance with /grants workspaces. Acceptance applies to a new root session; reload does not create pins.";
|
|
87
|
+
} else {
|
|
88
|
+
result.recovery =
|
|
89
|
+
"Correct the reported registry or Git-worktree problem. Routing requires the exact worktree root, not a subdirectory.";
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (authority)
|
|
94
|
+
return {
|
|
95
|
+
...result,
|
|
96
|
+
state: "not-granted",
|
|
97
|
+
reason: authority.reason,
|
|
98
|
+
recovery:
|
|
99
|
+
"This current grant lacks routing authority (never granted or revoked). " +
|
|
100
|
+
"The operator or parent must grant this exact ID; registration and acceptance do not grant it.",
|
|
101
|
+
};
|
|
102
|
+
if (result.pin !== "matching") return result;
|
|
103
|
+
return {
|
|
104
|
+
...result,
|
|
105
|
+
state: "active",
|
|
106
|
+
reason: "The current capability and settled destination pin match a valid registered worktree.",
|
|
107
|
+
recovery:
|
|
108
|
+
"Reuse this workspace ID for the authorized operation. Dispatch still checks its current scope and execution prerequisites.",
|
|
109
|
+
};
|
|
110
|
+
}
|