@sublang/slc 0.6.0 → 0.8.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 (79) hide show
  1. package/README.md +7 -2
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/app.js +15 -2
  4. package/dist/app.js.map +1 -1
  5. package/dist/cligent-agent.d.ts +8 -1
  6. package/dist/cligent-agent.d.ts.map +1 -1
  7. package/dist/cligent-agent.js +45 -4
  8. package/dist/cligent-agent.js.map +1 -1
  9. package/dist/compiled-execution.d.ts +44 -0
  10. package/dist/compiled-execution.d.ts.map +1 -0
  11. package/dist/compiled-execution.js +184 -0
  12. package/dist/compiled-execution.js.map +1 -0
  13. package/dist/compiled-executor.d.ts +9 -7
  14. package/dist/compiled-executor.d.ts.map +1 -1
  15. package/dist/compiled-executor.js +143 -44
  16. package/dist/compiled-executor.js.map +1 -1
  17. package/dist/config-file.d.ts +3 -0
  18. package/dist/config-file.d.ts.map +1 -1
  19. package/dist/config-file.js +22 -4
  20. package/dist/config-file.js.map +1 -1
  21. package/dist/config.d.ts +66 -15
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/config.js +115 -49
  24. package/dist/config.js.map +1 -1
  25. package/dist/entry-module.d.ts +0 -8
  26. package/dist/entry-module.d.ts.map +1 -1
  27. package/dist/entry-module.js +75 -77
  28. package/dist/entry-module.js.map +1 -1
  29. package/dist/execution.d.ts +19 -0
  30. package/dist/execution.d.ts.map +1 -1
  31. package/dist/execution.js.map +1 -1
  32. package/dist/interpreter.d.ts +18 -2
  33. package/dist/interpreter.d.ts.map +1 -1
  34. package/dist/interpreter.js +6 -0
  35. package/dist/interpreter.js.map +1 -1
  36. package/dist/link.d.ts +7 -0
  37. package/dist/link.d.ts.map +1 -1
  38. package/dist/link.js +4 -2
  39. package/dist/link.js.map +1 -1
  40. package/dist/phase-runner.d.ts +9 -2
  41. package/dist/phase-runner.d.ts.map +1 -1
  42. package/dist/phase-runner.js +3 -1
  43. package/dist/phase-runner.js.map +1 -1
  44. package/dist/pin-generate.d.ts.map +1 -1
  45. package/dist/pin-generate.js +10 -2
  46. package/dist/pin-generate.js.map +1 -1
  47. package/dist/playbook-contract.d.ts +18 -22
  48. package/dist/playbook-contract.d.ts.map +1 -1
  49. package/dist/playbook-contract.js.map +1 -1
  50. package/dist/playbook-ports.d.ts +11 -1
  51. package/dist/playbook-ports.d.ts.map +1 -1
  52. package/dist/playbook-ports.js +8 -1
  53. package/dist/playbook-ports.js.map +1 -1
  54. package/dist/reviewing-agent.d.ts +9 -2
  55. package/dist/reviewing-agent.d.ts.map +1 -1
  56. package/dist/reviewing-agent.js +232 -38
  57. package/dist/reviewing-agent.js.map +1 -1
  58. package/dist/runner.d.ts +1 -1
  59. package/dist/runner.d.ts.map +1 -1
  60. package/dist/runner.js +200 -39
  61. package/dist/runner.js.map +1 -1
  62. package/dist/runtime-contract.d.ts +17 -0
  63. package/dist/runtime-contract.d.ts.map +1 -0
  64. package/dist/runtime-contract.js +114 -0
  65. package/dist/runtime-contract.js.map +1 -0
  66. package/dist/slc.config.template.yaml +7 -2
  67. package/dist/verify-source.d.ts +61 -0
  68. package/dist/verify-source.d.ts.map +1 -0
  69. package/dist/verify-source.js +280 -0
  70. package/dist/verify-source.js.map +1 -0
  71. package/dist/verify.d.ts +70 -3
  72. package/dist/verify.d.ts.map +1 -1
  73. package/dist/verify.js +375 -86
  74. package/dist/verify.js.map +1 -1
  75. package/package.json +3 -3
  76. package/dist/host-capabilities.d.ts +0 -115
  77. package/dist/host-capabilities.d.ts.map +0 -1
  78. package/dist/host-capabilities.js +0 -507
  79. package/dist/host-capabilities.js.map +0 -1
