@planu/cli 8.9.0 → 8.10.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +4 -2
  3. package/dist/sdd-engine/canonical-tools.d.ts +13 -1
  4. package/dist/sdd-engine/canonical-tools.js +76 -3
  5. package/dist/sdd-engine/catalogue-presentation.d.ts +23 -0
  6. package/dist/sdd-engine/catalogue-presentation.js +123 -0
  7. package/dist/sdd-engine/completion-snapshot.d.ts +2 -1
  8. package/dist/sdd-engine/completion-snapshot.js +81 -23
  9. package/dist/sdd-engine/contracts.d.ts +1 -1
  10. package/dist/sdd-engine/contracts.js +4 -1
  11. package/dist/sdd-engine/feature-authority.d.ts +3 -2
  12. package/dist/sdd-engine/feature-authority.js +29 -1
  13. package/dist/sdd-engine/host-rule-pack.js +12 -2
  14. package/dist/sdd-engine/source-descriptor.d.ts +2 -2
  15. package/dist/sdd-engine/source-descriptor.js +38 -14
  16. package/dist/sdd-engine/tools/feature-store.d.ts +6 -6
  17. package/dist/sdd-engine/tools/feature-store.js +188 -84
  18. package/dist/sdd-engine/tools/workspace-tools.d.ts +1 -1
  19. package/dist/sdd-engine/tools/workspace-tools.js +43 -34
  20. package/dist/sdd-engine/workspace-init.d.ts +6 -0
  21. package/dist/sdd-engine/workspace-init.js +92 -2
  22. package/dist/sdd-engine/workspace-root.d.ts +3 -3
  23. package/dist/sdd-engine/workspace-root.js +23 -5
  24. package/dist/types/completion.d.ts +27 -1
  25. package/dist/types/resume-views.d.ts +15 -1
  26. package/dist/types/sdd-engine.d.ts +12 -1
  27. package/package.json +2 -2
  28. package/templates/AGENTS.md +2 -0
  29. package/templates/host/planu-sdd.md +2 -0
  30. package/templates/skills/preflight-guardian.md +2 -0
  31. package/templates/skills/spec-executor.md +2 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [8.10.0] - 2026-11-15
2
+
3
+ - Add an opt-in compact feature catalogue with literal ID query, status filtering and pages of 16 by default, up to 32 entries.
4
+ - Bind MAC-protected cursors to the server, request and full physical catalogue snapshot; each compact response is limited to 8,192 UTF-8 bytes. Each scan reads and revalidates all eligible inputs, with at most eight feature readers per capture stage; total I/O is not bounded.
5
+ - Preserve the legacy default and nine tools. Read-only recovery observations and cursors grant no permission, retry authority or verification time; uncertain guards remain for operator review.
6
+ - Planning and file operations remain available on Windows; automated server verification requires macOS or Linux and fails closed on Windows. Native Windows execution remains unvalidated.
7
+
1
8
  ## [8.9.0]
2
9
 
3
10
  - Add an opt-in bounded source view with strict UTF-8 and a cursor bound to the server, request and physical snapshot.
package/README.md CHANGED
@@ -144,6 +144,8 @@ The reviewed operator procedure is in the repository guide `docs/verification-bu
144
144
 
145
145
  ## Read-only diagnostics
146
146
 
147
+ For an opt-in feature catalogue, first require `engineCapabilities.version=1`, `views.sdd_list_features` containing `catalogue`, and `observations.featureCatalogue=1` in setup diagnostics. Request `view="catalogue"` and follow each non-null `nextCursor` on the same server, repeating query, status and page size. Each compact response is at most 8192 UTF-8 bytes and each capture stage runs at most eight feature readers concurrently; a complete scan still reads all eligible inputs, so total I/O is not bounded. The cursor grants no permission or certification.
148
+
147
149
  For an opt-in bounded source read, first require `engineCapabilities.version=1`, `views.sdd_read_file_slice` containing `bounded`, and `observations.sourceSlice=1` in setup diagnostics. Treat absent or unknown versions or capability values as unsupported; never probe a mutation. Request `sdd_read_file_slice` with `view="bounded"`, a path and line range, then follow each non-null `nextCursor` read-only on the same server instance with the same normalized path and range. The cursor binds the server, root, request and physical snapshot; the snapshot digest is not a checksum of file contents. The default legacy read remains unchanged.
148
150
 
149
151
  Each request reads at most 65,536 source bytes in at most 64 descriptor read calls, completes at most 200 selected lines per page and returns a compact JSON text envelope of at most 8,192 UTF-8 bytes. A continuation grants no permission, retry authority or verification time. A same-UID replacement after the last filesystem check is not transactionally excluded.
@@ -155,7 +157,7 @@ The existing nine tools expose additive diagnostics since 8.4.0; 8.5.0 adds comp
155
157
  ```json
