peaks-loop 4.1.9 → 4.1.10
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +29 -0
- package/dist/cli/commands/_register.js +2 -0
- package/dist/cli/commands/strat-tact-command-helpers.d.ts +16 -0
- package/dist/cli/commands/strat-tact-command-helpers.js +162 -0
- package/dist/cli/commands/strat-tact-commands.d.ts +3 -0
- package/dist/cli/commands/strat-tact-commands.js +176 -0
- package/dist/services/rd/ast-gate.d.ts +19 -12
- package/dist/services/rd/ast-gate.js +10 -0
- package/dist/services/rd/canonical-hash.d.ts +1 -0
- package/dist/services/rd/canonical-hash.js +38 -0
- package/dist/services/rd/impl.js +2 -8
- package/dist/services/rd/strategy.js +2 -8
- package/dist/services/rd/types.d.ts +10 -10
- package/dist/services/rd/types.js +21 -10
- package/package.json +5 -5
- package/skills/bee/peaks-rd/SKILL.md +25 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"pluginRoot": ".",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.10"
|
|
5
5
|
},
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "peaks-loop",
|
|
9
9
|
"description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
|
|
10
|
-
"version": "4.1.
|
|
10
|
+
"version": "4.1.10",
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "SquabbyZ"
|
|
13
13
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.1.10 — 2026-10-20(STRAT→TACT→MUT 生产者链,canonical digest 递归修复)
|
|
4
|
+
|
|
5
|
+
**版本级别**: 未发布区间 `v4.1.9..HEAD` 共 **3 个 commit**(**1 feat / 1 fix / 1 docs**)。取 **patch**,依维护者 2026-07-22 的常设规则"默认版本新增采用最小的版本位"。CLI 新增 `peaks strat` / `peaks tact` 两个动词组,均为既有 service 的薄包装;无破坏性变更(canonical digest 的值变了,但只影响修复前产生的临时 artifact)。
|
|
6
|
+
|
|
7
|
+
### 1. STRAT → TACT → MUT 生产者链(`45b378e9`,backlog §16 / §9.2)
|
|
8
|
+
|
|
9
|
+
- `peaks strat write`:写 strategy.md + `<out>.json`,生成 STRAT.sig。
|
|
10
|
+
- `peaks tact write`:校验 strategy JSON 的递归 sha256 与 markdown 的 `STRAT.sig:` 行,注册 STRAT.sig,跑 AST gate,写 impl.json(`inputSig` = STRAT.sig)。
|
|
11
|
+
- `peaks tact read`:重新校验 impl.json 并输出 `{ sha256, inputSig, changedFiles, astGateResult }`——文档里长期缺失的命令现在真实存在。
|
|
12
|
+
- 单轴写入守卫(`--session-id` 必填、`--out` 必须在 `.peaks/_runtime/<sid>/` 下)、`--changed-files` 项目内包含校验、AST 违规/篡改 artifact 的命名 refusal。
|
|
13
|
+
- 端到端测试:`strat write → tact write → tact read → mut`,`mut-report.json#inputSig` 等于 TACT.sig,并覆盖 passing-threshold 分支。
|
|
14
|
+
|
|
15
|
+
### 2. Canonical digest 递归修复(`45b378e9`)
|
|
16
|
+
|
|
17
|
+
- 旧实现 `JSON.stringify(rest, Object.keys(rest).sort())` 是数组 replacer,会在每一层过滤 key,导致嵌套对象(`astGateResult` 等)被哈希成 `{}`;伪造嵌套 verdict 仍能通过验证。
|
|
18
|
+
- 现在逐层排序 key,verifier 对**解析前原始 JSON**求哈希,`StrategyOutput` / `ImplOutput` 及嵌套 schema 均为 `.strict()`。嵌套字段、数组项、未知字段的篡改全部拒绝。
|
|
19
|
+
- 注:digest 是 checksum 不是 MAC;同时改内容并重算签名的 artifact 仍会通过(H8 固有)。
|
|
20
|
+
|
|
21
|
+
### 3. Backlog 与测试稳定性(`442c0e96`、`77a38b82`)
|
|
22
|
+
|
|
23
|
+
- §2.38 关闭:`peaks job add-slice` 已存在并追加 ledger。
|
|
24
|
+
- §9.50 关闭:AC-6 的 macOS gate 已在 CI 中通过。
|
|
25
|
+
- 全量 pre-push 暴露并修复:`tact read` 注册后的 invocation-check 夹具,以及 rule-D 对 `requireSessionAxis` 守卫的识别(补 `isUnsafePathInput`)。
|
|
26
|
+
|
|
27
|
+
### 4. 证据
|
|
28
|
+
|
|
29
|
+
- 531 files / 5798 tests 在 pre-push 全量套件中通过;`tsc --noEmit`、`pnpm build`、repo/staged gate 全绿。
|
|
30
|
+
- code review(两轮,HIGH 已修)PASS-WITH-FINDINGS;Karpathy pass;security `warn`(1 LOW,词法单轴 symlink);perf `warn`(1 LOW,AST gate 双跑);QA PASS(AC1–AC9);`verify-pipeline complete: true`。
|
|
31
|
+
|
|
3
32
|
## 4.1.9 — 2026-10-19(Step 0.8 gate:remedy 豁免、provisional 决策与 exit code 可见性)
|
|
4
33
|
|
|
5
34
|
**版本级别**: 未发布区间 `v4.1.8..HEAD` 共 **6 个 commit**(**2 fix / 1 style / 3 docs**)。取 **patch**,依维护者 2026-07-22 的常设规则"默认版本新增采用最小的版本位"。无破坏性 CLI 变更。
|
|
@@ -75,6 +75,7 @@ import { registerSliceReviewCommands } from './slice-review-commands.js';
|
|
|
75
75
|
import { registerSmokeCommands } from './smoke-commands.js';
|
|
76
76
|
import { registerSopCommands } from './sop-commands.js';
|
|
77
77
|
import { registerStatusLineCommands } from './statusline-commands.js';
|
|
78
|
+
import { registerStratTactCommands } from './strat-tact-commands.js';
|
|
78
79
|
import { registerSpillDemoCommand } from './spill-demo-command.js';
|
|
79
80
|
import { registerSubAgentCommands } from './sub-agent-commands.js';
|
|
80
81
|
import { registerSubAgentShutdownCommands } from './sub-agent-shutdown-commands.js';
|
|
@@ -174,6 +175,7 @@ const REGISTRATIONS = [
|
|
|
174
175
|
['dashboard-commands', registerDashboardCommands],
|
|
175
176
|
['best-practice-scan-command', registerBestPracticeScanCommand],
|
|
176
177
|
['mut-commands', registerMutCommands],
|
|
178
|
+
['strat-tact-commands', registerStratTactCommands],
|
|
177
179
|
['fixture-commands', registerFixtureCommands],
|
|
178
180
|
['reviewer-commands', registerReviewerCommands],
|
|
179
181
|
['ide-commands', registerIdeCommands],
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProgramIO } from '../cli-helpers.js';
|
|
2
|
+
import { type AstGateContext } from '../../services/rd/ast-gate.js';
|
|
3
|
+
import { type ImplOutput, type StrategyOutput } from '../../services/rd/types.js';
|
|
4
|
+
export declare class CommandRefusal extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly remedy: string;
|
|
7
|
+
constructor(code: string, remedy: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare function emitOk(io: ProgramIO, json: boolean, payload: Record<string, unknown>, human: string[]): void;
|
|
10
|
+
/** Run an action body, turning a named refusal into the CLI's error surface. */
|
|
11
|
+
export declare function guarded(io: ProgramIO, json: boolean, command: string, body: () => Promise<void>): Promise<void>;
|
|
12
|
+
/** Resolve `--out` and enforce the one-axis layout. */
|
|
13
|
+
export declare function requireSessionAxis(project: string, sessionId: string, out: string): string;
|
|
14
|
+
export declare function readStrategy(path: string): Promise<StrategyOutput>;
|
|
15
|
+
export declare function readImpl(path: string): Promise<ImplOutput>;
|
|
16
|
+
export declare function parseAstContext(raw: string | undefined): AstGateContext;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for the STRAT → TACT producer commands (backlog §16 / §9.2).
|
|
3
|
+
*
|
|
4
|
+
* Split out of `strat-tact-commands.ts` for the repo's 300-line source cap.
|
|
5
|
+
* Pure orchestration helpers: refusal plumbing, the one-axis path guard, and
|
|
6
|
+
* the artifact readers that re-verify a signed JSON document before trusting
|
|
7
|
+
* it. The service layer stays the single implementation of both stages.
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
11
|
+
import { fail } from 'peaks-loop-shared/result';
|
|
12
|
+
import { isUnsafePathInput } from '../../shared/path-safety.js';
|
|
13
|
+
import { AstGateContextSchema } from '../../services/rd/ast-gate.js';
|
|
14
|
+
import { canonicalSha256 } from '../../services/rd/canonical-hash.js';
|
|
15
|
+
import { ImplOutputSchema, StrategyOutputSchema } from '../../services/rd/types.js';
|
|
16
|
+
const SESSION_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
17
|
+
const JSON_SUFFIX = '.json';
|
|
18
|
+
/** Short sig prefix shown in a mismatch message; the full digest stays in the artifact. */
|
|
19
|
+
const SIG_PREVIEW_LEN = 12;
|
|
20
|
+
export class CommandRefusal extends Error {
|
|
21
|
+
code;
|
|
22
|
+
remedy;
|
|
23
|
+
constructor(code, remedy, message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.remedy = remedy;
|
|
27
|
+
this.name = 'CommandRefusal';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function emitOk(io, json, payload, human) {
|
|
31
|
+
if (json) {
|
|
32
|
+
io.stdout(JSON.stringify({ ok: true, ...payload }));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
io.stdout(human.join('\n'));
|
|
36
|
+
}
|
|
37
|
+
function refuse(io, json, command, r) {
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
if (json) {
|
|
40
|
+
io.stdout(JSON.stringify(fail(command, r.code, r.message, { remedy: r.remedy }, [r.remedy])));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
io.stderr(`${r.code}: ${r.message} — ${r.remedy}\n`);
|
|
44
|
+
}
|
|
45
|
+
/** Run an action body, turning a named refusal into the CLI's error surface. */
|
|
46
|
+
export async function guarded(io, json, command, body) {
|
|
47
|
+
try {
|
|
48
|
+
await body();
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (err instanceof CommandRefusal) {
|
|
52
|
+
refuse(io, json, command, err);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Resolve `--out` and enforce the one-axis layout. */
|
|
59
|
+
export function requireSessionAxis(project, sessionId, out) {
|
|
60
|
+
// The canonical traversal guard PLUS the stricter single-segment regex: the
|
|
61
|
+
// former is what the runtime-id scanner recognises, the latter also rejects
|
|
62
|
+
// backslashes and a leading dot that the traversal guard alone would admit.
|
|
63
|
+
if (isUnsafePathInput(sessionId) || !SESSION_ID_RE.test(sessionId)) {
|
|
64
|
+
throw new CommandRefusal('INVALID_SESSION_ID', 'Use the session id that names .peaks/_runtime/<sid>/ (letters, digits, dot, dash, underscore).', `invalid --session-id: ${sessionId}`);
|
|
65
|
+
}
|
|
66
|
+
const sessionRoot = resolve(project, '.peaks', '_runtime', sessionId);
|
|
67
|
+
const absolute = isAbsolute(out) ? resolve(out) : resolve(project, out);
|
|
68
|
+
const rel = relative(sessionRoot, absolute);
|
|
69
|
+
if (rel === '' || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
70
|
+
throw new CommandRefusal('ONE_AXIS_VIOLATION', `Pass --out .peaks/_runtime/${sessionId}/rd/<file>; artifacts are written only on the session axis.`, `--out must live under .peaks/_runtime/${sessionId}/ (got ${absolute})`);
|
|
71
|
+
}
|
|
72
|
+
return absolute;
|
|
73
|
+
}
|
|
74
|
+
async function readJsonFile(path, notFoundCode, invalidJsonCode, remedy) {
|
|
75
|
+
let raw;
|
|
76
|
+
try {
|
|
77
|
+
raw = await readFile(path, 'utf8');
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
throw new CommandRefusal(notFoundCode, remedy, `${path} could not be read: ${err instanceof Error ? err.message : String(err)}`);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(raw);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
throw new CommandRefusal(invalidJsonCode, remedy, `${path} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Recompute the digest over the RAW parsed JSON, before any schema strip.
|
|
91
|
+
* Order matters: an unknown field added to a signed artifact must change the
|
|
92
|
+
* digest (and therefore refuse), not be silently dropped by the schema.
|
|
93
|
+
*/
|
|
94
|
+
function assertArtifactDigest(raw, path, codes, remedy) {
|
|
95
|
+
if (raw === null || typeof raw !== 'object') {
|
|
96
|
+
throw new CommandRefusal(codes.invalid, remedy, `${path} is not a JSON object`);
|
|
97
|
+
}
|
|
98
|
+
const declared = raw.sha256;
|
|
99
|
+
const recomputed = canonicalSha256(raw);
|
|
100
|
+
if (declared !== recomputed) {
|
|
101
|
+
throw new CommandRefusal(codes.mismatch, remedy, `sha256 mismatch at ${path} (declared=${String(declared).slice(0, SIG_PREVIEW_LEN)}… ` +
|
|
102
|
+
`recomputed=${recomputed.slice(0, SIG_PREVIEW_LEN)}…)`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** The markdown sibling is the human-readable anchor; both must carry the same sig. */
|
|
106
|
+
async function requireStrategyMarkdown(jsonPath, sha256) {
|
|
107
|
+
const markdownPath = jsonPath.endsWith(JSON_SUFFIX)
|
|
108
|
+
? jsonPath.slice(0, -JSON_SUFFIX.length)
|
|
109
|
+
: jsonPath;
|
|
110
|
+
let markdown;
|
|
111
|
+
try {
|
|
112
|
+
markdown = await readFile(markdownPath, 'utf8');
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
throw new CommandRefusal('STRATEGY_MARKDOWN_NOT_FOUND', 'Re-run peaks strat write; it writes strategy.md next to the <out>.json sibling.', `strategy markdown not found at ${markdownPath} (${err instanceof Error ? err.message : String(err)})`);
|
|
116
|
+
}
|
|
117
|
+
const declared = /STRAT\.sig:\s*([a-f0-9]{64})/.exec(markdown)?.[1];
|
|
118
|
+
if (declared !== sha256) {
|
|
119
|
+
throw new CommandRefusal('STRATEGY_SIG_MISMATCH', `Re-run peaks strat write to regenerate both the markdown and its JSON sibling (${jsonPath}).`, `strategy markdown signature at ${markdownPath} is ${declared ?? '<missing>'} but the JSON ` +
|
|
120
|
+
`declares ${sha256.slice(0, SIG_PREVIEW_LEN)}…`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export async function readStrategy(path) {
|
|
124
|
+
const remedy = 'Re-run peaks strat write; --strategy expects the JSON sibling it wrote.';
|
|
125
|
+
const raw = await readJsonFile(path, 'STRATEGY_NOT_FOUND', 'INVALID_STRATEGY_JSON', remedy);
|
|
126
|
+
assertArtifactDigest(raw, path, { invalid: 'INVALID_STRATEGY', mismatch: 'STRAT_SIG_MISMATCH' }, remedy);
|
|
127
|
+
const parsed = StrategyOutputSchema.safeParse(raw);
|
|
128
|
+
if (!parsed.success) {
|
|
129
|
+
throw new CommandRefusal('INVALID_STRATEGY', remedy, `${path} does not match StrategyOutput: ${parsed.error.message}`);
|
|
130
|
+
}
|
|
131
|
+
await requireStrategyMarkdown(path, parsed.data.sha256);
|
|
132
|
+
return parsed.data;
|
|
133
|
+
}
|
|
134
|
+
export async function readImpl(path) {
|
|
135
|
+
const remedy = 'Re-run peaks tact write; --artifact expects the impl.json it wrote.';
|
|
136
|
+
const raw = await readJsonFile(path, 'IMPL_NOT_FOUND', 'INVALID_IMPL_JSON', remedy);
|
|
137
|
+
assertArtifactDigest(raw, path, { invalid: 'INVALID_IMPL', mismatch: 'IMPL_SIG_MISMATCH' }, remedy);
|
|
138
|
+
const parsed = ImplOutputSchema.safeParse(raw);
|
|
139
|
+
if (!parsed.success) {
|
|
140
|
+
throw new CommandRefusal('INVALID_IMPL', remedy, `${path} does not match ImplOutput: ${parsed.error.message}`);
|
|
141
|
+
}
|
|
142
|
+
return parsed.data;
|
|
143
|
+
}
|
|
144
|
+
export function parseAstContext(raw) {
|
|
145
|
+
if (raw === undefined) {
|
|
146
|
+
return { deps: {}, docSummaries: [] };
|
|
147
|
+
}
|
|
148
|
+
const remedy = 'Pass --ast-context as JSON matching { deps, docSummaries }, or omit it for the empty context.';
|
|
149
|
+
const parsed = AstGateContextSchema.safeParse(readJsonOrRefuse(raw, 'INVALID_AST_CONTEXT', remedy, '--ast-context'));
|
|
150
|
+
if (!parsed.success) {
|
|
151
|
+
throw new CommandRefusal('INVALID_AST_CONTEXT', remedy, `--ast-context does not match AstGateContext: ${parsed.error.message}`);
|
|
152
|
+
}
|
|
153
|
+
return parsed.data;
|
|
154
|
+
}
|
|
155
|
+
function readJsonOrRefuse(raw, code, remedy, path) {
|
|
156
|
+
try {
|
|
157
|
+
return JSON.parse(raw);
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
throw new CommandRefusal(code, remedy, `${path} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `peaks strat <sub>` / `peaks tact <sub>` — the STRAT → TACT producer chain.
|
|
3
|
+
*
|
|
4
|
+
* WHY this module exists (backlog §16 / §9.2): the documented chain
|
|
5
|
+
* `strategy.md (STRAT.sig) → impl.json (TACT.sig) → mut-report.json` had no
|
|
6
|
+
* CLI producer, so `mut/mut-report.json` could never receive a real
|
|
7
|
+
* `inputSig`. These commands are thin wrappers over the unchanged rd
|
|
8
|
+
* sub-stages; the service layer stays the single implementation.
|
|
9
|
+
*
|
|
10
|
+
* Hard rules carried over from the services:
|
|
11
|
+
* - H8: a TACT can only anchor to a STRAT whose recomputed sha256 matches
|
|
12
|
+
* the artifact content. `tact write` therefore never accepts a raw
|
|
13
|
+
* `--input-sig`; it re-verifies the strategy JSON first.
|
|
14
|
+
* - H6: AST-gate violations refuse before TACT.sig is written.
|
|
15
|
+
* - One-axis layout: every `--out` lives under
|
|
16
|
+
* `.peaks/_runtime/<sessionId>/`; `--session-id` is required on writes.
|
|
17
|
+
*/
|
|
18
|
+
import { mkdir, stat, writeFile } from 'node:fs/promises';
|
|
19
|
+
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
20
|
+
import { runAstGate } from '../../services/rd/ast-gate.js';
|
|
21
|
+
import { runStrategicStage } from '../../services/rd/strategic-stage.js';
|
|
22
|
+
import { registerStratSig, runTacticalStage } from '../../services/rd/tactical-stage.js';
|
|
23
|
+
import { CommandRefusal, emitOk, guarded, parseAstContext, readImpl, readStrategy, requireSessionAxis } from './strat-tact-command-helpers.js';
|
|
24
|
+
const CHANGED_FILES_REMEDY = 'Pass --changed-files as existing project-relative paths; the AST gate reads only files inside --project.';
|
|
25
|
+
async function isRegularFile(path) {
|
|
26
|
+
try {
|
|
27
|
+
return (await stat(path)).isFile();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Containment check: the AST gate must never read outside --project. */
|
|
34
|
+
async function resolveChangedFiles(project, files) {
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
if (isAbsolute(file)) {
|
|
37
|
+
throw new CommandRefusal('INVALID_CHANGED_FILE', CHANGED_FILES_REMEDY, `--changed-files entry is absolute: ${file}`);
|
|
38
|
+
}
|
|
39
|
+
const absolute = resolve(project, file);
|
|
40
|
+
const rel = relative(project, absolute);
|
|
41
|
+
if (rel === '' || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
42
|
+
throw new CommandRefusal('INVALID_CHANGED_FILE', CHANGED_FILES_REMEDY, `--changed-files entry escapes --project: ${file}`);
|
|
43
|
+
}
|
|
44
|
+
if (!(await isRegularFile(absolute))) {
|
|
45
|
+
throw new CommandRefusal('INVALID_CHANGED_FILE', CHANGED_FILES_REMEDY, `--changed-files entry does not exist as a file under --project: ${file}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return [...files];
|
|
49
|
+
}
|
|
50
|
+
/** A TOCTOU failure inside the service still surfaces as a named refusal. */
|
|
51
|
+
async function runTacticalSafely(input) {
|
|
52
|
+
try {
|
|
53
|
+
return await runTacticalStage(input);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
if (err instanceof CommandRefusal) {
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
throw new CommandRefusal('TACT_WRITE_FAILED', 'Re-run peaks tact write; if the AST gate now reports a violation, fix it first.', `tact write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function runStratWrite(io, a) {
|
|
63
|
+
const project = resolve(a.project);
|
|
64
|
+
const out = requireSessionAxis(project, a.sessionId, a.out);
|
|
65
|
+
await mkdir(dirname(out), { recursive: true });
|
|
66
|
+
const result = await runStrategicStage({
|
|
67
|
+
out,
|
|
68
|
+
goal: a.goal,
|
|
69
|
+
rootCauseAnalysis: a.rootCause,
|
|
70
|
+
impactSurface: a.impact,
|
|
71
|
+
designRationale: a.design
|
|
72
|
+
});
|
|
73
|
+
const jsonPath = `${out}.json`;
|
|
74
|
+
await writeFile(jsonPath, JSON.stringify(result, null, 2), 'utf8');
|
|
75
|
+
emitOk(io, a.json, { path: out, jsonPath, sha256: result.sha256 }, [
|
|
76
|
+
`strategy.md: ${out}`,
|
|
77
|
+
`json: ${jsonPath}`,
|
|
78
|
+
`STRAT.sig: ${result.sha256}`
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
async function runTactWrite(io, a) {
|
|
82
|
+
const project = resolve(a.project);
|
|
83
|
+
const out = requireSessionAxis(project, a.sessionId, a.out);
|
|
84
|
+
const changedFiles = await resolveChangedFiles(project, a.changedFiles);
|
|
85
|
+
const strategyPath = isAbsolute(a.strategy) ? resolve(a.strategy) : resolve(project, a.strategy);
|
|
86
|
+
const strategy = await readStrategy(strategyPath);
|
|
87
|
+
const context = parseAstContext(a.astContext);
|
|
88
|
+
// Name the violations before the service throws its count-only error.
|
|
89
|
+
const gate = await runAstGate({ project, changedFiles, context });
|
|
90
|
+
if (!gate.passed) {
|
|
91
|
+
throw new CommandRefusal('AST_GATE_FAILED', 'Fix the undocumented API call (or update the locked-version doc summary) and re-run peaks tact write.', `AST gate failed — ${gate.violations
|
|
92
|
+
.map((v) => `${v.api} at ${v.file}:${v.line}`)
|
|
93
|
+
.join('; ')}`);
|
|
94
|
+
}
|
|
95
|
+
await mkdir(dirname(out), { recursive: true });
|
|
96
|
+
// H8: rehydrate the in-process registry from the verified artifact —
|
|
97
|
+
// this CLI process never ran `runStrategicStage`.
|
|
98
|
+
registerStratSig(dirname(out), strategy.sha256);
|
|
99
|
+
const impl = await runTacticalSafely({
|
|
100
|
+
project,
|
|
101
|
+
changedFiles,
|
|
102
|
+
inputSig: strategy.sha256,
|
|
103
|
+
context,
|
|
104
|
+
out
|
|
105
|
+
});
|
|
106
|
+
emitOk(io, a.json, {
|
|
107
|
+
path: out,
|
|
108
|
+
sha256: impl.sha256,
|
|
109
|
+
inputSig: impl.inputSig,
|
|
110
|
+
changedFiles: impl.changedFiles,
|
|
111
|
+
astGateResult: impl.astGateResult
|
|
112
|
+
}, [`impl.json: ${out}`, `TACT.sig: ${impl.sha256}`, `inputSig: ${impl.inputSig}`]);
|
|
113
|
+
}
|
|
114
|
+
async function runTactRead(io, a) {
|
|
115
|
+
const project = resolve(a.project);
|
|
116
|
+
const artifact = isAbsolute(a.artifact) ? resolve(a.artifact) : resolve(project, a.artifact);
|
|
117
|
+
const impl = await readImpl(artifact);
|
|
118
|
+
emitOk(io, a.json, {
|
|
119
|
+
sha256: impl.sha256,
|
|
120
|
+
inputSig: impl.inputSig,
|
|
121
|
+
changedFiles: impl.changedFiles,
|
|
122
|
+
astGateResult: impl.astGateResult
|
|
123
|
+
}, [
|
|
124
|
+
`sha256: ${impl.sha256}`,
|
|
125
|
+
`inputSig: ${impl.inputSig}`,
|
|
126
|
+
`changedFiles: ${impl.changedFiles.join(', ')}`,
|
|
127
|
+
`astGateResult: passed=${impl.astGateResult.passed} violations=${impl.astGateResult.violations.length}`
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
export function registerStratTactCommands(program, io) {
|
|
131
|
+
const strat = program
|
|
132
|
+
.command('strat')
|
|
133
|
+
.description('STRAT producer: strategy.md + STRAT.sig (spec §4.2 战略审计)');
|
|
134
|
+
registerStratWrite(strat, io);
|
|
135
|
+
const tact = program
|
|
136
|
+
.command('tact')
|
|
137
|
+
.description('TACT producer/reader: impl.json + TACT.sig chained to STRAT.sig');
|
|
138
|
+
registerTactWrite(tact, io);
|
|
139
|
+
registerTactRead(tact, io);
|
|
140
|
+
}
|
|
141
|
+
function registerStratWrite(strat, io) {
|
|
142
|
+
strat
|
|
143
|
+
.command('write')
|
|
144
|
+
.description('Write strategy.md plus its <out>.json sibling. One-axis: --session-id required.')
|
|
145
|
+
.requiredOption('--project <path>', 'project root')
|
|
146
|
+
.requiredOption('--session-id <sid>', 'session id; --out must live under .peaks/_runtime/<sid>/')
|
|
147
|
+
.requiredOption('--out <path>', 'strategy markdown path (inside .peaks/_runtime/<sid>/)')
|
|
148
|
+
.requiredOption('--goal <text>', 'goal of this slice')
|
|
149
|
+
.requiredOption('--root-cause <text>', 'root-cause analysis')
|
|
150
|
+
.requiredOption('--impact <items...>', 'impact surface entries')
|
|
151
|
+
.requiredOption('--design <text>', 'design rationale')
|
|
152
|
+
.option('--json', 'machine-readable output', false)
|
|
153
|
+
.action((a) => guarded(io, a.json, 'strat write', () => runStratWrite(io, a)));
|
|
154
|
+
}
|
|
155
|
+
function registerTactWrite(tact, io) {
|
|
156
|
+
tact
|
|
157
|
+
.command('write')
|
|
158
|
+
.description('Verify the strategy JSON, run the AST gate, then write impl.json + TACT.sig. One-axis: --session-id required.')
|
|
159
|
+
.requiredOption('--project <path>', 'project root')
|
|
160
|
+
.requiredOption('--session-id <sid>', 'session id; --out must live under .peaks/_runtime/<sid>/')
|
|
161
|
+
.requiredOption('--strategy <path>', 'strategy JSON sibling written by `peaks strat write`')
|
|
162
|
+
.requiredOption('--out <path>', 'impl.json path (inside .peaks/_runtime/<sid>/)')
|
|
163
|
+
.requiredOption('--changed-files <paths...>', 'files the tactical stage changed')
|
|
164
|
+
.option('--ast-context <json>', 'AstGateContext JSON ({ deps, docSummaries })')
|
|
165
|
+
.option('--json', 'machine-readable output', false)
|
|
166
|
+
.action((a) => guarded(io, a.json, 'tact write', () => runTactWrite(io, a)));
|
|
167
|
+
}
|
|
168
|
+
function registerTactRead(tact, io) {
|
|
169
|
+
tact
|
|
170
|
+
.command('read')
|
|
171
|
+
.description('Re-read impl.json, recompute TACT.sig, and print the chain anchor.')
|
|
172
|
+
.requiredOption('--artifact <path>', 'impl.json written by `peaks tact write`')
|
|
173
|
+
.option('--project <path>', 'project root (default: cwd)', '.')
|
|
174
|
+
.option('--json', 'machine-readable output', false)
|
|
175
|
+
.action((a) => guarded(io, a.json, 'tact read', () => runTactRead(io, a)));
|
|
176
|
+
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import type { AstGateResult } from './types.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The locked-version context the gate compares against. The schema is the
|
|
5
|
+
* single source for both the type and the CLI's `--ast-context` validation —
|
|
6
|
+
* a malformed context is refused rather than silently read as empty.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AstGateContextSchema: z.ZodObject<{
|
|
9
|
+
deps: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
10
|
+
version: z.ZodString;
|
|
11
|
+
source: z.ZodString;
|
|
12
|
+
resolved: z.ZodString;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
docSummaries: z.ZodArray<z.ZodObject<{
|
|
15
|
+
dep: z.ZodString;
|
|
16
|
+
version: z.ZodString;
|
|
17
|
+
apis: z.ZodArray<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type AstGateContext = z.infer<typeof AstGateContextSchema>;
|
|
14
21
|
export interface RunAstGateInput {
|
|
15
22
|
readonly project: string;
|
|
16
23
|
readonly changedFiles: ReadonlyArray<string>;
|
|
@@ -12,6 +12,16 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { readFile } from 'node:fs/promises';
|
|
14
14
|
import { join } from 'node:path';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
/**
|
|
17
|
+
* The locked-version context the gate compares against. The schema is the
|
|
18
|
+
* single source for both the type and the CLI's `--ast-context` validation —
|
|
19
|
+
* a malformed context is refused rather than silently read as empty.
|
|
20
|
+
*/
|
|
21
|
+
export const AstGateContextSchema = z.object({
|
|
22
|
+
deps: z.record(z.string(), z.object({ version: z.string(), source: z.string(), resolved: z.string() })),
|
|
23
|
+
docSummaries: z.array(z.object({ dep: z.string(), version: z.string(), apis: z.array(z.string()) }))
|
|
24
|
+
});
|
|
15
25
|
const IMPORT_RE = /import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g;
|
|
16
26
|
const CALL_RE = /\b([a-zA-Z_$][\w$]*)\s*\(/g;
|
|
17
27
|
export async function runAstGate(input) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function canonicalSha256(content: object): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical H8 digest shared by STRAT, TACT and the CLI verifiers.
|
|
3
|
+
*
|
|
4
|
+
* WHY one export: `writeStrategy`, `writeImpl` and the `peaks tact read|write`
|
|
5
|
+
* verifiers must compute the IDENTICAL digest, or an artifact signed by one
|
|
6
|
+
* side is refused by the other. Keeping the omit-`sha256` + sorted-keys rule
|
|
7
|
+
* in one place is what stops that drift.
|
|
8
|
+
*
|
|
9
|
+
* WHY A RECURSIVE SORT AND NOT `JSON.stringify(rest, Object.keys(rest).sort())`:
|
|
10
|
+
* the array-replacer form filters keys at EVERY nesting level, so a nested
|
|
11
|
+
* object whose keys are not top-level names serializes as `{}` — the digest
|
|
12
|
+
* then ignores `astGateResult`, `changedFiles[]` entries and
|
|
13
|
+
* `askUserQuestion` entirely. Measured: forging `impl.json#astGateResult`
|
|
14
|
+
* without touching `sha256` still verified. The sort must be applied by hand,
|
|
15
|
+
* per level, so every nested value is part of the digest.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
function stableValue(value) {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value.map(stableValue);
|
|
21
|
+
}
|
|
22
|
+
if (value === null || typeof value !== 'object') {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
const source = value;
|
|
26
|
+
const sorted = {};
|
|
27
|
+
for (const key of Object.keys(source).sort()) {
|
|
28
|
+
sorted[key] = stableValue(source[key]);
|
|
29
|
+
}
|
|
30
|
+
return sorted;
|
|
31
|
+
}
|
|
32
|
+
export function canonicalSha256(content) {
|
|
33
|
+
const { sha256: _omit, ...rest } = content;
|
|
34
|
+
void _omit;
|
|
35
|
+
return createHash('sha256')
|
|
36
|
+
.update(JSON.stringify(stableValue(rest)))
|
|
37
|
+
.digest('hex');
|
|
38
|
+
}
|
package/dist/services/rd/impl.js
CHANGED
|
@@ -7,15 +7,9 @@
|
|
|
7
7
|
* H6 (CLI裁决): refuses to write when AST gate has violations —
|
|
8
8
|
* LLM MUST auto-fix and re-run.
|
|
9
9
|
*/
|
|
10
|
-
import { createHash } from 'node:crypto';
|
|
11
10
|
import { writeFile, rename, unlink } from 'node:fs/promises';
|
|
11
|
+
import { canonicalSha256 } from './canonical-hash.js';
|
|
12
12
|
import { ImplOutputSchema } from './types.js';
|
|
13
|
-
function sha256Of(content) {
|
|
14
|
-
const { sha256: _omit, ...rest } = content;
|
|
15
|
-
void _omit;
|
|
16
|
-
const canonical = JSON.stringify(rest, Object.keys(rest).sort());
|
|
17
|
-
return createHash('sha256').update(canonical).digest('hex');
|
|
18
|
-
}
|
|
19
13
|
export async function writeImpl(input) {
|
|
20
14
|
// Defense-in-depth: passed flag and violations[] must agree.
|
|
21
15
|
// A caller passing passed=true with non-empty violations (lying input)
|
|
@@ -40,7 +34,7 @@ export async function writeImpl(input) {
|
|
|
40
34
|
externalApiCalls: [...input.externalApiCalls],
|
|
41
35
|
astGateResult: input.astGate
|
|
42
36
|
};
|
|
43
|
-
const sha256 =
|
|
37
|
+
const sha256 = canonicalSha256(partial);
|
|
44
38
|
const final = { ...partial, sha256 };
|
|
45
39
|
ImplOutputSchema.parse(final);
|
|
46
40
|
const tmp = `${input.out}.tmp`;
|
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
* H8 (audit trail hashable): sig field embedded in strategy.md is the
|
|
6
6
|
* sha256 of all OTHER content (chicken-and-egg avoided).
|
|
7
7
|
*/
|
|
8
|
-
import { createHash } from 'node:crypto';
|
|
9
8
|
import { writeFile, rename, unlink } from 'node:fs/promises';
|
|
9
|
+
import { canonicalSha256 } from './canonical-hash.js';
|
|
10
10
|
import { StrategyOutputSchema } from './types.js';
|
|
11
|
-
function sha256Of(content) {
|
|
12
|
-
const { sha256: _omit, ...rest } = content;
|
|
13
|
-
void _omit;
|
|
14
|
-
const canonical = JSON.stringify(rest, Object.keys(rest).sort());
|
|
15
|
-
return createHash('sha256').update(canonical).digest('hex');
|
|
16
|
-
}
|
|
17
11
|
export async function writeStrategy(input) {
|
|
18
12
|
const partial = {
|
|
19
13
|
version: '1.0',
|
|
@@ -25,7 +19,7 @@ export async function writeStrategy(input) {
|
|
|
25
19
|
designRationale: input.designRationale,
|
|
26
20
|
...(input.askUserQuestion ? { askUserQuestion: input.askUserQuestion } : {})
|
|
27
21
|
};
|
|
28
|
-
const sha256 =
|
|
22
|
+
const sha256 = canonicalSha256(partial);
|
|
29
23
|
const final = { ...partial, sha256 };
|
|
30
24
|
StrategyOutputSchema.parse(final);
|
|
31
25
|
const body = [
|
|
@@ -16,8 +16,8 @@ export declare const StrategyOutputSchema: z.ZodObject<{
|
|
|
16
16
|
askUserQuestion: z.ZodOptional<z.ZodObject<{
|
|
17
17
|
question: z.ZodString;
|
|
18
18
|
options: z.ZodArray<z.ZodString>;
|
|
19
|
-
}, z.core.$
|
|
20
|
-
}, z.core.$
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
21
|
export type StrategyOutput = z.infer<typeof StrategyOutputSchema>;
|
|
22
22
|
export declare const AstViolationSchema: z.ZodObject<{
|
|
23
23
|
file: z.ZodString;
|
|
@@ -29,7 +29,7 @@ export declare const AstViolationSchema: z.ZodObject<{
|
|
|
29
29
|
error: "error";
|
|
30
30
|
warning: "warning";
|
|
31
31
|
}>;
|
|
32
|
-
}, z.core.$
|
|
32
|
+
}, z.core.$strict>;
|
|
33
33
|
export declare const AstGateResultSchema: z.ZodObject<{
|
|
34
34
|
passed: z.ZodBoolean;
|
|
35
35
|
violations: z.ZodArray<z.ZodObject<{
|
|
@@ -42,14 +42,14 @@ export declare const AstGateResultSchema: z.ZodObject<{
|
|
|
42
42
|
error: "error";
|
|
43
43
|
warning: "warning";
|
|
44
44
|
}>;
|
|
45
|
-
}, z.core.$
|
|
46
|
-
}, z.core.$
|
|
45
|
+
}, z.core.$strict>>;
|
|
46
|
+
}, z.core.$strict>;
|
|
47
47
|
export declare const ExternalApiCallSchema: z.ZodObject<{
|
|
48
48
|
file: z.ZodString;
|
|
49
49
|
line: z.ZodNumber;
|
|
50
50
|
api: z.ZodString;
|
|
51
51
|
version: z.ZodString;
|
|
52
|
-
}, z.core.$
|
|
52
|
+
}, z.core.$strict>;
|
|
53
53
|
export declare const ImplOutputSchema: z.ZodObject<{
|
|
54
54
|
version: z.ZodLiteral<"1.0">;
|
|
55
55
|
sha256: z.ZodString;
|
|
@@ -61,7 +61,7 @@ export declare const ImplOutputSchema: z.ZodObject<{
|
|
|
61
61
|
line: z.ZodNumber;
|
|
62
62
|
api: z.ZodString;
|
|
63
63
|
version: z.ZodString;
|
|
64
|
-
}, z.core.$
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
65
|
astGateResult: z.ZodObject<{
|
|
66
66
|
passed: z.ZodBoolean;
|
|
67
67
|
violations: z.ZodArray<z.ZodObject<{
|
|
@@ -74,9 +74,9 @@ export declare const ImplOutputSchema: z.ZodObject<{
|
|
|
74
74
|
error: "error";
|
|
75
75
|
warning: "warning";
|
|
76
76
|
}>;
|
|
77
|
-
}, z.core.$
|
|
78
|
-
}, z.core.$
|
|
79
|
-
}, z.core.$
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
}, z.core.$strict>;
|
|
80
80
|
export type ImplOutput = z.infer<typeof ImplOutputSchema>;
|
|
81
81
|
export type AstViolation = z.infer<typeof AstViolationSchema>;
|
|
82
82
|
export type AstGateResult = z.infer<typeof AstGateResultSchema>;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* TACT.sig inputSig chain must reference STRAT.sig.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
export const StrategyOutputSchema = z
|
|
8
|
+
export const StrategyOutputSchema = z
|
|
9
|
+
.object({
|
|
9
10
|
version: z.literal('1.0'),
|
|
10
11
|
sha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
11
12
|
generatedAt: z.string().datetime(),
|
|
@@ -18,27 +19,36 @@ export const StrategyOutputSchema = z.object({
|
|
|
18
19
|
question: z.string(),
|
|
19
20
|
options: z.array(z.string())
|
|
20
21
|
})
|
|
22
|
+
.strict()
|
|
21
23
|
.optional()
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export const AstViolationSchema = z
|
|
27
|
+
.object({
|
|
24
28
|
file: z.string(),
|
|
25
29
|
line: z.number().int(),
|
|
26
30
|
api: z.string(),
|
|
27
31
|
expectedVersion: z.string(),
|
|
28
32
|
actualVersion: z.string(),
|
|
29
33
|
severity: z.enum(['error', 'warning'])
|
|
30
|
-
})
|
|
31
|
-
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
export const AstGateResultSchema = z
|
|
37
|
+
.object({
|
|
32
38
|
passed: z.boolean(),
|
|
33
39
|
violations: z.array(AstViolationSchema)
|
|
34
|
-
})
|
|
35
|
-
|
|
40
|
+
})
|
|
41
|
+
.strict();
|
|
42
|
+
export const ExternalApiCallSchema = z
|
|
43
|
+
.object({
|
|
36
44
|
file: z.string(),
|
|
37
45
|
line: z.number().int(),
|
|
38
46
|
api: z.string(),
|
|
39
47
|
version: z.string()
|
|
40
|
-
})
|
|
41
|
-
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
export const ImplOutputSchema = z
|
|
51
|
+
.object({
|
|
42
52
|
version: z.literal('1.0'),
|
|
43
53
|
sha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
44
54
|
generatedAt: z.string().datetime(),
|
|
@@ -46,4 +56,5 @@ export const ImplOutputSchema = z.object({
|
|
|
46
56
|
changedFiles: z.array(z.string()),
|
|
47
57
|
externalApiCalls: z.array(ExternalApiCallSchema),
|
|
48
58
|
astGateResult: AstGateResultSchema
|
|
49
|
-
})
|
|
59
|
+
})
|
|
60
|
+
.strict();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peaks-loop",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.10",
|
|
4
4
|
"description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
|
|
5
5
|
"author": "SquabbyZ",
|
|
6
6
|
"keywords": [
|
|
@@ -129,10 +129,10 @@
|
|
|
129
129
|
"picomatch": "4.0.4",
|
|
130
130
|
"yaml": "^2.9.0",
|
|
131
131
|
"zod": "^4.4.3",
|
|
132
|
-
"peaks-loop-internal-runtime": "0.0.
|
|
133
|
-
"peaks-loop-
|
|
134
|
-
"peaks-loop-shared": "0.0.
|
|
135
|
-
"peaks-loop-
|
|
132
|
+
"peaks-loop-internal-runtime": "0.0.50",
|
|
133
|
+
"peaks-loop-shared-channel": "0.0.67",
|
|
134
|
+
"peaks-loop-shared": "0.0.99",
|
|
135
|
+
"peaks-loop-mut": "0.1.64"
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
138
|
"@changesets/cli": "2.31.1",
|
|
@@ -297,12 +297,34 @@ peaks-rd runs in two sub-stages:
|
|
|
297
297
|
Hard constraint: TACT.sig cannot be written when the AST gate has violations.
|
|
298
298
|
The LLM auto-fixes and retries (peaks-qa's 3-cycle repair cap).
|
|
299
299
|
|
|
300
|
+
Registered CLI surface (one-axis: `--session-id` required, every `--out` under
|
|
301
|
+
`.peaks/_runtime/<sid>/`):
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
peaks strat write --project <repo> --session-id <sid> \
|
|
305
|
+
--out .peaks/_runtime/<sid>/rd/strategy.md \
|
|
306
|
+
--goal <text> --root-cause <text> --impact <paths...> --design <text> --json
|
|
307
|
+
# writes strategy.md + its JSON sibling (.peaks/_runtime/<sid>/rd/strategy.md.json)
|
|
308
|
+
|
|
309
|
+
peaks tact write --project <repo> --session-id <sid> \
|
|
310
|
+
--strategy .peaks/_runtime/<sid>/rd/strategy.md.json \
|
|
311
|
+
--out .peaks/_runtime/<sid>/rd/impl.json \
|
|
312
|
+
--changed-files <paths...> [--ast-context '<json>'] --json
|
|
313
|
+
|
|
314
|
+
peaks tact read --artifact .peaks/_runtime/<sid>/rd/impl.json --project <repo> --json
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
`tact write` never accepts a raw `--input-sig`: it re-verifies the strategy
|
|
318
|
+
JSON's recomputed sha256 and refuses a tampered artifact. `tact read` does the
|
|
319
|
+
same for `impl.json` and prints `{ sha256, inputSig, changedFiles, astGateResult }`.
|
|
320
|
+
|
|
300
321
|
Karpathy guidelines remain injected in both sub-stages.
|
|
301
322
|
|
|
302
|
-
Public entry points (from `src/services/rd/rd-service.ts`)
|
|
323
|
+
Public entry points (from `src/services/rd/rd-service.ts`) are unchanged; the
|
|
324
|
+
commands above are thin wrappers over them:
|
|
303
325
|
|
|
304
|
-
- `runStrategic(input: RunStrategicInput): Promise<StrategyOutput>` — strategy writer
|
|
305
|
-
- `runTactical(input: RunTacticalInput): Promise<ImplOutput>` — runs AST gate then writes impl.json + TACT.sig chained to inputSig
|
|
326
|
+
- `runStrategic(input: RunStrategicInput): Promise<StrategyOutput>` — strategy writer (`peaks strat write`)
|
|
327
|
+
- `runTactical(input: RunTacticalInput): Promise<ImplOutput>` — runs AST gate then writes impl.json + TACT.sig chained to inputSig (`peaks tact write`)
|
|
306
328
|
|
|
307
329
|
## References
|
|
308
330
|
|