@@ -0,0 +1,17 @@
1
+ import type { PlaybookRuntimeDeclaration } from './verify.js';
2
+ export { declaresComposedV3, describeRuntimeDeclaration, type PlaybookRuntimeDeclaration, } from './verify.js';
3
+ /** The package whose installed engine declares the compiled-execution contract. */
4
+ export declare const PLAYBOOK_PACKAGE = "@sublang/playbook";
5
+ /** The engine surface carrying `RUNTIME_ABI` and `SUPPORTED_ARTIFACT_SCHEMAS`. */
6
+ export declare const PLAYBOOK_ENGINE_SPECIFIER = "@sublang/playbook/xstate-runtime";
7
+ /**
8
+ * Reads the engine declaration of the `@sublang/playbook` package that owns
9
+ * `linkTarget`: the first package manifest above the target owns it, so a
10
+ * parent workspace manifest lends no identity to a nested local file.
11
+ *
12
+ * @returns `undefined` when no owning manifest names `@sublang/playbook`.
13
+ * @throws when the owning package cannot resolve or import its engine
14
+ * subpath, naming the package and the failure.
15
+ */
16
+ export declare function readPlaybookRuntimeDeclaration(linkTarget: string): Promise<PlaybookRuntimeDeclaration | undefined>;
17
+ //# sourceMappingURL=runtime-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-contract.d.ts","sourceRoot":"","sources":["../src/runtime-contract.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC;AAErB,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AACpD,kFAAkF;AAClF,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAE5E;;;;;;;;GAQG;AACH,wBAAsB,8BAA8B,CAClD,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAmCjD"}
@@ -0,0 +1,114 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
+ /**
4
+ * The declared engine contract behind a pin's link target (phase-execution-30,
5
+ * verification-21; DR-028).
6
+ *
7
+ * A Playbook engine self-reports its compatibility on the
8
+ * `@sublang/playbook/xstate-runtime` surface as `RUNTIME_ABI` and
9
+ * `SUPPORTED_ARTIFACT_SCHEMAS` (Playbook DR-022). {@link readPlaybookRuntimeDeclaration}
10
+ * walks from a link target to the `@sublang/playbook` package that owns it,
11
+ * resolves that package's own engine subpath, imports it, and returns the raw
12
+ * declaration together with the package's `name@version` provenance, so the
13
+ * schema-3 generation is selected by what the installed engine declares rather
14
+ * than by an exact release number. The historical exact provenance maps stay
15
+ * with their callers; this module never infers a contract from a version. The
16
+ * declaration shape and its predicates live in `verify.ts`, whose
17
+ * artifact-local copy carries the verification-only schema decision whole.
18
+ */
19
+ import { readFile, stat } from 'node:fs/promises';
20
+ import { createRequire } from 'node:module';
21
+ import { dirname, join, resolve } from 'node:path';
22
+ import { pathToFileURL } from 'node:url';
23
+ import { isAbsentPathError, messageOf } from './errors.js';
24
+ export { declaresComposedV3, describeRuntimeDeclaration, } from './verify.js';
25
+ /** The package whose installed engine declares the compiled-execution contract. */
26
+ export const PLAYBOOK_PACKAGE = '@sublang/playbook';
27
+ /** The engine surface carrying `RUNTIME_ABI` and `SUPPORTED_ARTIFACT_SCHEMAS`. */
28
+ export const PLAYBOOK_ENGINE_SPECIFIER = '@sublang/playbook/xstate-runtime';
29
+ /**
30
+ * Reads the engine declaration of the `@sublang/playbook` package that owns
31
+ * `linkTarget`: the first package manifest above the target owns it, so a
32
+ * parent workspace manifest lends no identity to a nested local file.
33
+ *
34
+ * @returns `undefined` when no owning manifest names `@sublang/playbook`.
35
+ * @throws when the owning package cannot resolve or import its engine
36
+ * subpath, naming the package and the failure.
37
+ */
38
+ export async function readPlaybookRuntimeDeclaration(linkTarget) {
39
+ const owner = await owningPlaybookPackage(linkTarget);
40
+ if (owner === undefined)
41
+ return undefined;
42
+ const provenance = `${PLAYBOOK_PACKAGE}@${owner.version}`;
43
+ let entry;
44
+ try {
45
+ // A package may reference its own `exports` by name (Node self-reference),
46
+ // so the resolution consults exactly the manifest that owns the target.
47
+ entry = createRequire(join(owner.root, 'package.json')).resolve(PLAYBOOK_ENGINE_SPECIFIER);
48
+ }
49
+ catch (error) {
50
+ throw new Error(`${provenance} at ${owner.root} does not resolve ${PLAYBOOK_ENGINE_SPECIFIER}: ${messageOf(error)}`, { cause: error });
51
+ }
52
+ let engine;
53
+ try {
54
+ engine = (await import(pathToFileURL(entry).href));
55
+ }
56
+ catch (error) {
57
+ throw new Error(`${provenance} engine ${entry} failed to import: ${messageOf(error)}`, { cause: error });
58
+ }
59
+ return {
60
+ provenance,
61
+ packageRoot: owner.root,
62
+ runtimeAbi: engine.RUNTIME_ABI,
63
+ supportedArtifactSchemas: engine.SUPPORTED_ARTIFACT_SCHEMAS,
64
+ };
65
+ }
66
+ async function owningPlaybookPackage(path) {
67
+ const absolute = resolve(path);
68
+ let cursor;
69
+ try {
70
+ cursor = (await stat(absolute)).isDirectory()
71
+ ? absolute
72
+ : dirname(absolute);
73
+ }
74
+ catch (error) {
75
+ if (!isAbsentPathError(error))
76
+ throw error;
77
+ cursor = dirname(absolute);
78
+ }
79
+ for (;;) {
80
+ const manifestPath = join(cursor, 'package.json');
81
+ let source;
82
+ try {
83
+ source = await readFile(manifestPath, 'utf8');
84
+ }
85
+ catch (error) {
86
+ if (!isAbsentPathError(error))
87
+ throw error;
88
+ }
89
+ if (source !== undefined) {
90
+ let manifest;
91
+ try {
92
+ manifest = JSON.parse(source);
93
+ }
94
+ catch {
95
+ return undefined;
96
+ }
97
+ if (typeof manifest !== 'object' ||
98
+ manifest === null ||
99
+ !('name' in manifest) ||
100
+ manifest.name !== PLAYBOOK_PACKAGE ||
101
+ !('version' in manifest) ||
102
+ typeof manifest.version !== 'string' ||
103
+ manifest.version.length === 0) {
104
+ return undefined;
105
+ }
106
+ return { root: cursor, version: manifest.version };
107
+ }
108
+ const parent = dirname(cursor);
109
+ if (parent === cursor)
110
+ return undefined;
111
+ cursor = parent;
112
+ }
113
+ }
114
+ //# sourceMappingURL=runtime-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-contract.js","sourceRoot":"","sources":["../src/runtime-contract.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;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QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,QAAiB,CAAC;YACtB,IAAI,CAAC;gBACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAY,CAAC;YAC3C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IACE,OAAO,QAAQ,KAAK,QAAQ;gBAC5B,QAAQ,KAAK,IAAI;gBACjB,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC;gBACrB,QAAQ,CAAC,IAAI,KAAK,gBAAgB;gBAClC,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC;gBACxB,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;gBACpC,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAC7B,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrD,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,MAAM,KAAK,MAAM;YAAE,OAAO,SAAS,CAAC;QACxC,MAAM,GAAG,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,13 +1,18 @@
1
1
  # slc configuration, seeded on first run (DR-015). Environment variables
