@tekyzinc/gsd-t 3.23.11 → 3.25.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/CHANGELOG.md +48 -0
- package/README.md +7 -0
- package/bin/cli-preflight-checks/branch-guard.cjs +110 -0
- package/bin/cli-preflight-checks/contracts-stable.cjs +128 -0
- package/bin/cli-preflight-checks/deps-installed.cjs +89 -0
- package/bin/cli-preflight-checks/manifest-fresh.cjs +98 -0
- package/bin/cli-preflight-checks/ports-free.cjs +110 -0
- package/bin/cli-preflight-checks/working-tree-state.cjs +149 -0
- package/bin/cli-preflight.cjs +265 -0
- package/bin/gsd-t-context-brief-kinds/design-verify.cjs +139 -0
- package/bin/gsd-t-context-brief-kinds/execute.cjs +205 -0
- package/bin/gsd-t-context-brief-kinds/qa.cjs +130 -0
- package/bin/gsd-t-context-brief-kinds/red-team.cjs +131 -0
- package/bin/gsd-t-context-brief-kinds/scan.cjs +118 -0
- package/bin/gsd-t-context-brief-kinds/verify.cjs +157 -0
- package/bin/gsd-t-context-brief.cjs +395 -0
- package/bin/gsd-t-ratelimit-probe-worker.cjs +236 -0
- package/bin/gsd-t-ratelimit-probe.cjs +648 -0
- package/bin/gsd-t-verify-gate-judge.cjs +224 -0
- package/bin/gsd-t-verify-gate.cjs +612 -0
- package/bin/gsd-t.js +45 -1
- package/bin/live-activity-report.cjs +615 -0
- package/bin/m55-substrate-proof.cjs +134 -0
- package/bin/parallel-cli-tee.cjs +206 -0
- package/bin/parallel-cli.cjs +478 -0
- package/commands/gsd-t-execute.md +31 -0
- package/commands/gsd-t-help.md +21 -0
- package/commands/gsd-t-verify.md +38 -0
- package/docs/architecture.md +194 -0
- package/docs/diagrams/.gsd-t/.context-meter-state.json +10 -0
- package/docs/diagrams/.gsd-t/context-meter.log +9 -0
- package/docs/diagrams/.gsd-t/events/2026-05-08.jsonl +45 -0
- package/docs/diagrams/.gsd-t/events/2026-05-09.jsonl +1 -0
- package/docs/diagrams/.gsd-t/heartbeat-cd9e7f59-ba5b-406a-9ed6-16762f039e81.jsonl +48 -0
- package/docs/diagrams/01-top-level-map-d2.png +0 -0
- package/docs/diagrams/01-top-level-map.d2 +77 -0
- package/docs/diagrams/01-top-level-map.mmd +48 -0
- package/docs/diagrams/01-top-level-map.png +0 -0
- package/docs/diagrams/01-top-level-map.svg +126 -0
- package/docs/diagrams/02-milestone-lifecycle-d2.png +0 -0
- package/docs/diagrams/02-milestone-lifecycle.d2 +38 -0
- package/docs/diagrams/02-milestone-lifecycle.mmd +36 -0
- package/docs/diagrams/02-milestone-lifecycle.png +0 -0
- package/docs/diagrams/02-milestone-lifecycle.svg +114 -0
- package/docs/diagrams/03-wave-mode-d2.png +0 -0
- package/docs/diagrams/03-wave-mode.d2 +33 -0
- package/docs/diagrams/03-wave-mode.mmd +21 -0
- package/docs/diagrams/03-wave-mode.png +0 -0
- package/docs/diagrams/03-wave-mode.svg +113 -0
- package/docs/diagrams/04-design-to-code-d2.png +0 -0
- package/docs/diagrams/04-design-to-code.d2 +35 -0
- package/docs/diagrams/04-design-to-code.mmd +29 -0
- package/docs/diagrams/04-design-to-code.png +0 -0
- package/docs/diagrams/04-design-to-code.svg +115 -0
- package/docs/diagrams/05-backlog-d2.png +0 -0
- package/docs/diagrams/05-backlog.d2 +40 -0
- package/docs/diagrams/05-backlog.mmd +20 -0
- package/docs/diagrams/05-backlog.png +0 -0
- package/docs/diagrams/05-backlog.svg +113 -0
- package/docs/diagrams/06-automation-utilities-d2.png +0 -0
- package/docs/diagrams/06-automation-utilities.d2 +48 -0
- package/docs/diagrams/06-automation-utilities.mmd +47 -0
- package/docs/diagrams/06-automation-utilities.png +0 -0
- package/docs/diagrams/06-automation-utilities.svg +110 -0
- package/docs/diagrams/_theme.d2 +86 -0
- package/docs/requirements.md +48 -0
- package/docs/workflow-diagram.md +338 -0
- package/package.json +1 -1
- package/scripts/gsd-t-dashboard-server.js +190 -0
- package/scripts/gsd-t-transcript.html +200 -0
- package/templates/CLAUDE-global.md +46 -0
- package/templates/prompts/design-verify-subagent.md +3 -0
- package/templates/prompts/qa-subagent.md +3 -0
- package/templates/prompts/red-team-subagent.md +3 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* GSD-T Rate-Limit Probe — Single-Worker Child (M55 D3)
|
|
6
|
+
*
|
|
7
|
+
* Reads a synthetic context fixture from disk, spawns ONE
|
|
8
|
+
* `claude -p --dangerously-skip-permissions` child with a
|
|
9
|
+
* deterministic small prompt, captures:
|
|
10
|
+
* - ttftMs: spawn-start → first non-empty stdout byte
|
|
11
|
+
* - totalMs: spawn-start → child exit
|
|
12
|
+
* - status429:true iff stderr matches /rate.?limit/i or exit indicates 429
|
|
13
|
+
* - retryAfterMs: parsed from stderr `retry-after` hint when present
|
|
14
|
+
* - exitCode: child exit code (or null on signal)
|
|
15
|
+
*
|
|
16
|
+
* Emits exactly ONE NDJSON line on stdout containing the result envelope.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* node bin/gsd-t-ratelimit-probe-worker.cjs \
|
|
20
|
+
* --fixture <path> --worker-id <id> --cell-workers <N> \
|
|
21
|
+
* --cell-context-tokens <T> --run-idx <i> [--prompt-extra <text>] \
|
|
22
|
+
* [--cwd <dir>]
|
|
23
|
+
*
|
|
24
|
+
* Contract: .gsd-t/contracts/ratelimit-map-contract.md v1.0.0 STABLE
|
|
25
|
+
*
|
|
26
|
+
* The PARENT (sweep runner) is responsible for:
|
|
27
|
+
* - flowing this spawn through `bin/gsd-t-token-capture.cjs::captureSpawn`
|
|
28
|
+
* - aggregating multiple worker NDJSON lines into a cell summary
|
|
29
|
+
* - throwaway worktree management
|
|
30
|
+
*
|
|
31
|
+
* This file is the per-worker leaf; it does NOT call captureSpawn itself.
|
|
32
|
+
*
|
|
33
|
+
* Zero external deps (Node built-ins only).
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const fs = require('fs');
|
|
37
|
+
const path = require('path');
|
|
38
|
+
const { spawn } = require('child_process');
|
|
39
|
+
|
|
40
|
+
function parseArgs(argv) {
|
|
41
|
+
const args = {};
|
|
42
|
+
for (let i = 2; i < argv.length; i++) {
|
|
43
|
+
const a = argv[i];
|
|
44
|
+
if (a.startsWith('--')) {
|
|
45
|
+
const key = a.slice(2);
|
|
46
|
+
const next = argv[i + 1];
|
|
47
|
+
if (next != null && !next.startsWith('--')) {
|
|
48
|
+
args[key] = next;
|
|
49
|
+
i++;
|
|
50
|
+
} else {
|
|
51
|
+
args[key] = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return args;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const SMALL_PROMPT = 'Reply with only the number 42';
|
|
59
|
+
const RATE_LIMIT_RE = /rate.?limit|429|too.?many.?requests/i;
|
|
60
|
+
const RETRY_AFTER_MS_RE = /retry-after-ms[:\s]+(\d+)/i;
|
|
61
|
+
const RETRY_AFTER_S_RE = /retry-after[:\s]+(\d+)(?!\s*ms)/i;
|
|
62
|
+
|
|
63
|
+
function detectRetryAfterMs(stderr) {
|
|
64
|
+
const m1 = stderr.match(RETRY_AFTER_MS_RE);
|
|
65
|
+
if (m1) return parseInt(m1[1], 10);
|
|
66
|
+
const m2 = stderr.match(RETRY_AFTER_S_RE);
|
|
67
|
+
if (m2) return parseInt(m2[1], 10) * 1000;
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function runOneProbe({ fixturePath, cwd, claudeBin, model }) {
|
|
72
|
+
let fixtureBody = '';
|
|
73
|
+
try {
|
|
74
|
+
fixtureBody = fs.readFileSync(fixturePath, 'utf8');
|
|
75
|
+
} catch (err) {
|
|
76
|
+
return {
|
|
77
|
+
ttftMs: null,
|
|
78
|
+
totalMs: 0,
|
|
79
|
+
status429: false,
|
|
80
|
+
retryAfterMs: null,
|
|
81
|
+
exitCode: -1,
|
|
82
|
+
failedReason: 'fixture-read-failed: ' + (err && err.message || err),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Prompt = fixture context + a deterministic micro-question.
|
|
86
|
+
// The fixture inflates the input-token side; the model answers tersely.
|
|
87
|
+
const prompt = fixtureBody + '\n\n' + SMALL_PROMPT;
|
|
88
|
+
|
|
89
|
+
const args = ['-p', '--dangerously-skip-permissions', '--print'];
|
|
90
|
+
if (model) {
|
|
91
|
+
args.push('--model', model);
|
|
92
|
+
}
|
|
93
|
+
args.push(prompt);
|
|
94
|
+
|
|
95
|
+
return await new Promise((resolve) => {
|
|
96
|
+
const t0 = process.hrtime.bigint();
|
|
97
|
+
let firstByteAt = null;
|
|
98
|
+
let stdout = '';
|
|
99
|
+
let stderr = '';
|
|
100
|
+
let settled = false;
|
|
101
|
+
|
|
102
|
+
let child;
|
|
103
|
+
try {
|
|
104
|
+
child = spawn(claudeBin, args, {
|
|
105
|
+
cwd: cwd || process.cwd(),
|
|
106
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
107
|
+
env: { ...process.env },
|
|
108
|
+
});
|
|
109
|
+
} catch (err) {
|
|
110
|
+
resolve({
|
|
111
|
+
ttftMs: null,
|
|
112
|
+
totalMs: 0,
|
|
113
|
+
status429: false,
|
|
114
|
+
retryAfterMs: null,
|
|
115
|
+
exitCode: -1,
|
|
116
|
+
failedReason: 'spawn-threw: ' + (err && err.message || err),
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
child.stdout.on('data', (chunk) => {
|
|
122
|
+
if (firstByteAt === null) firstByteAt = process.hrtime.bigint();
|
|
123
|
+
stdout += chunk.toString();
|
|
124
|
+
});
|
|
125
|
+
child.stderr.on('data', (chunk) => {
|
|
126
|
+
stderr += chunk.toString();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
child.on('error', (err) => {
|
|
130
|
+
if (settled) return;
|
|
131
|
+
settled = true;
|
|
132
|
+
const t1 = process.hrtime.bigint();
|
|
133
|
+
resolve({
|
|
134
|
+
ttftMs: firstByteAt ? Number(firstByteAt - t0) / 1e6 : null,
|
|
135
|
+
totalMs: Number(t1 - t0) / 1e6,
|
|
136
|
+
status429: RATE_LIMIT_RE.test(stderr),
|
|
137
|
+
retryAfterMs: detectRetryAfterMs(stderr),
|
|
138
|
+
exitCode: -1,
|
|
139
|
+
failedReason: 'child-error: ' + (err && err.message || err),
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
child.on('exit', (code, signal) => {
|
|
144
|
+
if (settled) return;
|
|
145
|
+
settled = true;
|
|
146
|
+
const t1 = process.hrtime.bigint();
|
|
147
|
+
const totalMs = Number(t1 - t0) / 1e6;
|
|
148
|
+
const ttftMs = firstByteAt ? Number(firstByteAt - t0) / 1e6 : null;
|
|
149
|
+
const is429 = RATE_LIMIT_RE.test(stderr);
|
|
150
|
+
let failedReason = null;
|
|
151
|
+
if (code !== 0 && !is429) {
|
|
152
|
+
failedReason = 'exit-' + code + (signal ? '-' + signal : '') +
|
|
153
|
+
(stderr ? ': ' + stderr.slice(0, 200).replace(/\s+/g, ' ').trim() : '');
|
|
154
|
+
}
|
|
155
|
+
resolve({
|
|
156
|
+
ttftMs,
|
|
157
|
+
totalMs,
|
|
158
|
+
status429: is429,
|
|
159
|
+
retryAfterMs: is429 ? detectRetryAfterMs(stderr) : null,
|
|
160
|
+
exitCode: code == null ? -1 : code,
|
|
161
|
+
failedReason,
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Hard timeout per probe: 90s (covers 100k-context worst-case).
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
if (settled) return;
|
|
168
|
+
try { child.kill('SIGKILL'); } catch (_) {}
|
|
169
|
+
}, 90000);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function main() {
|
|
174
|
+
const args = parseArgs(process.argv);
|
|
175
|
+
const fixturePath = args.fixture;
|
|
176
|
+
if (!fixturePath) {
|
|
177
|
+
process.stderr.write('ERROR: --fixture <path> required\n');
|
|
178
|
+
process.exit(2);
|
|
179
|
+
}
|
|
180
|
+
const workerId = args['worker-id'] || 'w0';
|
|
181
|
+
const cellWorkers = parseInt(args['cell-workers'] || '1', 10);
|
|
182
|
+
const cellContextTokens = parseInt(args['cell-context-tokens'] || '0', 10);
|
|
183
|
+
const runIdx = parseInt(args['run-idx'] || '0', 10);
|
|
184
|
+
const cwd = args.cwd || process.cwd();
|
|
185
|
+
const claudeBin = args['claude-bin'] || process.env.GSD_T_CLAUDE_BIN || 'claude';
|
|
186
|
+
const model = args.model || process.env.GSD_T_PROBE_MODEL || 'claude-haiku-4-5';
|
|
187
|
+
|
|
188
|
+
const probeStart = Date.now();
|
|
189
|
+
const result = await runOneProbe({ fixturePath, cwd, claudeBin, model });
|
|
190
|
+
const probeEnd = Date.now();
|
|
191
|
+
|
|
192
|
+
const envelope = {
|
|
193
|
+
workerId,
|
|
194
|
+
cellWorkers,
|
|
195
|
+
cellContextTokens,
|
|
196
|
+
runIdx,
|
|
197
|
+
ttftMs: result.ttftMs,
|
|
198
|
+
totalMs: result.totalMs,
|
|
199
|
+
status429: result.status429,
|
|
200
|
+
retryAfterMs: result.retryAfterMs,
|
|
201
|
+
exitCode: result.exitCode,
|
|
202
|
+
failedReason: result.failedReason,
|
|
203
|
+
startedAt: new Date(probeStart).toISOString(),
|
|
204
|
+
endedAt: new Date(probeEnd).toISOString(),
|
|
205
|
+
model,
|
|
206
|
+
fixturePath,
|
|
207
|
+
};
|
|
208
|
+
process.stdout.write(JSON.stringify(envelope) + '\n');
|
|
209
|
+
// Exit 0 even on rate-limit/CLI failure — the parent reads the envelope, not the exit code.
|
|
210
|
+
process.exit(0);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (require.main === module) {
|
|
214
|
+
main().catch((err) => {
|
|
215
|
+
process.stderr.write('UNCAUGHT: ' + (err && err.stack || err) + '\n');
|
|
216
|
+
// Emit a failure envelope so the parent has structured data.
|
|
217
|
+
const envelope = {
|
|
218
|
+
workerId: 'unknown',
|
|
219
|
+
cellWorkers: 0,
|
|
220
|
+
cellContextTokens: 0,
|
|
221
|
+
runIdx: 0,
|
|
222
|
+
ttftMs: null,
|
|
223
|
+
totalMs: 0,
|
|
224
|
+
status429: false,
|
|
225
|
+
retryAfterMs: null,
|
|
226
|
+
exitCode: -1,
|
|
227
|
+
failedReason: 'uncaught: ' + (err && err.message || String(err)),
|
|
228
|
+
startedAt: new Date().toISOString(),
|
|
229
|
+
endedAt: new Date().toISOString(),
|
|
230
|
+
};
|
|
231
|
+
try { process.stdout.write(JSON.stringify(envelope) + '\n'); } catch (_) {}
|
|
232
|
+
process.exit(1);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
module.exports = { runOneProbe, detectRetryAfterMs, RATE_LIMIT_RE };
|