156
158
  {
157
159
  "version": 1,
158
- "bundledVersion": "8.9.0",
160
+ "bundledVersion": "8.10.0",
159
161
  "baseline": "available",
160
162
  "catalog": "unverified",
161
163
  "issues": [{
@@ -388,7 +390,7 @@ See the [Planu Proprietary Free-Use License](LICENSE) and [planu.dev/license](ht
388
390
  "mcpServers": {
389
391
  "planu": {
390
392
  "command": "npx",
391
- "args": ["-y", "@planu/cli@8.9.0"],
393
+ "args": ["-y", "@planu/cli@8.10.0"],
392
394
  "cwd": ".",
393
395
  "env": {
394
396
  "PLANU_WORKSPACE": "."
@@ -1,5 +1,6 @@
1
- import { z } from 'zod';
1
+ import type { ListFeaturesInput, SddResult } from '../types/sdd-engine.js';
2
2
  import type { EngineCapabilitiesV1 } from '../types/resume-views.js';
3
+ import { z } from 'zod';
3
4
  export declare const CANONICAL_SDD_TOOL_NAMES: readonly ['sdd_init_workspace', 'sdd_list_features', 'sdd_create_feature', 'sdd_lock_spec', 'sdd_read_spec_artifact', 'sdd_read_file_slice', 'sdd_get_active_task', 'sdd_apply_file_patch', 'sdd_complete_task'];
4
5
  export declare const ENGINE_CAPABILITIES: EngineCapabilitiesV1;
5
6
  export declare const TOOL_ANNOTATIONS: Readonly<{
@@ -39,8 +40,12 @@ export declare const ListFeaturesInputSchema: z.ZodObject<{
39
40
  planning: "planning";
40
41
  }>>;
41
42
  view: z.ZodOptional<z.ZodEnum<{
43
+ catalogue: "catalogue";
42
44
  setup_diagnostics: "setup_diagnostics";
43
45
  }>>;
46
+ query: z.ZodOptional<z.ZodString>;
47
+ page_size: z.ZodOptional<z.ZodNumber>;
48
+ cursor: z.ZodOptional<z.ZodString>;
44
49
  host: z.ZodOptional<z.ZodEnum<{
45
50
  all: "all";
46
51
  claude: "claude";
@@ -56,4 +61,11 @@ export declare const ReadFileSliceInputSchema: z.ZodObject<{
56
61
  view: z.ZodOptional<z.ZodLiteral<"bounded">>;
57
62
  cursor: z.ZodOptional<z.ZodString>;
58
63
  }, z.core.$strip>;
64
+ export declare function catalogueInputFailure(): SddResult<never>;
65
+ export declare function listInputFailure(): SddResult<never>;
66
+ export declare function catalogueDispatchFailure(reason: 'cancelled' | 'catalogue_unavailable'): SddResult<never>;
67
+ export declare function boundedWorkspaceHint(parts: (string | undefined)[]): string | undefined;
68
+ export declare const LEGACY_SPECS_HINT = "Planu ignores planu/specs. Do not create SPEC-* stubs or copy a FEAT into that tree. Retire host hooks that require planu/specs/SPEC-*/spec.md; the only contract is .sdd/features/FEAT-*.";
69
+ export declare function hasCatalogueOptions(input: ListFeaturesInput): boolean;
70
+ export declare function signalIsAborted(signal: AbortSignal): boolean;
59
71
  //# sourceMappingURL=canonical-tools.d.ts.map
@@ -20,7 +20,7 @@ export const ENGINE_CAPABILITIES = Object.freeze({
20
20
  'sdd_get_active_task',
21
21
  ]),
22
22
  views: Object.freeze({
23
- sdd_list_features: Object.freeze(['setup_diagnostics']),
23
+ sdd_list_features: Object.freeze(['setup_diagnostics', 'catalogue']),
24
24
  sdd_read_file_slice: Object.freeze(['bounded']),
25
25
  sdd_get_active_task: Object.freeze([
26
26
  'verification_preflight',
@@ -35,6 +35,7 @@ export const ENGINE_CAPABILITIES = Object.freeze({
35
35
  sdd_lock_spec: Object.freeze(['lock', 'evidence_checkpoint']),
36
36
  }),
37
37
  observations: Object.freeze({
38
+ featureCatalogue: 1,
38
39
  sourceSlice: 1,
39
40
  setupDiagnostics: 1,
40
41
  verificationPreflight: 1,
@@ -48,6 +49,10 @@ export const ENGINE_CAPABILITIES = Object.freeze({
48
49
  verificationProcess: 1,
49
50
  }),
50
51
  limits: Object.freeze({
52
+ featureCataloguePageSizeDefault: 16,
53
+ featureCataloguePageSizeMax: 32,
54
+ featureCatalogueQueryBytes: 128,
55
+ featureCatalogueCursorCharacters: 1024,
51
56
  compactTextBytes: 8192,
52
57
  defaultVerificationTimeoutMs: 180000,
53
58
  sourceSliceBytes: 65536,
@@ -70,14 +75,21 @@ export const TOOL_ANNOTATIONS = Object.freeze({
70
75
  export const ListFeaturesInputSchema = z
71
76
  .object({
72
77
  status_filter: z.enum(['all', 'planning', 'executing', 'done']).optional(),
73
- view: z.enum(['setup_diagnostics'], { error: 'Invalid setup diagnostic view.' }).optional(),
78
+ view: z
79
+ .enum(['setup_diagnostics', 'catalogue'], {
80
+ error: 'Invalid setup diagnostic view.',
81
+ })
82
+ .optional(),
83
+ query: z.string().optional(),
84
+ page_size: z.number().optional(),
85
+ cursor: z.string().optional(),
74
86
  host: z
75
87
  .enum(['all', 'claude', 'cursor', 'codex', 'gemini'], {
76
88
  error: 'Invalid setup diagnostic host.',
77
89
  })
78
90
  .optional(),
79
91
  })
80
- .refine((input) => input.host === undefined || input.view === 'setup_diagnostics', {
92
+ .refine((input) => input.host === undefined || input.view !== undefined, {
81
93
  message: 'Host requires setup diagnostics view.',
82
94
  });
83
95
  export const ReadFileSliceInputSchema = z.object({
@@ -87,4 +99,65 @@ export const ReadFileSliceInputSchema = z.object({
87
99
  view: z.literal('bounded').optional(),
88
100
  cursor: z.string().optional(),
89
101
  });
102
+ export function catalogueInputFailure() {
103
+ return {
104
+ success: false,
105
+ error: {
106
+ code: 'ERR_INVALID_ARTIFACT',
107
+ message: 'Feature catalogue input is invalid.',
108
+ trigger: 'sdd_list_features',
109
+ details: { reason: 'catalogue_input_invalid', nextAction: 'fix_inputs' },
110
+ },
111
+ };
112
+ }
113
+ export function listInputFailure() {
114
+ return {
115
+ success: false,
116
+ error: {
117
+ code: 'ERR_INVALID_ARTIFACT',
118
+ message: 'Compact task read is unavailable; follow the bounded next action.',
119
+ trigger: 'sdd_list_features',
120
+ details: { reason: 'compact_input_invalid', nextAction: 'fix_inputs' },
121
+ },
122
+ };
123
+ }
124
+ export function catalogueDispatchFailure(reason) {
125
+ const cancelled = reason === 'cancelled';
126
+ return {
127
+ success: false,
128
+ error: {
129
+ code: cancelled ? 'ERR_VERIFICATION_FAILED' : 'ERR_INVALID_ARTIFACT',
130
+ message: 'Feature catalogue read is unavailable.',
131
+ trigger: 'sdd_list_features',
132
+ details: {
133
+ reason,
134
+ nextAction: cancelled ? 'retry_read' : 'inspect_artifacts',
135
+ },
136
+ },
137
+ };
138
+ }
139
+ export function boundedWorkspaceHint(parts) {
140
+ const combined = parts.filter((item) => item !== undefined).join(' ');
141
+ if (!combined) {
142
+ return undefined;
143
+ }
144
+ let bounded = '';
145
+ let bytes = 0;
146
+ for (const character of combined) {
147
+ const size = new TextEncoder().encode(character).byteLength;
148
+ if (bytes + size > 1024) {
149
+ break;
150
+ }
151
+ bounded += character;
152
+ bytes += size;
153
+ }
154
+ return bounded;
155
+ }
156
+ export const LEGACY_SPECS_HINT = 'Planu ignores planu/specs. Do not create SPEC-* stubs or copy a FEAT into that tree. Retire host hooks that require planu/specs/SPEC-*/spec.md; the only contract is .sdd/features/FEAT-*.';
157
+ export function hasCatalogueOptions(input) {
158
+ return input.query !== undefined || input.page_size !== undefined || input.cursor !== undefined;
159
+ }
160
+ export function signalIsAborted(signal) {
161
+ return signal.aborted;
162
+ }
90
163
  //# sourceMappingURL=canonical-tools.js.map
@@ -0,0 +1,23 @@
1
+ import type { CataloguePageV1, ErrorCode, FeatureSummary, ListFeaturesInput, SddFailure, SddResult } from '../types/sdd-engine.js';
2
+ import type { CatalogueCursorPayload } from '../types/resume-views.js';
3
+ import type { ReadCursorCodec } from './workspace-root.js';
4
+ import type { CatalogueError, CatalogueFileCapture, CompletionFailureReason } from '../types/completion.js';
5
+ export declare function compactCatalogueFailure(reason: CatalogueError): SddFailure;
6
+ export declare function catalogueOptions(input: ListFeaturesInput): {
7
+ query: string;
8
+ status: 'all' | 'planning' | 'executing' | 'done';
9
+ size: number;
10
+ } | null;
11
+ export declare function compactIdValid(value: string): boolean;
12
+ export declare function cataloguePage(entries: FeatureSummary[], root: string, snapshot: string, request: string, options: NonNullable<ReturnType<typeof catalogueOptions>>, cursor: CatalogueCursorPayload | null, codec: ReadCursorCodec): SddResult<{
13
+ catalogue: CataloguePageV1;
14
+ }>;
15
+ export declare class CatalogueReadError extends Error {
16
+ readonly reason: CatalogueError;
17
+ constructor(reason: CatalogueError);
18
+ }
19
+ export declare function checkCatalogueAbort(signal?: AbortSignal): void;
20
+ export declare function catalogueCursor(input: string | undefined, request: string, codec: ReadCursorCodec): CatalogueCursorPayload | null | undefined;
21
+ export declare function sameCatalogueRoot(root: string, tasks: CatalogueFileCapture, lock: CatalogueFileCapture | null): boolean;
22
+ export declare function classifyCatalogueError(category: 'catalogue' | 'guard' | 'other', reason: CatalogueError | CompletionFailureReason | undefined, code: ErrorCode | undefined, revalidation: boolean, aborted: boolean): CatalogueError;
23
+ //# sourceMappingURL=catalogue-presentation.d.ts.map
@@ -0,0 +1,123 @@
1
+ const catalogueErrors = {
2
+ catalogue_input_invalid: ['ERR_INVALID_ARTIFACT', 'fix_inputs'],
3
+ catalogue_cursor_invalid: ['ERR_INVALID_ARTIFACT', 'reread_catalogue'],
4
+ catalogue_cursor_stale: ['ERR_SPEC_DRIFT', 'reread_catalogue'],
5
+ catalogue_identifier_invalid: ['ERR_INVALID_ARTIFACT', 'inspect_artifacts'],
6
+ catalogue_response_too_large: ['ERR_INVALID_ARTIFACT', 'inspect_artifacts'],
7
+ catalogue_unavailable: ['ERR_INVALID_ARTIFACT', 'inspect_artifacts'],
8
+ catalogue_path_unsafe: ['ERR_PERMISSION_VIOLATION', 'inspect_artifacts'],
9
+ catalogue_capability_unavailable: ['ERR_PERMISSION_VIOLATION', 'use_supported_runtime'],
10
+ guard_present: ['ERR_TASK_OUT_OF_SEQUENCE', 'wait_for_guard'],
11
+ persistence_uncertain: ['ERR_VERIFICATION_FAILED', 'inspect_recovery'],
12
+ cancelled: ['ERR_VERIFICATION_FAILED', 'retry_read'],
13
+ };
14
+ export function compactCatalogueFailure(reason) {
15
+ const [code, nextAction] = catalogueErrors[reason];
16
+ return {
17
+ success: false,
18
+ error: {
19
+ code,
20
+ message: 'Feature catalogue read is unavailable.',
21
+ trigger: 'sdd_list_features',
22
+ details: { reason, nextAction },
23
+ },
24
+ };
25
+ }
26
+ function asciiFold(value) {
27
+ return value.replace(/[A-Z]/gu, (letter) => String.fromCharCode(letter.charCodeAt(0) + 32));
28
+ }
29
+ export function catalogueOptions(input) {
30
+ const { query = '', page_size: size = 16, status_filter: status = 'all' } = input;
31
+ if (input.view !== 'catalogue' ||
32
+ input.host !== undefined ||
33
+ typeof query !== 'string' ||
34
+ new TextEncoder().encode(query).byteLength > 128 ||
35
+ Array.from(query, (character) => character.charCodeAt(0)).some((code) => code < 32 || (code >= 127 && code < 160)) ||
36
+ !Number.isSafeInteger(size) ||
37
+ size < 1 ||
38
+ size > 32 ||
39
+ !['all', 'planning', 'executing', 'done'].includes(status)) {
40
+ return null;
41
+ }
42
+ return { query: asciiFold(query.trim()), status, size };
43
+ }
44
+ export function compactIdValid(value) {
45
+ return value.length <= 128 && /^[A-Z0-9_-]+$/u.test(value);
46
+ }
47
+ export function cataloguePage(entries, root, snapshot, request, options, cursor, codec) {
48
+ const matching = entries.filter((entry) => asciiFold(entry.id).includes(options.query) &&
49
+ (options.status === 'all' || entry.status === options.status));
50
+ const index = cursor ? matching.findIndex((entry) => entry.id === cursor[5]) + 1 : 0;
51
+ if (cursor && (index === 0 || index >= matching.length)) {
52
+ return compactCatalogueFailure('catalogue_cursor_invalid');
53
+ }
54
+ const page = {
55
+ version: 1,
56
+ snapshotSha256: snapshot,
57
+ total: matching.length,
58
+ offset: index,
59
+ entries: [],
60
+ nextCursor: null,
61
+ };
62
+ for (const entry of matching.slice(index, index + options.size)) {
63
+ const nextEntries = [...page.entries, entry];
64
+ const next = index + nextEntries.length < matching.length
65
+ ? codec.encode(['planu.read-cursor.v1', 'catalogue', root, request, snapshot, entry.id])
66
+ : null;
67
+ const candidate = { ...page, entries: nextEntries, nextCursor: next };
68
+ if (new TextEncoder().encode(JSON.stringify({ success: true, data: { catalogue: candidate } }))
69
+ .byteLength > 8192) {
70
+ break;
71
+ }
72
+ page.entries = nextEntries;
73
+ page.nextCursor = next;
74
+ }
75
+ if (matching.length > index && page.entries.length === 0) {
76
+ return compactCatalogueFailure('catalogue_response_too_large');
77
+ }
78
+ if (new TextEncoder().encode(JSON.stringify({ success: true, data: { catalogue: page } }))
79
+ .byteLength > 8192) {
80
+ return compactCatalogueFailure('catalogue_response_too_large');
81
+ }
82
+ return { success: true, data: { catalogue: page } };
83
+ }
84
+ export class CatalogueReadError extends Error {
85
+ reason;
86
+ constructor(reason) {
87
+ super(reason);
88
+ this.reason = reason;
89
+ }
90
+ }
91
+ export function checkCatalogueAbort(signal) {
92
+ if (signal?.aborted) {
93
+ throw new CatalogueReadError('cancelled');
94
+ }
95
+ }
96
+ export function catalogueCursor(input, request, codec) {
97
+ if (input === undefined) {
98
+ return null;
99
+ }
100
+ const decoded = codec.decode(input);
101
+ return decoded?.[1] === 'catalogue' && decoded[3] === request ? decoded : undefined;
102
+ }
103
+ export function sameCatalogueRoot(root, tasks, lock) {
104
+ return tasks.rootIdentitySha256 === root && (!lock || lock.rootIdentitySha256 === root);
105
+ }
106
+ export function classifyCatalogueError(category, reason, code, revalidation, aborted) {
107
+ if (category === 'guard' && (reason === 'persistence_uncertain' || reason === 'guard_present')) {
108
+ return reason;
109
+ }
110
+ if (aborted || reason === 'cancelled') {
111
+ return 'cancelled';
112
+ }
113
+ if (category === 'catalogue' && reason && reason !== 'contract_drift') {
114
+ return revalidation && reason !== 'catalogue_capability_unavailable'
115
+ ? 'catalogue_cursor_stale'
116
+ : reason;
117
+ }
118
+ if (revalidation || code === 'ERR_SPEC_DRIFT') {
119
+ return 'catalogue_cursor_stale';
120
+ }
121
+ return code === 'ERR_PERMISSION_VIOLATION' ? 'catalogue_path_unsafe' : 'catalogue_unavailable';
122
+ }
123
+ //# sourceMappingURL=catalogue-presentation.js.map
@@ -1,12 +1,13 @@
1
1
  import type { ScopedVerificationSnapshot } from '../types/verification.js';
2
2
  import type { CompleteTaskResult, SddResult } from '../types/sdd-engine.js';
3
- import type { CompletionSnapshot, CompletionSnapshotOptions } from '../types/completion.js';
3
+ import type { CatalogueArtifactCapture, CompletionSnapshot, CompletionSnapshotOptions } from '../types/completion.js';
4
4
  import { type CompletionLease } from './completion-guard.js';
5
5
  /** Catalogue reads need task status and lock presence, not an execution readiness card. */
6
6
  export declare function readCatalogueArtifacts(featDir: string): Promise<{
7
7
  tasksContent: string;
8
8
  locked: boolean;
9
9
  }>;
10
+ export declare function captureCatalogueArtifacts(featDir: string, workspaceRoot: string, signal?: AbortSignal): Promise<CatalogueArtifactCapture>;
10
11
  export declare function captureCompletionSnapshot(requestedFeatDir: string, options?: CompletionSnapshotOptions): Promise<CompletionSnapshot>;
11
12
  export declare function revalidateCompletionSnapshot(snapshot: CompletionSnapshot): Promise<void>;
12
13
  export declare function commitOwnedScopedTask(taskId: string, scopedSnapshot: ScopedVerificationSnapshot, output: string, signal: AbortSignal, snapshot: CompletionSnapshot, lease: CompletionLease, persist: (written: string) => Promise<SddResult<null>>): Promise<SddResult<CompleteTaskResult>>;
@@ -1,9 +1,12 @@
1
1
  import * as fs from 'node:fs/promises';
2
+ import { createHash } from 'node:crypto';
2
3
  import * as path from 'node:path';
3
4
  import { activeTaskFromContent, markTaskVerified, remainingTaskCount, summarizeEvidence, } from './task-content.js';
4
5
  import { completionFailure, taskOutOfSequence } from './task-failures.js';
5
- import { CompletionGuardError, captureDirectories, lastAuthorityDirectory, checkWritable, guardFailure, hashArtifact, readArtifact, revalidateDirectories, rewriteArtifact, sameIdentity, } from './feature-authority.js';
6
+ import { CompletionGuardError, captureDirectories, lastAuthorityDirectory, checkWritable, guardFailure, hashArtifact, readArtifact, revalidateDirectories, rewriteArtifact, sameIdentity, validateSnapshotLock, } from './feature-authority.js';
6
7
  import { assertCatalogueAvailable } from './completion-guard.js';
8
+ import { withSourceDescriptor } from './source-descriptor.js';
9
+ import { CatalogueReadError } from './catalogue-presentation.js';
7
10
  /** Catalogue reads need task status and lock presence, not an execution readiness card. */
8
11
  export async function readCatalogueArtifacts(featDir) {
9
12
  const directories = await captureDirectories(featDir);
@@ -27,6 +30,83 @@ export async function readCatalogueArtifacts(featDir) {
27
30
  await revalidateDirectories(directories);
28
31
  return { tasksContent: tasks.content, locked };
29
32
  }
33
+ function catalogueCheck(signal) {
34
+ if (signal?.aborted) {
35
+ guardFailure('cancelled', 'Catalogue read cancelled.');
36
+ }
37
+ }
38
+ async function catalogueFile(root, local, signal) {
39
+ const digest = createHash('sha256');
40
+ const decoder = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
41
+ let content = '';
42
+ const result = await withSourceDescriptor(root, local, async (context) => {
43
+ let offset = 0;
44
+ while (offset < context.snapshot.size) {
45
+ const bytes = await context.read(offset, Math.min(4096, context.snapshot.size - offset));
46
+ digest.update(bytes);
47
+ content += decoder.decode(bytes, { stream: true });
48
+ offset += bytes.byteLength;
49
+ }
50
+ content += decoder.decode();
51
+ return {
52
+ content,
53
+ rootIdentitySha256: context.snapshot.rootIdentitySha256,
54
+ rawSha256: digest.digest('hex'),
55
+ descriptor: context.snapshot.snapshotSha256,
56
+ };
57
+ }, 'catalogue', signal);
58
+ if (!result.ok) {
59
+ if (result.cause === 'capability_unavailable') {
60
+ throw new CatalogueReadError('catalogue_capability_unavailable');
61
+ }
62
+ if (result.cause === 'cancelled') {
63
+ guardFailure('cancelled', 'Catalogue read cancelled.');
64
+ }
65
+ if (result.cause === 'unstable') {
66
+ guardFailure('contract_drift', 'Catalogue file changed.', 'ERR_SPEC_DRIFT');
67
+ }
68
+ guardFailure('contract_drift', 'Catalogue file unavailable.', result.cause === 'unsafe_path' ? 'ERR_PERMISSION_VIOLATION' : 'ERR_INVALID_ARTIFACT');
69
+ }
70
+ return result.value;
71
+ }
72
+ async function catalogueLockPresent(feature) {
73
+ try {
74
+ await fs.lstat(path.join(feature, '.lock'));
75
+ return true;
76
+ }
77
+ catch (error) {
78
+ if (error.code === 'ENOENT') {
79
+ return false;
80
+ }
81
+ throw error;
82
+ }
83
+ }
84
+ export async function captureCatalogueArtifacts(featDir, workspaceRoot, signal) {
85
+ catalogueCheck(signal);
86
+ const directories = await captureDirectories(featDir, workspaceRoot);
87
+ catalogueCheck(signal);
88
+ const feature = lastAuthorityDirectory(directories);
89
+ await assertCatalogueAvailable(feature);
90
+ catalogueCheck(signal);
91
+ const local = (name) => path.relative(workspaceRoot, path.join(feature.directory, name));
92
+ const tasks = await catalogueFile(workspaceRoot, local('tasks.md'), signal);
93
+ catalogueCheck(signal);
94
+ const present = await catalogueLockPresent(feature.directory);
95
+ catalogueCheck(signal);
96
+ const lock = present ? await catalogueFile(workspaceRoot, local('.lock'), signal) : null;
97
+ catalogueCheck(signal);
98
+ await assertCatalogueAvailable(feature);
99
+ catalogueCheck(signal);
100
+ const lockAppeared = !present && (await catalogueLockPresent(feature.directory));
101
+ catalogueCheck(signal);
102
+ if (lockAppeared) {
103
+ guardFailure('contract_drift', 'Catalogue lock appeared.', 'ERR_SPEC_DRIFT');
104
+ }
105
+ catalogueCheck(signal);
106
+ await revalidateDirectories(directories);
107
+ catalogueCheck(signal);
108
+ return { directories, tasks, lock };
109
+ }
30
110
  export async function captureCompletionSnapshot(requestedFeatDir, options) {
31
111
  const directories = await captureDirectories(requestedFeatDir, options?.workspaceRoot);
32
112
  const featDir = lastAuthorityDirectory(directories).directory;
@@ -197,28 +277,6 @@ export async function persistCompletionSnapshot(lease, snapshot, writtenTasks, s
197
277
  throw error;
198
278
  }
199
279
  }
200
- function hasSnapshotHashes(value, artifacts) {
201
- if (!value || typeof value !== 'object') {
202
- return false;
203
- }
204
- const record = value;
205
- return (record.specHash === hashArtifact(artifacts['spec.md'].content) &&
206
- record.planHash === hashArtifact(artifacts['plan.md'].content) &&
207
- record.tasksHash === hashArtifact(artifacts['tasks.md'].content));
208
- }
209
- function validateSnapshotLock(artifacts, validateLock) {
210
- let lock;
211
- try {
212
- lock = JSON.parse(artifacts['.lock'].content);
213
- }
214
- catch {
215
- return guardFailure('contract_drift', 'Lock file is not valid JSON.');
216
- }
217
- if (validateLock !== false && !hasSnapshotHashes(lock, artifacts)) {
218
- guardFailure('contract_drift', 'Locked trinity hashes do not match the authoritative bytes.');
219
- }
220
- return lock;
221
- }
222
280
  async function revalidatePersistedContract(snapshot) {
223
281
  await revalidateDirectories(snapshot.directories);
224
282
  for (const name of ['spec.md', 'plan.md']) {
@@ -1,7 +1,7 @@
1
1
  export { ListFeaturesInputSchema, ReadFileSliceInputSchema } from './canonical-tools.js';
2
2
  import { z } from 'zod';
3
3
  import type { EvidenceCheckpointInput } from '../types/sdd-engine.js';
4
- export type { ArtifactType, FilePermission, ErrorCode, SddErrorDetails, SddSuccess, SddFailure, SddResult, InitWorkspaceInput, ListFeaturesInput, CreateFeatureInput, LockSpecInput, ReadSpecArtifactInput, ReadFileSliceInput, GetActiveTaskInput, ApplyFilePatchInput, CompleteTaskInput, ParsedManifest, ActiveTaskDetails, ActiveTaskResult, CompleteTaskResult, FeatureSummary, } from '../types/sdd-engine.js';
4
+ export type { ArtifactType, FilePermission, ErrorCode, SddErrorDetails, SddSuccess, SddFailure, SddResult, InitWorkspaceInput, ListFeaturesInput, CreateFeatureInput, LockSpecInput, ReadSpecArtifactInput, ReadFileSliceInput, GetActiveTaskInput, ApplyFilePatchInput, CompleteTaskInput, ParsedManifest, ActiveTaskDetails, ActiveTaskResult, CompleteTaskResult, FeatureSummary, CataloguePageV1, } from '../types/sdd-engine.js';
5
5
  export declare const FeatureIdSchema: z.ZodString;
6
6
  export declare const ArtifactTypeSchema: z.ZodEnum<{
7
7
  plan: "plan";
@@ -239,7 +239,10 @@ export const ApplyFilePatchInputSchema = z.object({
239
239
  });
240
240
  const VerificationReceiptInputSchema = z.preprocess((input, context) => {
241
241
  if (typeof input === 'object' && input !== null && Object.hasOwn(input, '__proto__')) {
242
- context.addIssue({ code: 'custom', message: 'Invalid verification receipt element.' });
242
+ context.addIssue({
243
+ code: 'custom',
244
+ message: 'Invalid verification receipt element.',
245
+ });
243
246
  return z.NEVER;
244
247
  }
245
248
  return input;
@@ -1,6 +1,6 @@
1
1
  import { type Stats } from 'node:fs';
2
- import type { ErrorCode } from '../types/sdd-engine.js';
3
- import type { CompletionFailureReason, PhysicalIdentity, ArtifactCapture, AuthorityDirectory } from '../types/completion.js';
2
+ import type { ErrorCode, SddLockFile } from '../types/sdd-engine.js';
3
+ import type { CompletionFailureReason, PhysicalIdentity, ArtifactCapture, AuthorityDirectory, CompletionSnapshot } from '../types/completion.js';
4
4
  export declare class CompletionGuardError extends Error {
5
5
  readonly reason: CompletionFailureReason;
6
6
  readonly code: ErrorCode;
@@ -19,4 +19,5 @@ export declare function isEvidencePath(value: string): boolean;
19
19
  export declare function disjointPaths(paths: readonly string[]): boolean;
20
20
  export declare function hashArtifact(content: string): string;
21
21
  export declare function lastAuthorityDirectory(directories: AuthorityDirectory[]): AuthorityDirectory;
22
+ export declare function validateSnapshotLock(artifacts: CompletionSnapshot['artifacts'], validateLock?: boolean): SddLockFile;
22
23
  //# sourceMappingURL=feature-authority.d.ts.map
@@ -30,7 +30,13 @@ function decodeArtifact(bytes) {
30
30
  }
31
31
  }
32
32
  export function physicalIdentity(stat) {
33
- return { dev: stat.dev, ino: stat.ino, mode: stat.mode, uid: stat.uid, nlink: stat.nlink };
33
+ return {
34
+ dev: stat.dev,
35
+ ino: stat.ino,
36
+ mode: stat.mode,
37
+ uid: stat.uid,
38
+ nlink: stat.nlink,
39
+ };
34
40
  }
35
41
  export function sameIdentity(left, right) {
36
42
  return (left.dev === right.dev &&
@@ -228,4 +234,26 @@ export function lastAuthorityDirectory(directories) {
228
234
  }
229
235
  return feature;
230
236
  }
237
+ function hasSnapshotHashes(value, artifacts) {
238
+ if (!value || typeof value !== 'object') {
239
+ return false;
240
+ }
241
+ const record = value;
242
+ return (record.specHash === hashArtifact(artifacts['spec.md'].content) &&
243
+ record.planHash === hashArtifact(artifacts['plan.md'].content) &&
244
+ record.tasksHash === hashArtifact(artifacts['tasks.md'].content));
245
+ }
246
+ export function validateSnapshotLock(artifacts, validateLock) {
247
+ let lock;
248
+ try {
249
+ lock = JSON.parse(artifacts['.lock'].content);
250
+ }
251
+ catch {
252
+ return guardFailure('contract_drift', 'Lock file is not valid JSON.');
253
+ }
254
+ if (validateLock !== false && !hasSnapshotHashes(lock, artifacts)) {
255
+ guardFailure('contract_drift', 'Locked trinity hashes do not match the authoritative bytes.');
256
+ }
257
+ return lock;
258
+ }
231
259
  //# sourceMappingURL=feature-authority.js.map
@@ -18,6 +18,8 @@ After the local client has registered the MCP server and the intended project is
18
18
 
19
19
  ## Read-only diagnostics
20
20
 
21
+ For an opt-in feature catalogue, first require \`engineCapabilities.version=1\`, \`views.sdd_list_features\` containing \`catalogue\`, and \`observations.featureCatalogue=1\` in setup diagnostics. Request \`view="catalogue"\` and follow each non-null \`nextCursor\` on the same server, repeating query, status and page size. Each compact response is at most 8192 UTF-8 bytes and each capture stage runs at most eight feature readers concurrently; a complete scan still reads all eligible inputs, so total I/O is not bounded. The cursor grants no permission or certification.
22
+
21
23
  For an opt-in bounded source read, first require \`engineCapabilities.version=1\`, \`views.sdd_read_file_slice\` containing \`bounded\`, and \`observations.sourceSlice=1\` in setup diagnostics. Treat an absent or unknown descriptor version or capability value as unsupported; do not probe a mutation. Use \`sdd_read_file_slice\` with \`view="bounded"\` and the required path and line range. Follow a non-null \`nextCursor\` read-only on the same server instance, repeating the same normalized path and range; the cursor is bound to that server, root, request and physical snapshot. Stop when \`nextCursor\` is null. The physical snapshot digest is not a content checksum. A same-UID replacement after the last filesystem check is not transactionally excluded. This view and its cursor grant no permission, retry authority or verification time. The default legacy read remains unchanged.
22
24
 
23
25
  Before optional views or observations, inspect setup diagnostics and require a recognized \`engineCapabilities.version=1\` and the relevant advertised value. An absent or unknown version means unsupported; never probe a mutation or fall back to lock/relock to discover support. This describes server implementation only: host catalogues remain unverified, and a host catalogue refresh is separate from restarting MCP.
@@ -183,7 +185,12 @@ async function inspectSetupDiagnostics(root, version, selectedHost, client) {
183
185
  return {
184
186
  version: 1,
185
187
  engineCapabilities: ENGINE_CAPABILITIES,
186
- server: { version, tools: CANONICAL_SDD_TOOL_NAMES, count: 9, scope: 'server_registration' },
188
+ server: {
189
+ version,
190
+ tools: CANONICAL_SDD_TOOL_NAMES,
191
+ count: 9,
192
+ scope: 'server_registration',
193
+ },
187
194
  ...clientInfo(client),
188
195
  effectiveMcpCatalogue: 'unverified',
189
196
  skillCatalogue: 'unverified',
@@ -317,7 +324,10 @@ export async function setupDiagnosticResult(server, workspace, version, args) {
317
324
  return compact.formatCompactResult(homeError);
318
325
  }
319
326
  const setupDiagnostics = await inspectSetupDiagnostics(resolved.workspaceRoot, version ?? 'unknown', (args.host ?? 'all'), server.server.getClientVersion());
320
- return compact.formatCompactResult({ success: true, data: { setupDiagnostics } });
327
+ return compact.formatCompactResult({
328
+ success: true,
329
+ data: { setupDiagnostics },
330
+ });
321
331
  }
322
332
  catch {
323
333
  const failure = compact.compactFailure('artifact_unavailable');
@@ -1,3 +1,3 @@
1
- import type { SourceDescriptorCallback, SourceDescriptorResult } from '../types/completion.js';
2
- export declare function withSourceDescriptor<T>(workspaceRoot: string, local: string, callback: SourceDescriptorCallback<T>, profile?: 'source' | number, signal?: AbortSignal): Promise<SourceDescriptorResult<T>>;
1
+ import type { DescriptorProfile, SourceDescriptorCallback, SourceDescriptorResult } from '../types/completion.js';
2
+ export declare function withSourceDescriptor<T>(workspaceRoot: string, local: string, callback: SourceDescriptorCallback<T>, profile?: DescriptorProfile, signal?: AbortSignal): Promise<SourceDescriptorResult<T>>;
3
3
  //# sourceMappingURL=source-descriptor.d.ts.map