2
- # SLC_AGENT / SLC_MODEL / SLC_EFFORT and matching SLC_REVIEWER_* variables,
3
- # plus SLC_STALL_TIMEOUT, override these per key (DR-006, DR-022).
2
+ # SLC_AGENT / SLC_MODEL / SLC_EFFORT / SLC_FAST_MODE and matching
3
+ # SLC_REVIEWER_* variables, plus SLC_STALL_TIMEOUT, override these per key
4
+ # (DR-006, DR-022).
4
5
  agent: claude-code
5
6
  # model: claude-opus-4-8
6
7
  # effort: high
8
+ # Fast mode is a literal request (true or false) where the agent CLI supports
9
+ # it; omit it to keep the agent CLI's default.
10
+ # fastMode: true
7
11
  # Optional independent review/fix loop; disabled until reviewerAgent is set.
8
12
  # reviewerAgent: codex
9
13
  # reviewerModel: gpt-5.3-codex
10
14
  # reviewerEffort: xhigh
15
+ # reviewerFastMode: true
11
16
  # Seconds of agent inactivity before a stalled call fails the run (DR-019);
12
17
  # 0 disables the watchdog.
13
18
  # stallTimeout: 600
@@ -0,0 +1,61 @@
1
+ /** What a Source fragment contributes to the items compiled from it. */
2
+ export type SourceFragmentKind =
3
+ /** A fenced `markdown` instruction block. */
4
+ 'instruction'
5
+ /** A blockquote whose prose relays it in quotes, markers included. */
6
+ | 'relay'
7
+ /** A plain blockquote. */
8
+ | 'prompt';
9
+ /** One prompt fragment the Source authors explicitly. */
10
+ export interface SourceFragment {
11
+ kind: SourceFragmentKind;
12
+ /** Zero-based Source line where the fragment starts. */
13
+ start: number;
14
+ /** The fragment's exact prompt lines, escapes resolved. */
15
+ lines: string[];
16
+ }
17
+ /** One required result field and its ownership annotation. */
18
+ export interface GearsResultField {
19
+ name: string;
20
+ /** True when the item's result contract makes the player's final text authoritative. */
21
+ verbatim: boolean;
22
+ }
23
+ /** One declared `Results:` entry of a GEARS item. */
24
+ export interface GearsResult {
25
+ guard: string;
26
+ description: string;
27
+ fields: GearsResultField[];
28
+ }
29
+ /** The minimal GEARS item surface the Source and relay checks read. */
30
+ export interface GearsItem {
31
+ id: string;
32
+ ordinal: number;
33
+ /** True when the item's acting sentence delegates to a prompted or relayed player. */
34
+ delegated: boolean;
35
+ /** The delegated player's name, when the acting sentence names one. */
36
+ player?: string;
37
+ /** The item's contiguous acting prompt lines, escapes resolved. */
38
+ prompt: string[];
39
+ results: GearsResult[];
40
+ }
41
+ /**
42
+ * The prompt fragments authored explicitly in one free-form Source: fenced
43
+ * `markdown` instruction blocks and blockquotes, in Source order.
44
+ *
45
+ * @throws {Error} when an instruction fence is never closed.
46
+ */
47
+ export declare function sourcePromptFragments(sourceText: string): SourceFragment[];
48
+ /** Parses the minimal GEARS item surface the Source-fidelity rules read. */
49
+ export declare function parseGearsContract(gearsText: string): GearsItem[];
50
+ /**
51
+ * The conservation findings at the Source→GEARS seam (verification-25).
52
+ *
53
+ * Returns one finding per violated rule, in rule order, and the empty array when
54
+ * the GEARS conserves its Source. A Source authoring no fragment leaves the
55
+ * invented-prompt-line rule inapplicable: plain prose deliberately leaves prompt
56
+ * wording to the compiler's judgment.
57
+ *
58
+ * @throws {Error} when the Source's instruction fence is never closed.
59
+ */
60
+ export declare function checkSourceGearsContract(sourceText: string, gearsText: string): string[];
61
+ //# sourceMappingURL=verify-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-source.d.ts","sourceRoot":"","sources":["../src/verify-source.ts"],"names":[],"mappings":"AAiCA,wEAAwE;AACxE,MAAM,MAAM,kBAAkB;AAC5B,6CAA6C;AAC3C,aAAa;AACf,sEAAsE;GACpE,OAAO;AACT,0BAA0B;GACxB,QAAQ,CAAC;AAEb,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAED,uEAAuE;AACvE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,SAAS,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAsBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CA0C1E;AAkCD,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CA0CjE;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,EAAE,CAiHV"}
@@ -0,0 +1,280 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
+ /**
4
+ * Deterministic Source→GEARS conservation checks (DR-029, verification-25).
5
+ *
6
+ * A text-to-GEARS compile must conserve every prompt fragment its Source
7
+ * authors: fenced instruction blocks and blockquotes reach the GEARS items
8
+ * verbatim and in Source order, and — once a Source authors any fragment — a
9
+ * GEARS prompt line the Source never authored is an invention. That is
10
+ * mechanically decidable, so it is decided here rather than left to a Reviewer's
11
+ * judgment (phase-execution-51).
12
+ *
13
+ * Every function is pure over the two texts: no filesystem, no definition, no
14
+ * installed engine, and no prior artifact. Semantic item partitioning, condition
15
+ * wording, and result descriptions remain the Reviewer's concern.
16
+ */
17
+ const ITEM_HEADING = /^###\s+(\S+)\s*$/;
18
+ const MARKDOWN_FENCE = /^```markdown\s*$/i;
19
+ const FENCE_END = /^```\s*$/;
20
+ const BLOCKQUOTE = /^>\s?(.*)$/;
21
+ const PLACEHOLDER = /<([A-Za-z_$#][A-Za-z0-9_$#-]*)>/g;
22
+ const RELAY_PLACEHOLDER_LINE = /^>\s+<[A-Za-z_$#][A-Za-z0-9_$#-]*>$/;
23
+ const RESULT_BULLET = /^-\s+`([A-Za-z_$][A-Za-z0-9_$]*)`:\s+(.+)$/;
24
+ // A result-field entry names one output property, optionally annotating its
25
+ // ownership; the name is captured as authored so a non-identifier is reported
26
+ // rather than skipped (text2gears.md "Result contracts").
27
+ const ANNOTATED_FIELD = /^([^\s:]+)\s*:\s*<([^>]*)>$/;
28
+ const BARE_FIELD = /^\S+$/;
29
+ const FIELD_IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
30
+ const ENGLISH_PLAYER = '[A-Z][A-Za-z0-9_-]*';
31
+ /** Resolves Markdown escaping that is Source syntax rather than prompt content. */
32
+ function normalizePromptLine(line) {
33
+ return line.replace(/\\([<>])/g, '$1');
34
+ }
35
+ /** Whether prose immediately introducing a Source blockquote makes `>` content. */
36
+ function introducesQuotedRelay(lines, start) {
37
+ const context = [];
38
+ for (let index = start - 1; index >= 0 && context.length < 4; index--) {
39
+ const line = lines[index].trim();
40
+ if (line === '')
41
+ continue;
42
+ if (line.startsWith('#') || line.startsWith('```'))
43
+ break;
44
+ context.unshift(line);
45
+ }
46
+ return /\bin quotes\s*\(`>`\)/i.test(context.join(' '));
47
+ }
48
+ /**
49
+ * The prompt fragments authored explicitly in one free-form Source: fenced
50
+ * `markdown` instruction blocks and blockquotes, in Source order.
51
+ *
52
+ * @throws {Error} when an instruction fence is never closed.
53
+ */
54
+ export function sourcePromptFragments(sourceText) {
55
+ const lines = sourceText.split('\n');
56
+ const fragments = [];
57
+ for (let index = 0; index < lines.length; index++) {
58
+ if (MARKDOWN_FENCE.test(lines[index])) {
59
+ const start = index;
60
+ const content = [];
61
+ for (index++; index < lines.length && !FENCE_END.test(lines[index]); index++) {
62
+ content.push(normalizePromptLine(lines[index]));
63
+ }
64
+ if (index >= lines.length) {
65
+ throw new Error(`unclosed markdown instruction fence at line ${start + 1}`);
66
+ }
67
+ fragments.push({ kind: 'instruction', start, lines: content });
68
+ continue;
69
+ }
70
+ if (!BLOCKQUOTE.test(lines[index]))
71
+ continue;
72
+ const start = index;
73
+ const quotedRelay = introducesQuotedRelay(lines, start);
74
+ const content = [];
75
+ while (index < lines.length) {
76
+ const match = BLOCKQUOTE.exec(lines[index]);
77
+ if (match === null)
78
+ break;
79
+ const line = normalizePromptLine(match[1]);
80
+ content.push(quotedRelay ? (line === '' ? '>' : `> ${line}`) : line);
81
+ index++;
82
+ }
83
+ index--;
84
+ fragments.push({
85
+ kind: quotedRelay ? 'relay' : 'prompt',
86
+ start,
87
+ lines: content,
88
+ });
89
+ }
90
+ return fragments.filter((fragment) => fragment.lines.length > 0);
91
+ }
92
+ /** Required result fields and their ownership annotation. */
93
+ function resultFields(description) {
94
+ const marker = description.indexOf('Output shall include');
95
+ if (marker === -1)
96
+ return [];
97
+ const fields = [];
98
+ for (const match of description.slice(marker).matchAll(/`([^`]+)`/g)) {
99
+ const span = match[1].trim();
100
+ const annotated = ANNOTATED_FIELD.exec(span);
101
+ if (annotated !== null) {
102
+ fields.push({
103
+ name: annotated[1],
104
+ verbatim: annotated[2].trim().toLowerCase() === 'verbatim final text',
105
+ });
106
+ continue;
107
+ }
108
+ // A span carrying whitespace is prose, not a bare property name.
109
+ if (BARE_FIELD.test(span))
110
+ fields.push({ name: span, verbatim: false });
111
+ }
112
+ return fields;
113
+ }
114
+ /** Player named by one delegated GEARS acting sentence. */
115
+ function actingPlayer(acting) {
116
+ const prompted = new RegExp(`\\bCaptain shall prompt\\s+(${ENGLISH_PLAYER})\\b`).exec(acting)?.[1];
117
+ if (prompted !== undefined)
118
+ return prompted;
119
+ return new RegExp(`\\bCaptain shall relay\\b.*?\\bto\\s+(${ENGLISH_PLAYER})\\b`).exec(acting)?.[1];
120
+ }
121
+ /** Parses the minimal GEARS item surface the Source-fidelity rules read. */
122
+ export function parseGearsContract(gearsText) {
123
+ const lines = gearsText.split('\n');
124
+ const starts = [];
125
+ for (let index = 0; index < lines.length; index++) {
126
+ const heading = ITEM_HEADING.exec(lines[index]);
127
+ if (heading !== null)
128
+ starts.push({ index, id: heading[1] });
129
+ }
130
+ return starts.map((start, ordinal) => {
131
+ const end = starts[ordinal + 1]?.index ?? lines.length;
132
+ const section = lines.slice(start.index + 1, end);
133
+ const firstQuote = section.findIndex((line) => BLOCKQUOTE.test(line));
134
+ const prompt = [];
135
+ let cursor = firstQuote;
136
+ while (cursor >= 0 && cursor < section.length) {
137
+ const quote = BLOCKQUOTE.exec(section[cursor]);
138
+ if (quote === null)
139
+ break;
140
+ prompt.push(normalizePromptLine(quote[1]));
141
+ cursor++;
142
+ }
143
+ const acting = section.slice(0, Math.max(firstQuote, 0)).join(' ');
144
+ const delegated = /\bCaptain shall (?:prompt\b|relay\b)/.test(acting);
145
+ const player = actingPlayer(acting);
146
+ const results = [];
147
+ for (const line of section.slice(Math.max(cursor, 0))) {
148
+ const bullet = RESULT_BULLET.exec(line);
149
+ if (bullet === null)
150
+ continue;
151
+ results.push({
152
+ guard: bullet[1],
153
+ description: bullet[2],
154
+ fields: resultFields(bullet[2]),
155
+ });
156
+ }
157
+ return {
158
+ id: start.id,
159
+ ordinal,
160
+ delegated,
161
+ ...(player === undefined ? {} : { player }),
162
+ prompt,
163
+ results,
164
+ };
165
+ });
166
+ }
167
+ /** Canonical kebab-token to camel-field mapping shared with the link phase. */
168
+ function placeholderField(token) {
169
+ if (token === '#')
170
+ return 'irNumber';
171
+ return token.replace(/-([A-Za-z0-9_$])/g, (_match, next) => next.toUpperCase());
172
+ }
173
+ /** First exact contiguous occurrence of `needle` in `haystack`. */
174
+ function fragmentIndex(haystack, needle) {
175
+ if (needle.length === 0 || needle.length > haystack.length)
176
+ return -1;
177
+ outer: for (let index = 0; index <= haystack.length - needle.length; index++) {
178
+ for (let offset = 0; offset < needle.length; offset++) {
179
+ if (haystack[index + offset] !== needle[offset])
180
+ continue outer;
181
+ }
182
+ return index;
183
+ }
184
+ return -1;
185
+ }
186
+ /**
187
+ * The conservation findings at the Source→GEARS seam (verification-25).
188
+ *
189
+ * Returns one finding per violated rule, in rule order, and the empty array when
190
+ * the GEARS conserves its Source. A Source authoring no fragment leaves the
191
+ * invented-prompt-line rule inapplicable: plain prose deliberately leaves prompt
192
+ * wording to the compiler's judgment.
193
+ *
194
+ * @throws {Error} when the Source's instruction fence is never closed.
195
+ */
196
+ export function checkSourceGearsContract(sourceText, gearsText) {
197
+ const findings = [];
198
+ const fragments = sourcePromptFragments(sourceText);
199
+ const items = parseGearsContract(gearsText);
200
+ const relayedFields = new Set(fragments
201
+ .filter((fragment) => fragment.kind === 'relay')
202
+ .flatMap((fragment) => fragment.lines.flatMap((line) => [...line.matchAll(PLACEHOLDER)].map((match) => placeholderField(match[1])))));
203
+ const authoredLines = new Set(fragments.flatMap((fragment) => fragment.lines.filter((line) => line !== '')));
204
+ for (const fragment of fragments) {
205
+ if (!items.some((item) => fragmentIndex(item.prompt, fragment.lines) >= 0)) {
206
+ findings.push(`source ${fragment.kind} fragment at line ${fragment.start + 1} was dropped or changed`);
207
+ }
208
+ }
209
+ for (const item of items) {
210
+ const matches = fragments
211
+ .map((fragment) => ({
212
+ fragment,
213
+ promptIndex: fragmentIndex(item.prompt, fragment.lines),
214
+ }))
215
+ .filter((entry) => entry.promptIndex >= 0)
216
+ .sort((left, right) => left.promptIndex - right.promptIndex);
217
+ for (let index = 1; index < matches.length; index++) {
218
+ if (matches[index - 1].fragment.start > matches[index].fragment.start) {
219
+ findings.push(`${item.id}: authored prompt fragments are out of Source order`);
220
+ break;
221
+ }
222
+ }
223
+ // A Source that authors no fragment leaves prompt wording to the compiler
224
+ // (DR-029), so the invented-line rule applies only once one exists.
225
+ if (fragments.length === 0)
226
+ continue;
227
+ for (const line of item.prompt) {
228
+ if (line === '' || authoredLines.has(line))
229
+ continue;
230
+ if (RELAY_PLACEHOLDER_LINE.test(line))
231
+ continue;
232
+ findings.push(`${item.id}: prompt line is not an authored fragment: ${JSON.stringify(line)}`);
233
+ }
234
+ }
235
+ // Downstream artifacts and calling playbooks consume an output property by
236
+ // name, so a quoted kebab-case key names nothing the verifier can synthesize
237
+ // (DR-029; text2gears.md "Result contracts").
238
+ for (const item of items) {
239
+ for (const result of item.results) {
240
+ for (const field of result.fields) {
241
+ if (FIELD_IDENTIFIER.test(field.name))
242
+ continue;
243
+ findings.push(`${item.id}: result \`${result.guard}\` names the non-identifier output property ${JSON.stringify(field.name)}`);
244
+ }
245
+ }
246
+ }
247
+ const producers = new Map();
248
+ for (const item of items) {
249
+ for (const result of item.results) {
250
+ for (const field of result.fields) {
251
+ const entries = producers.get(field.name) ?? [];
252
+ entries.push(field);
253
+ producers.set(field.name, entries);
254
+ }
255
+ }
256
+ }
257
+ for (const [field, entries] of producers) {
258
+ if (entries.some((entry) => entry.verbatim) &&
259
+ entries.some((entry) => !entry.verbatim)) {
260
+ findings.push(`${field}: result field mixes verbatim and judge-authored ownership`);
261
+ }
262
+ }
263
+ const reported = new Set();
264
+ for (const item of items) {
265
+ for (const line of item.prompt) {
266
+ for (const match of line.matchAll(PLACEHOLDER)) {
267
+ const field = placeholderField(match[1]);
268
+ if (!relayedFields.has(field))
269
+ continue;
270
+ const key = `${item.id}:${field}`;
271
+ if (!line.startsWith('> ') && !reported.has(key)) {
272
+ findings.push(`${item.id}: relayed player field ${field} lacks a literal quote marker`);
273
+ reported.add(key);
274
+ }
275
+ }
276
+ }
277
+ }
278
+ return findings;
279
+ }
280
+ //# sourceMappingURL=verify-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-source.js","sourceRoot":"","sources":["../src/verify-source.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;;;;GAaG;AAEH,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,SAAS,GAAG,UAAU,CAAC;AAC7B,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,MAAM,sBAAsB,GAAG,qCAAqC,CAAC;AACrE,MAAM,aAAa,GAAG,4CAA4C,CAAC;AACnE,4EAA4E;AAC5E,8EAA8E;AAC9E,0DAA0D;AAC1D,MAAM,eAAe,GAAG,6BAA6B,CAAC;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AI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/C,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,SAAS;gBACxC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,IAAI,KAAK,EAAE,CAAC;gBAClC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjD,QAAQ,CAAC,IAAI,CACX,GAAG,IAAI,CAAC,EAAE,0BAA0B,KAAK,+BAA+B,CACzE,CAAC;oBACF,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/dist/verify.d.ts CHANGED
@@ -81,7 +81,38 @@ export interface PlaybookInvocationState {
81
81
  */
82
82
  export declare const NEEDS_BOSS_REPLY = "needsBossReply";
83
83
  export declare const BOSS_QUESTION_MARKER = "Output shall include `question:";
84
- /** Artifact schema selected only by a complete reviewed Playbook provenance. */
84
+ /**
85
+ * A Playbook engine's raw compatibility self-report — `RUNTIME_ABI` and
86
+ * `SUPPORTED_ARTIFACT_SCHEMAS` on its `@sublang/playbook/xstate-runtime`
87
+ * surface — read from the installed package owning a link target
88
+ * (verification-21, phase-execution-30; DR-028). The reader lives in
89
+ * `runtime-contract.ts`; the predicates stay here so the artifact-local
90
+ * verifier copy (verification-12) carries the schema decision whole.
91
+ */
92
+ export interface PlaybookRuntimeDeclaration {
93
+ /** `@sublang/playbook@<version>` of the owning installed package. */
94
+ provenance: string;
95
+ /** Lexical root of the owning package. */
96
+ packageRoot: string;
97
+ /** The exported `RUNTIME_ABI`, or `undefined` when the engine exports none. */
98
+ runtimeAbi: unknown;
99
+ /** The exported `SUPPORTED_ARTIFACT_SCHEMAS`, or `undefined` when absent. */
100
+ supportedArtifactSchemas: unknown;
101
+ }
102
+ /**
103
+ * True when the declaration admits the roleless schema-3 `composed-v3`
104
+ * generation: `RUNTIME_ABI` is exactly `1` and `SUPPORTED_ARTIFACT_SCHEMAS`
105
+ * contains `3` (DR-028).
106
+ */
107
+ export declare function declaresComposedV3(declaration: PlaybookRuntimeDeclaration): boolean;
108
+ /** Names a declaration for fail-closed diagnostics. */
109
+ export declare function describeRuntimeDeclaration(declaration: PlaybookRuntimeDeclaration): string;
110
+ /**
111
+ * Artifact schema recorded for an exact reviewed Playbook provenance: the
112
+ * historical map kept as recorded (DR-028). A later release supplies its
113
+ * schema through the installed engine's declaration instead
114
+ * ({@link resolveArtifactSchemaForVerification}).
115
+ */
85
116
  export declare function artifactSchemaForPlaybookProvenance(provenance: unknown): 1 | 3 | undefined;
86
117
  /**
87
118
  * Returns the Playbook package provenance that owns an invocation's concrete
@@ -94,6 +125,8 @@ export interface MachineConfigLike {
94
125
  initial?: string;
95
126
  states?: Record<string, StateLike>;
96
127
  on?: Record<string, unknown>;
128
+ /** The machine's initial context: a literal record or an input-taking factory. */
129
+ context?: unknown;
97
130
  }
