@planu/cli 5.7.6 → 5.7.8
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 +31 -0
- package/dist/.planu-build.json +1 -1
- package/dist/config/hook-templates/planu-review-panel-trigger.sh +2 -3
- package/dist/config/skill-templates/planu-multi-teammate-review.md +7 -11
- package/dist/engine/evidence-gates/evidence-skeletons.js +3 -1
- package/dist/engine/execution/job-runtime.d.ts +7 -3
- package/dist/engine/execution/job-runtime.js +18 -6
- package/dist/engine/execution/validate-job-executor.d.ts +2 -0
- package/dist/engine/execution/validate-job-executor.js +25 -0
- package/dist/engine/readiness-checker.js +17 -6
- package/dist/engine/reconcile/propagate-mirrors.js +6 -6
- package/dist/engine/spec-format/lean-spec-generator.js +2 -2
- package/dist/engine/spec-grounding/contract.d.ts +3 -3
- package/dist/engine/spec-grounding/contract.js +23 -76
- package/dist/engine/spec-grounding/grounding-entry-parser.d.ts +5 -0
- package/dist/engine/spec-grounding/grounding-entry-parser.js +185 -0
- package/dist/storage/runtime-db.d.ts +4 -2
- package/dist/storage/runtime-db.js +50 -12
- package/dist/storage/spec-store.d.ts +2 -1
- package/dist/storage/spec-store.js +28 -3
- package/dist/tools/bump-spec-version.js +5 -5
- package/dist/tools/create-spec.js +4 -1
- package/dist/tools/init-project/skills-multi-teammate-review-writer.js +1 -1
- package/dist/tools/jobs/handlers.js +18 -11
- package/dist/tools/list-specs.js +33 -15
- package/dist/tools/multi-teammate-review.js +1 -14
- package/dist/tools/register-platform-tools/design-stack-tools.js +3 -3
- package/dist/tools/register-spec-tools/analysis-tools.js +22 -9
- package/dist/tools/register-spec-tools/core-spec-tools.js +97 -43
- package/dist/tools/schemas/output-schemas.d.ts +14 -0
- package/dist/tools/schemas/output-schemas.js +14 -0
- package/dist/tools/schemas/package-handoff-output-schema.d.ts +1 -0
- package/dist/tools/schemas/package-handoff-output-schema.js +3 -1
- package/dist/tools/schemas/validate-output-schema.d.ts +1 -0
- package/dist/tools/schemas/validate-output-schema.js +3 -1
- package/dist/tools/sync-spec-state-handler.js +92 -23
- package/dist/tools/tool-registry/core-tools.js +71 -24
- package/dist/tools/tool-registry/group-quality-compliance.js +11 -14
- package/dist/tools/tool-registry-helpers.js +6 -2
- package/dist/types/durable-job.d.ts +1 -0
- package/dist/types/spec/core.d.ts +4 -0
- package/dist/types/spec-grounding.d.ts +14 -0
- package/package.json +3 -3
- package/planu-plugin.json +1 -1
- package/dist/tools/tool-registry/deprecated-stubs.d.ts +0 -19
- package/dist/tools/tool-registry/deprecated-stubs.js +0 -65
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const GROUNDING_SOURCES = [
|
|
2
|
+
'user_input',
|
|
3
|
+
'project_evidence',
|
|
4
|
+
'documented_assumption',
|
|
5
|
+
'ungrounded_advisory',
|
|
6
|
+
];
|
|
7
|
+
const GROUNDING_CONFIDENCES = ['low', 'medium', 'high'];
|
|
8
|
+
const TECHNICAL_REFERENCE_SECTIONS = [
|
|
9
|
+
'create',
|
|
10
|
+
'modify',
|
|
11
|
+
'test',
|
|
12
|
+
];
|
|
13
|
+
export function isRecord(value) {
|
|
14
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function stringifyDiagnosticValue(value) {
|
|
17
|
+
if (typeof value === 'string') {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
return 'undefined';
|
|
22
|
+
}
|
|
23
|
+
if (value === null) {
|
|
24
|
+
return 'null';
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
27
|
+
return value.toString();
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return JSON.stringify(value);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return 'unstringifiable value';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function nonObjectEntryDiagnostic(entry, index) {
|
|
37
|
+
return {
|
|
38
|
+
identifier: `entry[${String(index)}]`,
|
|
39
|
+
field: 'entry',
|
|
40
|
+
value: stringifyDiagnosticValue(entry),
|
|
41
|
+
allowed: [],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function toGroundingSource(value) {
|
|
45
|
+
return typeof value === 'string' && GROUNDING_SOURCES.includes(value)
|
|
46
|
+
? value
|
|
47
|
+
: null;
|
|
48
|
+
}
|
|
49
|
+
function toGroundingConfidence(value) {
|
|
50
|
+
return typeof value === 'string' && GROUNDING_CONFIDENCES.includes(value)
|
|
51
|
+
? value
|
|
52
|
+
: null;
|
|
53
|
+
}
|
|
54
|
+
function toTechnicalReferenceSection(value) {
|
|
55
|
+
return typeof value === 'string' &&
|
|
56
|
+
TECHNICAL_REFERENCE_SECTIONS.includes(value)
|
|
57
|
+
? value
|
|
58
|
+
: null;
|
|
59
|
+
}
|
|
60
|
+
function toStringArrayWithDiagnostics(value, identifier) {
|
|
61
|
+
if (!Array.isArray(value)) {
|
|
62
|
+
return { evidence: [], diagnostics: [] };
|
|
63
|
+
}
|
|
64
|
+
const evidence = [];
|
|
65
|
+
const diagnostics = [];
|
|
66
|
+
for (const item of value) {
|
|
67
|
+
if (typeof item === 'string') {
|
|
68
|
+
evidence.push(item);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
diagnostics.push({
|
|
72
|
+
identifier,
|
|
73
|
+
field: 'evidence',
|
|
74
|
+
value: stringifyDiagnosticValue(item),
|
|
75
|
+
allowed: ['string'],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { evidence, diagnostics };
|
|
80
|
+
}
|
|
81
|
+
export function toCriterionGroundingRecord(entry, index) {
|
|
82
|
+
if (!isRecord(entry)) {
|
|
83
|
+
return { record: null, diagnostics: [nonObjectEntryDiagnostic(entry, index)] };
|
|
84
|
+
}
|
|
85
|
+
const text = typeof entry.text === 'string' && entry.text.length > 0 ? entry.text : null;
|
|
86
|
+
const identifier = text ?? `entry[${String(index)}]`;
|
|
87
|
+
const source = toGroundingSource(entry.source);
|
|
88
|
+
if (!source) {
|
|
89
|
+
return {
|
|
90
|
+
record: null,
|
|
91
|
+
diagnostics: [
|
|
92
|
+
{
|
|
93
|
+
identifier,
|
|
94
|
+
field: 'source',
|
|
95
|
+
value: stringifyDiagnosticValue(entry.source),
|
|
96
|
+
allowed: GROUNDING_SOURCES,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const confidence = toGroundingConfidence(entry.confidence);
|
|
102
|
+
if (!confidence) {
|
|
103
|
+
return {
|
|
104
|
+
record: null,
|
|
105
|
+
diagnostics: [
|
|
106
|
+
{
|
|
107
|
+
identifier,
|
|
108
|
+
field: 'confidence',
|
|
109
|
+
value: stringifyDiagnosticValue(entry.confidence),
|
|
110
|
+
allowed: GROUNDING_CONFIDENCES,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (!text) {
|
|
116
|
+
return {
|
|
117
|
+
record: null,
|
|
118
|
+
diagnostics: [
|
|
119
|
+
{ identifier, field: 'text', value: stringifyDiagnosticValue(entry.text), allowed: [] },
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const { evidence, diagnostics } = toStringArrayWithDiagnostics(entry.evidence, identifier);
|
|
124
|
+
return { record: { text, source, evidence, confidence }, diagnostics };
|
|
125
|
+
}
|
|
126
|
+
export function toTechnicalReferenceGroundingRecord(entry, index) {
|
|
127
|
+
if (!isRecord(entry)) {
|
|
128
|
+
return { record: null, diagnostics: [nonObjectEntryDiagnostic(entry, index)] };
|
|
129
|
+
}
|
|
130
|
+
const path = typeof entry.path === 'string' && entry.path.length > 0 ? entry.path : null;
|
|
131
|
+
const identifier = path ?? `entry[${String(index)}]`;
|
|
132
|
+
const section = toTechnicalReferenceSection(entry.section);
|
|
133
|
+
if (!section) {
|
|
134
|
+
return {
|
|
135
|
+
record: null,
|
|
136
|
+
diagnostics: [
|
|
137
|
+
{
|
|
138
|
+
identifier,
|
|
139
|
+
field: 'section',
|
|
140
|
+
value: stringifyDiagnosticValue(entry.section),
|
|
141
|
+
allowed: TECHNICAL_REFERENCE_SECTIONS,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const source = toGroundingSource(entry.source);
|
|
147
|
+
if (!source) {
|
|
148
|
+
return {
|
|
149
|
+
record: null,
|
|
150
|
+
diagnostics: [
|
|
151
|
+
{
|
|
152
|
+
identifier,
|
|
153
|
+
field: 'source',
|
|
154
|
+
value: stringifyDiagnosticValue(entry.source),
|
|
155
|
+
allowed: GROUNDING_SOURCES,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const confidence = toGroundingConfidence(entry.confidence);
|
|
161
|
+
if (!confidence) {
|
|
162
|
+
return {
|
|
163
|
+
record: null,
|
|
164
|
+
diagnostics: [
|
|
165
|
+
{
|
|
166
|
+
identifier,
|
|
167
|
+
field: 'confidence',
|
|
168
|
+
value: stringifyDiagnosticValue(entry.confidence),
|
|
169
|
+
allowed: GROUNDING_CONFIDENCES,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (!path) {
|
|
175
|
+
return {
|
|
176
|
+
record: null,
|
|
177
|
+
diagnostics: [
|
|
178
|
+
{ identifier, field: 'path', value: stringifyDiagnosticValue(entry.path), allowed: [] },
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const { evidence, diagnostics } = toStringArrayWithDiagnostics(entry.evidence, identifier);
|
|
183
|
+
return { record: { path, section, source, evidence, confidence }, diagnostics };
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=grounding-entry-parser.js.map
|
|
@@ -62,7 +62,7 @@ export interface JobLeaseInput {
|
|
|
62
62
|
readonly now?: string;
|
|
63
63
|
}
|
|
64
64
|
export interface RuntimeWorkspaceRecovery {
|
|
65
|
-
readonly schemaVersion:
|
|
65
|
+
readonly schemaVersion: 5;
|
|
66
66
|
readonly projectId: string;
|
|
67
67
|
readonly workspaceId: string;
|
|
68
68
|
readonly records: readonly RuntimeRecord[];
|
|
@@ -83,7 +83,7 @@ export declare class RuntimeDatabaseResourceExhaustedError extends Error {
|
|
|
83
83
|
/** A bounded (one connection), transactional SQLite runtime store. */
|
|
84
84
|
export declare class RuntimeDatabase implements Disposable {
|
|
85
85
|
readonly path: string;
|
|
86
|
-
readonly schemaVersion =
|
|
86
|
+
readonly schemaVersion = 5;
|
|
87
87
|
private readonly database;
|
|
88
88
|
private readonly connectionKey;
|
|
89
89
|
private closed;
|
|
@@ -135,6 +135,8 @@ export declare class RuntimeDatabase implements Disposable {
|
|
|
135
135
|
restartReceiptPublication(projectId: string, workspaceId: string, id: string, limits: ValidationReceiptCheckpointLimits): DurableJobRecord;
|
|
136
136
|
restartJobWithPayload(projectId: string, workspaceId: string, id: string, payload: unknown): DurableJobRecord;
|
|
137
137
|
cancelJob(projectId: string, workspaceId: string, id: string): DurableJobRecord;
|
|
138
|
+
private assertRestartCeiling;
|
|
139
|
+
private freshRestartDeadline;
|
|
138
140
|
private archiveCheckpointBeforeRestart;
|
|
139
141
|
recoverExpiredJobs(now?: string, projectId?: string, workspaceId?: string): number;
|
|
140
142
|
private requireLeasedJob;
|
|
@@ -4,8 +4,10 @@ import { dirname, isAbsolute, resolve } from 'node:path';
|
|
|
4
4
|
import { DatabaseSync } from 'node:sqlite';
|
|
5
5
|
import { DURABLE_JOB_STATES, } from '../types/durable-job.js';
|
|
6
6
|
import { parseValidationReceiptPendingCheckpoint, } from '../types/durable-validation.js';
|
|
7
|
+
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
8
|
+
import { getRuntimePolicy } from '../engine/runtime-policy.js';
|
|
7
9
|
export { DURABLE_JOB_STATES };
|
|
8
|
-
const CURRENT_SCHEMA_VERSION =
|
|
10
|
+
const CURRENT_SCHEMA_VERSION = 5;
|
|
9
11
|
const DEFAULT_BUSY_TIMEOUT_MS = 5_000;
|
|
10
12
|
const DEFAULT_MAX_CONNECTIONS = 4;
|
|
11
13
|
/**
|
|
@@ -38,6 +40,7 @@ const OUTBOX_ELIGIBILITY_CLAUSE = `
|
|
|
38
40
|
OR json_extract(fence.value_json, '$.nextAttemptAt')
|
|
39
41
|
NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'
|
|
40
42
|
OR json_extract(fence.value_json, '$.nextAttemptAt') <= ?)`;
|
|
43
|
+
const VALIDATE_DEADLINE_REFRESH_SQL = `CASE WHEN json_extract(payload_json, '$.kind') = 'validate' THEN json_set(payload_json, '$.deadlineAt', ?) ELSE payload_json END`;
|
|
41
44
|
const openConnections = new Map();
|
|
42
45
|
let integrityCheckedOpens = 0;
|
|
43
46
|
let integrityBypassedOpens = 0;
|
|
@@ -87,6 +90,14 @@ function stringifyJson(value) {
|
|
|
87
90
|
}
|
|
88
91
|
return serialized;
|
|
89
92
|
}
|
|
93
|
+
function withFreshValidateDeadline(payload, deadlineAt) {
|
|
94
|
+
if (!payload ||
|
|
95
|
+
typeof payload !== 'object' ||
|
|
96
|
+
payload.kind !== 'validate') {
|
|
97
|
+
return payload;
|
|
98
|
+
}
|
|
99
|
+
return { ...payload, deadlineAt };
|
|
100
|
+
}
|
|
90
101
|
/** A bounded (one connection), transactional SQLite runtime store. */
|
|
91
102
|
export class RuntimeDatabase {
|
|
92
103
|
path;
|
|
@@ -324,6 +335,15 @@ export class RuntimeDatabase {
|
|
|
324
335
|
COMMIT;
|
|
325
336
|
`);
|
|
326
337
|
}
|
|
338
|
+
const afterFencingToken = this.database.prepare('PRAGMA user_version').get();
|
|
339
|
+
if (afterFencingToken.user_version === 4) {
|
|
340
|
+
this.database.exec(`
|
|
341
|
+
BEGIN IMMEDIATE;
|
|
342
|
+
ALTER TABLE jobs ADD COLUMN restarts INTEGER NOT NULL DEFAULT 0 CHECK (restarts >= 0);
|
|
343
|
+
PRAGMA user_version = 5;
|
|
344
|
+
COMMIT;
|
|
345
|
+
`);
|
|
346
|
+
}
|
|
327
347
|
}
|
|
328
348
|
assertIntegrity() {
|
|
329
349
|
this.assertOpen();
|
|
@@ -575,21 +595,23 @@ export class RuntimeDatabase {
|
|
|
575
595
|
requireIdentifier(projectId, 'projectId');
|
|
576
596
|
requireIdentifier(workspaceId, 'workspaceId');
|
|
577
597
|
requireIdentifier(id, 'job id');
|
|
578
|
-
const now = new Date().toISOString();
|
|
579
598
|
this.transaction(() => {
|
|
580
599
|
const current = this.getJob(projectId, workspaceId, id);
|
|
581
600
|
if (!current ||
|
|
582
601
|
!['accepted', 'checkpointed', 'failed', 'dead-letter', 'cancelled', 'completed'].includes(current.state)) {
|
|
583
602
|
throw new Error('[Planu] Job is not restartable');
|
|
584
603
|
}
|
|
604
|
+
this.assertRestartCeiling(current, id);
|
|
605
|
+
const { now, deadlineAt } = this.freshRestartDeadline();
|
|
585
606
|
this.archiveCheckpointBeforeRestart(projectId, workspaceId, id, now);
|
|
586
607
|
const result = this.database
|
|
587
|
-
.prepare(`UPDATE jobs SET state = 'accepted', attempts = 0, cancel_requested = 0,
|
|
608
|
+
.prepare(`UPDATE jobs SET state = 'accepted', attempts = 0, restarts = restarts + 1, cancel_requested = 0,
|
|
588
609
|
checkpoint_json = NULL, result_json = NULL, error_message = NULL,
|
|
589
|
-
lease_owner = NULL, lease_expires_at = NULL, updated_at =
|
|
610
|
+
lease_owner = NULL, lease_expires_at = NULL, updated_at = ?,
|
|
611
|
+
payload_json = ${VALIDATE_DEADLINE_REFRESH_SQL}
|
|
590
612
|
WHERE project_id = ? AND workspace_id = ? AND id = ?
|
|
591
613
|
AND state IN ('accepted', 'checkpointed', 'failed', 'dead-letter', 'cancelled', 'completed')`)
|
|
592
|
-
.run(now, projectId, workspaceId, id);
|
|
614
|
+
.run(now, deadlineAt, projectId, workspaceId, id);
|
|
593
615
|
if (result.changes !== 1) {
|
|
594
616
|
throw new Error('[Planu] Job is not restartable');
|
|
595
617
|
}
|
|
@@ -601,7 +623,6 @@ export class RuntimeDatabase {
|
|
|
601
623
|
requireIdentifier(projectId, 'projectId');
|
|
602
624
|
requireIdentifier(workspaceId, 'workspaceId');
|
|
603
625
|
requireIdentifier(id, 'job id');
|
|
604
|
-
const now = new Date().toISOString();
|
|
605
626
|
this.transaction(() => {
|
|
606
627
|
const current = this.getJob(projectId, workspaceId, id);
|
|
607
628
|
if (!current ||
|
|
@@ -610,13 +631,16 @@ export class RuntimeDatabase {
|
|
|
610
631
|
!parseValidationReceiptPendingCheckpoint(current.checkpoint, limits)) {
|
|
611
632
|
throw new Error('[Planu] Job receipt publication is not restartable');
|
|
612
633
|
}
|
|
634
|
+
this.assertRestartCeiling(current, id);
|
|
635
|
+
const { now, deadlineAt } = this.freshRestartDeadline();
|
|
613
636
|
const changed = this.database
|
|
614
|
-
.prepare(`UPDATE jobs SET state = 'accepted', attempts = 0, cancel_requested = 0,
|
|
637
|
+
.prepare(`UPDATE jobs SET state = 'accepted', attempts = 0, restarts = restarts + 1, cancel_requested = 0,
|
|
615
638
|
result_json = NULL, error_message = NULL, lease_owner = NULL,
|
|
616
|
-
lease_expires_at = NULL, updated_at =
|
|
639
|
+
lease_expires_at = NULL, updated_at = ?,
|
|
640
|
+
payload_json = ${VALIDATE_DEADLINE_REFRESH_SQL}
|
|
617
641
|
WHERE project_id = ? AND workspace_id = ? AND id = ?
|
|
618
642
|
AND state IN ('failed', 'dead-letter') AND cancel_requested = 0`)
|
|
619
|
-
.run(now, projectId, workspaceId, id);
|
|
643
|
+
.run(now, deadlineAt, projectId, workspaceId, id);
|
|
620
644
|
if (changed.changes !== 1) {
|
|
621
645
|
throw new Error('[Planu] Job receipt publication is not restartable');
|
|
622
646
|
}
|
|
@@ -628,21 +652,22 @@ export class RuntimeDatabase {
|
|
|
628
652
|
requireIdentifier(projectId, 'projectId');
|
|
629
653
|
requireIdentifier(workspaceId, 'workspaceId');
|
|
630
654
|
requireIdentifier(id, 'job id');
|
|
631
|
-
const now = new Date().toISOString();
|
|
632
655
|
this.transaction(() => {
|
|
633
656
|
const current = this.getJob(projectId, workspaceId, id);
|
|
634
657
|
if (!current ||
|
|
635
658
|
!['failed', 'dead-letter', 'cancelled', 'completed'].includes(current.state)) {
|
|
636
659
|
throw new Error('[Planu] Job payload is not replaceable while work is active');
|
|
637
660
|
}
|
|
661
|
+
this.assertRestartCeiling(current, id);
|
|
662
|
+
const { now, deadlineAt } = this.freshRestartDeadline();
|
|
638
663
|
this.archiveCheckpointBeforeRestart(projectId, workspaceId, id, now);
|
|
639
664
|
const result = this.database
|
|
640
|
-
.prepare(`UPDATE jobs SET state = 'accepted', attempts = 0, cancel_requested = 0,
|
|
665
|
+
.prepare(`UPDATE jobs SET state = 'accepted', attempts = 0, restarts = restarts + 1, cancel_requested = 0,
|
|
641
666
|
payload_json = ?, checkpoint_json = NULL, result_json = NULL, error_message = NULL,
|
|
642
667
|
lease_owner = NULL, lease_expires_at = NULL, updated_at = ?
|
|
643
668
|
WHERE project_id = ? AND workspace_id = ? AND id = ?
|
|
644
669
|
AND state IN ('failed', 'dead-letter', 'cancelled', 'completed')`)
|
|
645
|
-
.run(stringifyJson(payload), now, projectId, workspaceId, id);
|
|
670
|
+
.run(stringifyJson(withFreshValidateDeadline(payload, deadlineAt)), now, projectId, workspaceId, id);
|
|
646
671
|
if (result.changes !== 1) {
|
|
647
672
|
throw new Error('[Planu] Job payload is not replaceable while work is active');
|
|
648
673
|
}
|
|
@@ -671,6 +696,18 @@ export class RuntimeDatabase {
|
|
|
671
696
|
.run(now, projectId, workspaceId, id);
|
|
672
697
|
return requireJobRecord(this.getJob(projectId, workspaceId, id), id);
|
|
673
698
|
}
|
|
699
|
+
assertRestartCeiling(current, id) {
|
|
700
|
+
if (current.restarts >= current.maxAttempts) {
|
|
701
|
+
throw new Error(`[Planu] Job ${id} was restarted ${String(current.restarts)} times (ceiling ${String(current.maxAttempts)}); call cancel_job and submit a fresh operation`);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
freshRestartDeadline() {
|
|
705
|
+
const nowMs = Date.now();
|
|
706
|
+
return {
|
|
707
|
+
now: new Date(nowMs).toISOString(),
|
|
708
|
+
deadlineAt: nowMs + getRuntimePolicy().validation.defaultDeadlineMs,
|
|
709
|
+
};
|
|
710
|
+
}
|
|
674
711
|
archiveCheckpointBeforeRestart(projectId, workspaceId, id, restartedAt) {
|
|
675
712
|
const current = this.getJob(projectId, workspaceId, id);
|
|
676
713
|
if (current?.checkpoint === undefined) {
|
|
@@ -1162,6 +1199,7 @@ function mapJobRow(row) {
|
|
|
1162
1199
|
error: typeof row.error_message === 'string' ? row.error_message : undefined,
|
|
1163
1200
|
attempts: Number(row.attempts),
|
|
1164
1201
|
maxAttempts: Number(row.max_attempts),
|
|
1202
|
+
restarts: Number(row.restarts),
|
|
1165
1203
|
cancelRequested: row.cancel_requested === 1,
|
|
1166
1204
|
leaseOwner: typeof row.lease_owner === 'string' ? row.lease_owner : undefined,
|
|
1167
1205
|
fencingToken: Number(row.fencing_token),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Spec, SpecStatus, SpecVersion, SpecSummary, DefinitionOfReady, DefinitionOfDone, StatusHistoryEntry, PostCommitTaskClaim } from '../types/index.js';
|
|
1
|
+
import type { Spec, SpecStatus, SpecVersion, SpecSummary, DefinitionOfReady, DefinitionOfDone, StatusHistoryEntry, PostCommitTaskClaim, SpecStoreListing } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Thrown when code tries to write `status` via `updateSpec` directly.
|
|
4
4
|
* All status transitions must go through `handleUpdateStatus` → `transitionSpec`.
|
|
@@ -34,6 +34,7 @@ export declare function discoverCanonicalSpecPath(specId: string, canonicalRoot:
|
|
|
34
34
|
* verified against the current spec.md before being returned (SPEC-1699).
|
|
35
35
|
*/
|
|
36
36
|
export declare function listSpecs(projectId: string, canonicalRoot?: string): Promise<Spec[]>;
|
|
37
|
+
export declare function listSpecsWithGhosts(projectId: string, canonicalRoot: string): Promise<SpecStoreListing>;
|
|
37
38
|
/**
|
|
38
39
|
* Run a read-modify side effect against a fresh spec snapshot while holding the
|
|
39
40
|
* same cross-process lock used by status mutations.
|
|
@@ -256,6 +256,9 @@ async function refreshSpecFromDisk(projectId, spec, canonicalRoot) {
|
|
|
256
256
|
specMdPath = await resolveVerifiedSpecPath(spec.id, spec.specPath, canonicalRoot);
|
|
257
257
|
}
|
|
258
258
|
catch (error) {
|
|
259
|
+
if (error instanceof PortablePathError && error.code === 'NOT_FOUND') {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
259
262
|
reportClassifiedDegradation('SPEC_CONTENT_DIGEST_CHECK_SKIPPED', error);
|
|
260
263
|
return spec;
|
|
261
264
|
}
|
|
@@ -264,9 +267,15 @@ async function refreshSpecFromDisk(projectId, spec, canonicalRoot) {
|
|
|
264
267
|
content = await readFile(specMdPath, 'utf-8');
|
|
265
268
|
}
|
|
266
269
|
catch (error) {
|
|
270
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
267
273
|
reportClassifiedDegradation('SPEC_CONTENT_DIGEST_CHECK_SKIPPED', error);
|
|
268
274
|
return spec;
|
|
269
275
|
}
|
|
276
|
+
if (content.length === 0) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
270
279
|
const digest = digestOf(content);
|
|
271
280
|
if (digest === spec.contentDigest) {
|
|
272
281
|
return spec;
|
|
@@ -286,11 +295,27 @@ async function refreshSpecFromDisk(projectId, spec, canonicalRoot) {
|
|
|
286
295
|
* verified against the current spec.md before being returned (SPEC-1699).
|
|
287
296
|
*/
|
|
288
297
|
export async function listSpecs(projectId, canonicalRoot) {
|
|
289
|
-
const specs = await loadAll(projectId);
|
|
290
298
|
if (canonicalRoot === undefined) {
|
|
291
|
-
return
|
|
299
|
+
return loadAll(projectId);
|
|
292
300
|
}
|
|
293
|
-
|
|
301
|
+
const { specs } = await listSpecsWithGhosts(projectId, canonicalRoot);
|
|
302
|
+
return specs;
|
|
303
|
+
}
|
|
304
|
+
export async function listSpecsWithGhosts(projectId, canonicalRoot) {
|
|
305
|
+
const specs = await loadAll(projectId);
|
|
306
|
+
const refreshed = await Promise.all(specs.map((spec) => refreshSpecFromDisk(projectId, spec, canonicalRoot)));
|
|
307
|
+
const listing = { specs: [], ghosts: [] };
|
|
308
|
+
refreshed.forEach((refreshedSpec, index) => {
|
|
309
|
+
if (refreshedSpec === null) {
|
|
310
|
+
const original = specs[index];
|
|
311
|
+
if (original) {
|
|
312
|
+
listing.ghosts.push(original);
|
|
313
|
+
}
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
listing.specs.push(refreshedSpec);
|
|
317
|
+
});
|
|
318
|
+
return listing;
|
|
294
319
|
}
|
|
295
320
|
/**
|
|
296
321
|
* Run a read-modify side effect against a fresh spec snapshot while holding the
|
|
@@ -19,14 +19,14 @@ const BumpSpecVersionSchema = {
|
|
|
19
19
|
.min(1)
|
|
20
20
|
.max(4096)
|
|
21
21
|
.optional()
|
|
22
|
-
.describe('Absolute path to the project root. Takes precedence over projectId.'),
|
|
22
|
+
.describe('Absolute path to the project root. Takes precedence over projectId. Max 4096 characters.'),
|
|
23
23
|
projectId: z
|
|
24
24
|
.string()
|
|
25
25
|
.min(1)
|
|
26
26
|
.max(500)
|
|
27
27
|
.optional()
|
|
28
|
-
.describe('Project ID (hash). Required if projectPath is not provided.'),
|
|
29
|
-
specId: SpecIdSchema.describe('Spec ID to bump, e.g. SPEC-042.'),
|
|
28
|
+
.describe('Project ID (hash). Required if projectPath is not provided. Max 500 characters.'),
|
|
29
|
+
specId: SpecIdSchema.describe('Spec ID to bump, e.g. SPEC-042. Must match pattern ^SPEC-\\d+$, max 50 characters.'),
|
|
30
30
|
kind: z
|
|
31
31
|
.enum(['patch', 'minor', 'major'])
|
|
32
32
|
.describe('Bump kind: patch (typo/format), minor (new criterion/scope expansion), major (breaking change).'),
|
|
@@ -34,13 +34,13 @@ const BumpSpecVersionSchema = {
|
|
|
34
34
|
.string()
|
|
35
35
|
.min(5)
|
|
36
36
|
.max(500)
|
|
37
|
-
.describe('Free-text reason for the bump
|
|
37
|
+
.describe('Free-text reason for the bump. Min 5, max 500 characters. Recorded in history.'),
|
|
38
38
|
by: z
|
|
39
39
|
.string()
|
|
40
40
|
.min(1)
|
|
41
41
|
.max(200)
|
|
42
42
|
.optional()
|
|
43
|
-
.describe('Actor identifier (session id, plugin id, username). Defaults to a session token.'),
|
|
43
|
+
.describe('Actor identifier (session id, plugin id, username). Defaults to a session token. Max 200 characters.'),
|
|
44
44
|
};
|
|
45
45
|
// ---------------------------------------------------------------------------
|
|
46
46
|
// Handler
|
|
@@ -1083,7 +1083,10 @@ export async function resolveGroundedVerificationCommands(projectPath, testPaths
|
|
|
1083
1083
|
if (typeof manifest.scripts?.test !== 'string' || manifest.scripts.test.trim() === '') {
|
|
1084
1084
|
return [];
|
|
1085
1085
|
}
|
|
1086
|
-
|
|
1086
|
+
const joiner = packageManager === 'npm' ? ' -- ' : ' ';
|
|
1087
|
+
return [
|
|
1088
|
+
`${packageManager} run test${joiner}${testPaths.map(quotePosixShellArgument).join(' ')}`,
|
|
1089
|
+
];
|
|
1087
1090
|
}
|
|
1088
1091
|
catch {
|
|
1089
1092
|
return [];
|
|
@@ -51,7 +51,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
53
|
import { DurableJobRuntime, publicJobCursor } from '../../engine/execution/job-runtime.js';
|
|
54
|
-
import { scheduleValidateJobExecution } from '../../engine/execution/validate-job-executor.js';
|
|
54
|
+
import { isValidateScopeActive, scheduleValidateJobExecution, } from '../../engine/execution/validate-job-executor.js';
|
|
55
55
|
import { schedulePackageHandoffJobExecution } from '../../engine/execution/package-handoff-job-executor.js';
|
|
56
56
|
import { isValidationReceiptPendingIntent, parseValidationReceiptPendingCheckpoint, } from '../../types/durable-validation.js';
|
|
57
57
|
import { redactText } from '../../security/redactor.js';
|
|
@@ -63,7 +63,11 @@ function result(payload) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
function publicJob(runtime, job) {
|
|
66
|
-
const
|
|
66
|
+
const scopeActive = isValidateScopeActive(job.projectId, job.workspaceId);
|
|
67
|
+
const sanitized = runtime.observe(job, { scopeActive });
|
|
68
|
+
if (sanitized.queue.status === 'stalled') {
|
|
69
|
+
rescheduleStalledJob(job);
|
|
70
|
+
}
|
|
67
71
|
if (job.state === 'completed') {
|
|
68
72
|
const { checkpoint: _checkpoint, error: _error, ...completed } = sanitized;
|
|
69
73
|
return completed;
|
|
@@ -75,6 +79,17 @@ function publicJob(runtime, job) {
|
|
|
75
79
|
return { ...sanitized, error: errorMessage, errorMessage };
|
|
76
80
|
}
|
|
77
81
|
const RECEIPT_PENDING_MESSAGE = '[Planu] VALIDATION_RECEIPT_PENDING action=restart_job';
|
|
82
|
+
function rescheduleStalledJob(job) {
|
|
83
|
+
const kind = job.payload && typeof job.payload === 'object'
|
|
84
|
+
? job.payload.kind
|
|
85
|
+
: undefined;
|
|
86
|
+
if (kind === 'validate') {
|
|
87
|
+
scheduleValidateJobExecution(job.projectId, job.workspaceId);
|
|
88
|
+
}
|
|
89
|
+
else if (kind === 'package-handoff') {
|
|
90
|
+
schedulePackageHandoffJobExecution(job.projectId, job.workspaceId);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
78
93
|
function checkpointLimits() {
|
|
79
94
|
const policy = getRuntimePolicy().validation;
|
|
80
95
|
return {
|
|
@@ -108,15 +123,7 @@ export function handleRestartJob(input) {
|
|
|
108
123
|
throw new Error('[Planu] Invalid validation receipt checkpoint');
|
|
109
124
|
}
|
|
110
125
|
const job = pending ? runtime.restartReceiptPublication(input) : runtime.restart(input);
|
|
111
|
-
|
|
112
|
-
? job.payload.kind
|
|
113
|
-
: undefined;
|
|
114
|
-
if (kind === 'validate') {
|
|
115
|
-
scheduleValidateJobExecution(job.projectId, job.workspaceId);
|
|
116
|
-
}
|
|
117
|
-
else if (kind === 'package-handoff') {
|
|
118
|
-
schedulePackageHandoffJobExecution(job.projectId, job.workspaceId);
|
|
119
|
-
}
|
|
126
|
+
rescheduleStalledJob(job);
|
|
120
127
|
const observation = publicJob(runtime, job);
|
|
121
128
|
return Promise.resolve(result({ schemaVersion: 1, job: observation, cursor: publicJobCursor(observation) }));
|
|
122
129
|
}
|
package/dist/tools/list-specs.js
CHANGED
|
@@ -35,6 +35,31 @@ function buildLegacyMigrationNextAction(directives) {
|
|
|
35
35
|
`legacyFiles into their targetSection, then call migrate_legacy_spec with the merged spec.md ` +
|
|
36
36
|
`body and filesToRetire.`);
|
|
37
37
|
}
|
|
38
|
+
async function loadSpecsWithGhosts(projectId, projectPath) {
|
|
39
|
+
if (projectPath) {
|
|
40
|
+
const listing = await specStore.listSpecsWithGhosts(projectId, projectPath);
|
|
41
|
+
return { allSpecs: listing.specs, ghosts: listing.ghosts, ghostDetectionSkipped: false };
|
|
42
|
+
}
|
|
43
|
+
const allSpecs = await specStore.listSpecs(projectId);
|
|
44
|
+
return { allSpecs, ghosts: [], ghostDetectionSkipped: true };
|
|
45
|
+
}
|
|
46
|
+
function filterSpecs(allSpecs, status, type) {
|
|
47
|
+
const byStatus = status
|
|
48
|
+
? allSpecs.filter((s) => s.status === status)
|
|
49
|
+
: allSpecs.filter((s) => s.status !== 'discarded');
|
|
50
|
+
return type ? byStatus.filter((s) => s.type === type) : byStatus;
|
|
51
|
+
}
|
|
52
|
+
function buildGhostReport(ghosts) {
|
|
53
|
+
return ghosts
|
|
54
|
+
.filter((g) => g.status !== 'discarded')
|
|
55
|
+
.map((g) => ({
|
|
56
|
+
id: g.id,
|
|
57
|
+
title: g.title,
|
|
58
|
+
status: g.status,
|
|
59
|
+
specPath: g.specPath,
|
|
60
|
+
nextAction: `update_status(${g.id}, discarded) with a reason, or restore spec.md from git`,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
38
63
|
/** Track which projects have been auto-discovered this session (once per project). */
|
|
39
64
|
const discoveredProjects = new Set();
|
|
40
65
|
const MAX_STRUCTURED_SPECS = 50;
|
|
@@ -124,21 +149,10 @@ export async function handleListSpecs(params) {
|
|
|
124
149
|
if (detail === 'full' && knowledge.projectPath) {
|
|
125
150
|
await collectReadOnlyProjectSignals(projectId, knowledge.projectPath, collector);
|
|
126
151
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (status) {
|
|
131
|
-
specs = specs.filter((s) => s.status === status);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
// Exclude discarded specs from default (unfiltered) results
|
|
135
|
-
specs = specs.filter((s) => s.status !== 'discarded');
|
|
136
|
-
}
|
|
137
|
-
if (type) {
|
|
138
|
-
specs = specs.filter((s) => s.type === type);
|
|
139
|
-
}
|
|
152
|
+
const { allSpecs, ghosts, ghostDetectionSkipped } = await loadSpecsWithGhosts(projectId, knowledge.projectPath);
|
|
153
|
+
const specs = filterSpecs(allSpecs, status, type);
|
|
154
|
+
const reportedGhosts = buildGhostReport(ghosts);
|
|
140
155
|
// Build summary statistics
|
|
141
|
-
const allSpecs = await specStore.listSpecs(projectId);
|
|
142
156
|
const statusCounts = {};
|
|
143
157
|
const typeCounts = {};
|
|
144
158
|
for (const s of allSpecs) {
|
|
@@ -221,11 +235,14 @@ export async function handleListSpecs(params) {
|
|
|
221
235
|
});
|
|
222
236
|
}
|
|
223
237
|
const filterApplied = Boolean(status) || Boolean(type);
|
|
224
|
-
const
|
|
238
|
+
const baseHumanSummary = filterApplied && specs.length === 0
|
|
225
239
|
? `No plans match the current filter.`
|
|
226
240
|
: filterApplied
|
|
227
241
|
? buildListSpecsSummary(specs.length, specs.reduce((acc, s) => ({ ...acc, [s.status]: (acc[s.status] ?? 0) + 1 }), {}))
|
|
228
242
|
: buildListSpecsSummary(allSpecs.length, statusCounts);
|
|
243
|
+
const humanSummary = ghostDetectionSkipped
|
|
244
|
+
? `${baseHumanSummary}\nGhost detection skipped: project path is unknown.`
|
|
245
|
+
: baseHumanSummary;
|
|
229
246
|
// SPEC-467: Detect branches and include info for LLM branch-awareness
|
|
230
247
|
let branchInfo = null;
|
|
231
248
|
if (detail === 'full' && knowledge.projectPath) {
|
|
@@ -315,6 +332,7 @@ export async function handleListSpecs(params) {
|
|
|
315
332
|
staleStatusWarnings: staleStatusWarnings.length > 0 ? staleStatusWarnings : undefined,
|
|
316
333
|
legacyMigrationDirectives: legacyMigrationDirectives.length > 0 ? legacyMigrationDirectives : undefined,
|
|
317
334
|
nextAction: legacyMigrationNextAction,
|
|
335
|
+
ghosts: reportedGhosts.length > 0 ? reportedGhosts : undefined,
|
|
318
336
|
};
|
|
319
337
|
return {
|
|
320
338
|
content: [
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
// tools/multi-teammate-review.ts — MCP tool registration for multi-teammate review (SPEC-593)
|
|
2
|
-
// NOTE (SPEC-658): registerMultiTeammateReviewTool now registers a deprecation stub.
|
|
3
|
-
// The underlying handleMultiTeammateReview logic is kept for direct import by skills/tests.
|
|
4
1
|
import { z } from 'zod';
|
|
5
|
-
// safeTracked removed — registration replaced by deprecation stub (SPEC-658)
|
|
6
2
|
import { toolResult, formatError } from './response-helpers.js';
|
|
7
|
-
import { makeDeprecationStub } from './tool-registry/deprecated-stubs.js';
|
|
8
|
-
import { registerFromEntries } from './tool-entry.js';
|
|
9
3
|
import { runReviewPanel } from '../engine/multi-teammate-review/panel-orchestrator.js';
|
|
10
4
|
import { buildModelHeader } from '../engine/model-router/subtask-model-assigner.js';
|
|
11
5
|
// ---------------------------------------------------------------------------
|
|
@@ -117,14 +111,7 @@ export async function handleMultiTeammateReview(args) {
|
|
|
117
111
|
];
|
|
118
112
|
return toolResult(outputLines.join('\n'));
|
|
119
113
|
}
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
// Tool registration (SPEC-658: replaced with deprecation stub)
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
114
|
export function registerMultiTeammateReviewTool(s) {
|
|
124
|
-
|
|
125
|
-
// The tool stays registered so callers receive a helpful message, not "unknown tool".
|
|
126
|
-
registerFromEntries(s, [
|
|
127
|
-
makeDeprecationStub('multi_teammate_review', '.claude/skills/review-and-merge.md', 'review-and-merge'),
|
|
128
|
-
]);
|
|
115
|
+
void s;
|
|
129
116
|
}
|
|
130
117
|
//# sourceMappingURL=multi-teammate-review.js.map
|