98
131
  interface InvokeLike {
99
132
  src?: unknown;
@@ -293,7 +326,9 @@ export declare function placeholdersIn(prompt: string): string[];
293
326
  */
294
327
  export declare function probeContextReads(inputFn: (arg: {
295
328
  context: Record<string, unknown>;
296
- }) => unknown): string[];
329
+ }) => unknown,
330
+ /** The machine's initial context, so a typed field does not truncate the trace. */
331
+ initial?: Record<string, unknown>): string[];
297
332
  /**
298
333
  * Derives every captain state's prompt contract from the machine config
299
334
  * (verification-5): traced context reads, sentinel-traced input wiring, and the
@@ -322,6 +357,8 @@ export declare function checkPromptComposition(opts: {
322
357
  actor?: CaptainState['actor'];
323
358
  /** Grounded linked-artifact schema for otherwise ambiguous direct Captain states. */
324
359
  artifactSchema?: 1 | 3;
360
+ /** Collects observations that degrade the probe without failing the contract. */
361
+ diagnostics?: string[];
325
362
  }): string[];
326
363
  type PromptIdentity = (roleId: string) => string;
327
364
  type PromptComposer = (input: unknown, promptIdentity: PromptIdentity) => string;
@@ -434,10 +471,19 @@ export declare function generatePromptContractTest(opts: {
434
471
  player?: Record<string, string[]>;
435
472
  };
436
473
  }): string;
437
- /** Schema decision shared by generated and standalone artifact verification. */
474
+ /**
475
+ * Schema decision shared by generated and standalone artifact verification
476
+ * (verification-21). Reviewed provenance is evidence through its exact
477
+ * historical map; any other provenance is evidence only through the engine
478
+ * declaration read from the link target's installed package — `RUNTIME_ABI`
479
+ * `1` with artifact schema `3` — and is otherwise reported unsupported
480
+ * (DR-028).
481
+ */
438
482
  export declare function resolveArtifactSchemaForVerification(opts: {
439
483
  artifactSchema?: 1 | 3;
440
484
  provenance?: unknown;
485
+ /** The link target's installed engine declaration, when the caller read it. */
486
+ runtimeDeclaration?: PlaybookRuntimeDeclaration;
441
487
  config?: MachineConfigLike;
442
488
  linked?: {
443
489
  default?: unknown;
@@ -446,6 +492,25 @@ export declare function resolveArtifactSchemaForVerification(opts: {
446
492
  artifactSchema?: 1 | 3;
447
493
  findings: string[];
448
494
  };
495
+ /**
496
+ * The deterministic link-fidelity checks over one live linked `playbook` module
497
+ * beside its FSM (verification-27): exactly the checks the emitted
498
+ * prompt-contract suite asserts, decided from those two paths alone and
499
+ * returning one finding per violation.
500
+ *
501
+ * The gate that runs this before any Reviewer call must never throw into the
502
+ * executor it guards (DR-030, phase-execution-53), so a module that cannot be
503
+ * imported yields its import diagnostic as a finding. An absent module or FSM
504
+ * yields none: an artifact the performing call has not written is the generic
505
+ * target check's business (phase-execution-4). An FSM that cannot be imported
506
+ * yields none either — the suite's checks derive from that machine, so they
507
+ * degrade exactly as emission degrades its prompt-contract test to a
508
+ * diagnostic (verification-5).
509
+ */
510
+ export declare function checkLinkedModuleContract(opts: {
511
+ linkedPath: string;
512
+ fsmPath: string;
513
+ }): Promise<string[]>;
449
514
  /**
450
515
  * Emits the prompt-contract test beside a compiled `playbook` artifact
451
516
  * (verification-5): derives and pins the per-state contract from the physical
@@ -468,6 +533,8 @@ export declare function emitPromptContractTest(opts: {
468
533
  artifactSchema?: 1 | 3;
469
534
  /** Actual reviewed full-link target provenance, when the caller has it. */
470
535
  provenance?: unknown;
536
+ /** The full-link target's installed engine declaration, when read (DR-028). */
537
+ runtimeDeclaration?: PlaybookRuntimeDeclaration;
471
538
  }): Promise<{
472
539
  path: string;
473
540
  diagnostics: string[];