@event4u/agent-config 7.2.0 → 7.4.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +74 -0
- package/README.md +9 -10
- package/dist/agent-src/commands/fix/pr-comments.md +42 -13
- package/dist/agent-src/rules/cli-output-handling.md +18 -0
- package/dist/agent-src/skills/bug-analyzer/evals/evals.json +13 -0
- package/dist/agent-src/skills/code-review/evals/evals.json +21 -0
- package/dist/cli/registry.js +1 -0
- package/dist/cli/registry.js.map +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +4 -4
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +2 -2
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +2 -2
- package/dist/mcp/registry-manifest.json +2 -2
- package/dist/router.json +1 -1
- package/dist/server/schemas/settings.js +3 -0
- package/dist/server/schemas/settings.js.map +1 -1
- package/docs/contracts/governance-enforcement-projection.md +154 -0
- package/docs/enforcement-by-host.md +44 -0
- package/docs/governance-advantage.md +72 -0
- package/package.json +2 -1
- package/src/config/agent-settings.template.yml +9 -0
- package/src/scripts/_cli/cmd_analyze_session.ts +347 -0
- package/src/scripts/_dispatch.bash +8 -0
- package/src/scripts/_lib/eval_discrimination.ts +95 -0
- package/src/scripts/_lib/token_count.ts +110 -35
- package/src/scripts/_lib/trigger_routers.ts +268 -0
- package/src/scripts/audit_initial_context.ts +37 -12
- package/src/scripts/bench_ab_v2_run.ts +38 -0
- package/src/scripts/bench_quality_run.ts +253 -0
- package/src/scripts/bench_rule_load_latency.ts +178 -0
- package/src/scripts/check_kernel_prefix_stability.ts +0 -0
- package/src/scripts/check_quality_regression.ts +244 -0
- package/src/scripts/check_token_quality_golden.ts +253 -0
- package/src/scripts/check_token_regression.ts +266 -0
- package/src/scripts/cross_model_smoke.ts +245 -0
- package/src/scripts/hook_manifest.yaml +15 -3
- package/src/scripts/hooks/rtk_wrap_hook.ts +228 -0
- package/src/scripts/probe_host_compliance.ts +145 -0
- package/src/scripts/run_skill_evals.ts +38 -0
- package/src/scripts/skill_linter.ts +26 -10
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* PreToolUse RTK-wrap nudge — deterministic, warn-in-context
|
|
4
|
+
* (token-saving Phase 3).
|
|
5
|
+
*
|
|
6
|
+
* Converts RTK from advisory to DETERMINISTIC: instead of trusting a
|
|
7
|
+
* self-reported flag, this hook keys off a live `which rtk` probe. When rtk is
|
|
8
|
+
* actually installed AND the agent is about to run a single verbose CLI command
|
|
9
|
+
* that is NOT completeness-critical, it surfaces (warn) "re-run wrapped with
|
|
10
|
+
* rtk" so the 60–90% output-token saving is captured. It NEVER blocks (the v1
|
|
11
|
+
* dispatcher contract is allow/block/warn — there is no transparent
|
|
12
|
+
* `updatedInput` rewrite — and, like `injection_scan_hook`, warn preserves
|
|
13
|
+
* agency). It NEVER fires when rtk is absent (silent plain-command fallback,
|
|
14
|
+
* no nag).
|
|
15
|
+
*
|
|
16
|
+
* Default-OFF. Fires only when `hooks.rtk_wrap.enabled: true` in
|
|
17
|
+
* `.agent-settings.yml`. Disabled / missing / rtk-absent → no-op exit 0.
|
|
18
|
+
* fail_closed: false — any parse/probe error returns allow (never break a
|
|
19
|
+
* command for a token optimization).
|
|
20
|
+
*
|
|
21
|
+
* Denylist (never nudged — completeness-critical or already-handled):
|
|
22
|
+
* - `git diff` / `rtk read` (silent truncation risk — see the rtk skill)
|
|
23
|
+
* - already `rtk …` wrapped, or piped / compound (`|`, `&&`, `||`, `;`)
|
|
24
|
+
* - any program not in the verbose-CLI allowlist
|
|
25
|
+
*
|
|
26
|
+
* Exit codes (dispatcher contract): 0 allow · 2 warn (+ JSON reason on stdout).
|
|
27
|
+
*/
|
|
28
|
+
import fs from "node:fs";
|
|
29
|
+
import path from "node:path";
|
|
30
|
+
import { pathToFileURL } from "node:url";
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
shlexSplit,
|
|
34
|
+
ShlexError,
|
|
35
|
+
_split_subcommands,
|
|
36
|
+
_is_env_assignment,
|
|
37
|
+
} from "./block_no_verify.js";
|
|
38
|
+
|
|
39
|
+
const SETTINGS_FILE = ".agent-settings.yml";
|
|
40
|
+
const EXIT_ALLOW = 0;
|
|
41
|
+
const EXIT_WARN = 2;
|
|
42
|
+
|
|
43
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | { [k: string]: JsonValue };
|
|
44
|
+
type JsonObject = { [k: string]: JsonValue };
|
|
45
|
+
|
|
46
|
+
// Verbose-CLI programs worth wrapping — mirrors the cli-output-handling rule
|
|
47
|
+
// triggers + the rtk skill's "✅ Always" table. Kept in sync with
|
|
48
|
+
// src/rules/cli-output-handling.md.
|
|
49
|
+
const _RTK_PROGRAMS: ReadonlySet<string> = new Set([
|
|
50
|
+
"git", "phpstan", "rector", "phpunit", "composer",
|
|
51
|
+
"npm", "pnpm", "yarn", "eslint", "tsc", "vitest", "jest",
|
|
52
|
+
"pytest", "ruff", "mypy", "pyright", "cargo", "go",
|
|
53
|
+
"golangci-lint", "docker", "kubectl", "terraform",
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
function _isObject(v: unknown): v is JsonObject {
|
|
57
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** `hooks.rtk_wrap.enabled: true` mini-parser (mirrors injection_scan_hook). */
|
|
61
|
+
function _enabled(root: string): boolean {
|
|
62
|
+
const f = path.join(root, SETTINGS_FILE);
|
|
63
|
+
try {
|
|
64
|
+
if (!fs.statSync(f).isFile()) return false;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
let text: string;
|
|
69
|
+
try {
|
|
70
|
+
text = fs.readFileSync(f, "utf-8");
|
|
71
|
+
} catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
let in_hooks = false;
|
|
75
|
+
let in_rw = false;
|
|
76
|
+
const lines = text.split(/\r\n|\r|\n/);
|
|
77
|
+
if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
78
|
+
for (const raw of lines) {
|
|
79
|
+
const line = raw.replace(/\s+$/, "");
|
|
80
|
+
if (!line || line.replace(/^\s+/, "").startsWith("#")) continue;
|
|
81
|
+
if (!(line.startsWith(" ") || line.startsWith("\t"))) {
|
|
82
|
+
in_hooks = /^hooks\s*:\s*$/.test(line);
|
|
83
|
+
in_rw = false;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (in_hooks) {
|
|
87
|
+
if (/^\s+rtk_wrap\s*:\s*$/.test(line)) {
|
|
88
|
+
in_rw = true;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (in_rw && /^\s{0,3}\S/.test(line)) in_rw = false;
|
|
92
|
+
}
|
|
93
|
+
if (in_rw && /^\s+enabled\s*:\s*true\b/.test(line)) return true;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Live `which rtk` — scan PATH for an executable `rtk` (cross-platform). */
|
|
99
|
+
export function rtk_available(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
100
|
+
const pathVar = env.PATH ?? env.Path ?? "";
|
|
101
|
+
if (!pathVar) return false;
|
|
102
|
+
const dirs = pathVar.split(path.delimiter).filter(Boolean);
|
|
103
|
+
// On Windows the launcher is rtk.exe / rtk.cmd / rtk.bat.
|
|
104
|
+
const exts = process.platform === "win32" ? ["", ".exe", ".cmd", ".bat"] : [""];
|
|
105
|
+
for (const dir of dirs) {
|
|
106
|
+
for (const ext of exts) {
|
|
107
|
+
const candidate = path.join(dir, `rtk${ext}`);
|
|
108
|
+
try {
|
|
109
|
+
const st = fs.statSync(candidate);
|
|
110
|
+
if (st.isFile()) {
|
|
111
|
+
// POSIX: require an executable bit; Windows: extension is enough.
|
|
112
|
+
if (process.platform === "win32" || (st.mode & 0o111) !== 0) return true;
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
/* not here — keep scanning */
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function _extract_command(envelope: JsonObject): string | null {
|
|
123
|
+
const payload = (_isObject(envelope["payload"]) ? envelope["payload"] : {}) as JsonObject;
|
|
124
|
+
const tool_input = (_isObject(payload["tool_input"]) ? payload["tool_input"] : {}) as JsonObject;
|
|
125
|
+
for (const src of [tool_input["command"], payload["command"], envelope["command"]]) {
|
|
126
|
+
if (typeof src === "string") return src;
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface Eligibility {
|
|
132
|
+
eligible: boolean;
|
|
133
|
+
program?: string;
|
|
134
|
+
reason_skip?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* A command is eligible for an rtk-wrap nudge iff it is a SINGLE simple command
|
|
139
|
+
* (no pipe / compound separators), whose program is a known verbose CLI, and is
|
|
140
|
+
* not a completeness-critical / already-wrapped case.
|
|
141
|
+
*/
|
|
142
|
+
export function classify(command: string): Eligibility {
|
|
143
|
+
const cmd = command.trim();
|
|
144
|
+
if (!cmd) return { eligible: false, reason_skip: "empty" };
|
|
145
|
+
|
|
146
|
+
let tokens: string[];
|
|
147
|
+
try {
|
|
148
|
+
tokens = shlexSplit(cmd);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
if (e instanceof ShlexError) return { eligible: false, reason_skip: "parse-error" };
|
|
151
|
+
throw e;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Compound / piped → don't wrap (rtk wraps a single command). `_split_subcommands`
|
|
155
|
+
// splits on && || ; | — more than one group means a pipeline/chain.
|
|
156
|
+
const groups = _split_subcommands(tokens);
|
|
157
|
+
if (groups.length !== 1) return { eligible: false, reason_skip: "compound-or-piped" };
|
|
158
|
+
|
|
159
|
+
const sub = groups[0] as string[];
|
|
160
|
+
let i = 0;
|
|
161
|
+
while (i < sub.length && _is_env_assignment(sub[i] as string)) i += 1;
|
|
162
|
+
const program = sub[i];
|
|
163
|
+
if (!program) return { eligible: false, reason_skip: "no-program" };
|
|
164
|
+
if (program === "rtk") return { eligible: false, reason_skip: "already-rtk" };
|
|
165
|
+
if (!_RTK_PROGRAMS.has(program)) return { eligible: false, program, reason_skip: "not-verbose-cli" };
|
|
166
|
+
// `git diff` is completeness-critical (silent truncation) — never wrap.
|
|
167
|
+
if (program === "git" && sub[i + 1] === "diff") {
|
|
168
|
+
return { eligible: false, program, reason_skip: "git-diff-denylisted" };
|
|
169
|
+
}
|
|
170
|
+
return { eligible: true, program };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function _readStdin(): string {
|
|
174
|
+
try {
|
|
175
|
+
if (process.stdin.isTTY) return "";
|
|
176
|
+
return fs.readFileSync(0, "utf-8");
|
|
177
|
+
} catch {
|
|
178
|
+
return "";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function _jsonReason(reason: string): string {
|
|
183
|
+
return JSON.stringify({ decision: "warn", reason });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function main(): number {
|
|
187
|
+
let envelope: JsonValue;
|
|
188
|
+
try {
|
|
189
|
+
const raw = _readStdin();
|
|
190
|
+
envelope = raw.trim() ? (JSON.parse(raw) as JsonValue) : {};
|
|
191
|
+
} catch {
|
|
192
|
+
return EXIT_ALLOW; // never break a command on a malformed envelope
|
|
193
|
+
}
|
|
194
|
+
if (!_isObject(envelope)) return EXIT_ALLOW;
|
|
195
|
+
|
|
196
|
+
const cwd = envelope["cwd"];
|
|
197
|
+
const projectRoot = envelope["workspace_root"] ?? envelope["project_root"];
|
|
198
|
+
const root =
|
|
199
|
+
typeof cwd === "string" && cwd
|
|
200
|
+
? cwd
|
|
201
|
+
: typeof projectRoot === "string" && projectRoot
|
|
202
|
+
? projectRoot
|
|
203
|
+
: ".";
|
|
204
|
+
if (!_enabled(root)) return EXIT_ALLOW;
|
|
205
|
+
|
|
206
|
+
// Deterministic gate: the live probe, NOT a self-reported flag.
|
|
207
|
+
if (!rtk_available()) return EXIT_ALLOW;
|
|
208
|
+
|
|
209
|
+
const command = _extract_command(envelope);
|
|
210
|
+
if (!command) return EXIT_ALLOW;
|
|
211
|
+
|
|
212
|
+
const verdict = classify(command);
|
|
213
|
+
if (!verdict.eligible) return EXIT_ALLOW;
|
|
214
|
+
|
|
215
|
+
const reason =
|
|
216
|
+
`rtk is installed and wraps verbose CLI output (60–90% fewer output tokens). ` +
|
|
217
|
+
`Re-run wrapped: \`rtk ${command.trim()}\`. ` +
|
|
218
|
+
`(Skip for completeness-critical output like \`git diff\`.)`;
|
|
219
|
+
process.stdout.write(`${_jsonReason(reason)}\n`);
|
|
220
|
+
return EXIT_WARN;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const _isCliEntry =
|
|
224
|
+
process.argv[1] !== undefined &&
|
|
225
|
+
import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
|
226
|
+
if (_isCliEntry) {
|
|
227
|
+
process.exit(main());
|
|
228
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Host-compliance probe for thin projection (token-saving Phase 0).
|
|
4
|
+
*
|
|
5
|
+
* Thin projection is a CONTRACT WITH THE HOST: a non-kernel rule body is
|
|
6
|
+
* demoted to a router pointer, and the host is trusted to load the body only
|
|
7
|
+
* on trigger-match. On a host that reconstructs rule bodies internally (e.g. a
|
|
8
|
+
* plugin loader that re-inlines everything), thin projection is a silent no-op
|
|
9
|
+
* — so it must be falsified per host before the thin flip ships.
|
|
10
|
+
*
|
|
11
|
+
* This probe has two halves:
|
|
12
|
+
*
|
|
13
|
+
* MECHANICAL (here, automated): run the real thin projector (`thin_entry`)
|
|
14
|
+
* on a canary rule fixture and assert the body is replaced by a pointer that
|
|
15
|
+
* still carries the trigger hint (so the router can select it). This proves
|
|
16
|
+
* the projector demotes correctly — the prerequisite for any host test.
|
|
17
|
+
*
|
|
18
|
+
* LIVE (operator gate): install the thin-projected canary into each host,
|
|
19
|
+
* invoke its keyword, and confirm the host shows the POINTER, not the body.
|
|
20
|
+
* This is a human-run step (live trigger-eval is a human gate) — the probe
|
|
21
|
+
* prints the checklist + a results table to fill in.
|
|
22
|
+
*
|
|
23
|
+
* CLI:
|
|
24
|
+
* ./scripts-run src/scripts/probe_host_compliance # mechanical check + checklist
|
|
25
|
+
* ./scripts-run src/scripts/probe_host_compliance --json
|
|
26
|
+
*
|
|
27
|
+
* Exit codes: 0 demotion verified · 1 file error · 2 projector failed to demote.
|
|
28
|
+
*/
|
|
29
|
+
import * as fs from 'node:fs';
|
|
30
|
+
import * as path from 'node:path';
|
|
31
|
+
import process from 'node:process';
|
|
32
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
33
|
+
|
|
34
|
+
import { thin_entry } from './project_thin_rules.js';
|
|
35
|
+
|
|
36
|
+
const _HERE = fileURLToPath(import.meta.url);
|
|
37
|
+
const REPO_ROOT = path.resolve(path.dirname(_HERE), '..', '..');
|
|
38
|
+
const CANARY = path.join(
|
|
39
|
+
REPO_ROOT,
|
|
40
|
+
'tests/fixtures/host-compliance/host-compliance-canary.md',
|
|
41
|
+
);
|
|
42
|
+
const CANARY_ID = 'host-compliance-canary';
|
|
43
|
+
const SENTINEL = 'CANARY_BODY_SENTINEL_DO_NOT_INLINE';
|
|
44
|
+
const KEYWORD = 'xyzzy-canary-probe';
|
|
45
|
+
const POINTER_MARKER = 'Routed rule — load the body on trigger-match';
|
|
46
|
+
|
|
47
|
+
// The supported hosts whose live thin-compliance must be falsified.
|
|
48
|
+
const HOSTS = ['claude-code', 'cursor', 'augment'];
|
|
49
|
+
|
|
50
|
+
export interface DemotionResult {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
pointer_present: boolean;
|
|
53
|
+
body_removed: boolean;
|
|
54
|
+
trigger_hint_preserved: boolean;
|
|
55
|
+
link_present: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Assert a thinned canary is a valid pointer (body gone, still selectable). */
|
|
59
|
+
export function evaluate_demotion(
|
|
60
|
+
thinned: string,
|
|
61
|
+
opts: { sentinel: string; keyword: string } = { sentinel: SENTINEL, keyword: KEYWORD },
|
|
62
|
+
): DemotionResult {
|
|
63
|
+
const pointer_present = thinned.includes(POINTER_MARKER);
|
|
64
|
+
const body_removed = !thinned.includes(opts.sentinel);
|
|
65
|
+
const trigger_hint_preserved = thinned.includes(opts.keyword);
|
|
66
|
+
const link_present = /Body: \[`[^`]+`\]\(/.test(thinned);
|
|
67
|
+
return {
|
|
68
|
+
ok: pointer_present && body_removed && trigger_hint_preserved && link_present,
|
|
69
|
+
pointer_present,
|
|
70
|
+
body_removed,
|
|
71
|
+
trigger_hint_preserved,
|
|
72
|
+
link_present,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function operator_checklist(): string {
|
|
77
|
+
const rows = HOSTS.map(
|
|
78
|
+
(h) => ` - [ ] ${h}: fires on \`${KEYWORD}\` AND shows the pointer, NOT the body sentinel`,
|
|
79
|
+
).join('\n');
|
|
80
|
+
return (
|
|
81
|
+
'LIVE host-compliance step (operator gate — live trigger-eval is human-run):\n' +
|
|
82
|
+
' 1. Set `lean_projection.mode: thin` and run `task generate-tools && task sync`.\n' +
|
|
83
|
+
' 2. Install the projected canary into each host.\n' +
|
|
84
|
+
` 3. Invoke the keyword \`${KEYWORD}\` in a session on each host.\n` +
|
|
85
|
+
' 4. PASS = the rule fires AND the host surfaces the router pointer;\n' +
|
|
86
|
+
` FAIL = the host surfaces the body sentinel (\`${SENTINEL}\`) → thin\n` +
|
|
87
|
+
' projection is a no-op there; escalate to the host vendor.\n' +
|
|
88
|
+
'Results:\n' +
|
|
89
|
+
rows +
|
|
90
|
+
'\n'
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function main(argv: string[]): number {
|
|
95
|
+
const asJson = argv.includes('--json');
|
|
96
|
+
for (const a of argv) {
|
|
97
|
+
if (!['--json', '-h', '--help'].includes(a)) {
|
|
98
|
+
process.stderr.write(`error: unknown argument: ${a}\n`);
|
|
99
|
+
return 1;
|
|
100
|
+
}
|
|
101
|
+
if (a === '-h' || a === '--help') {
|
|
102
|
+
process.stdout.write('usage: probe_host_compliance [--json]\n');
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let text: string;
|
|
108
|
+
try {
|
|
109
|
+
text = fs.readFileSync(CANARY, 'utf-8');
|
|
110
|
+
} catch {
|
|
111
|
+
process.stderr.write(`error: cannot read canary fixture ${path.relative(REPO_ROOT, CANARY)}\n`);
|
|
112
|
+
return 1;
|
|
113
|
+
}
|
|
114
|
+
const thinned = thin_entry(CANARY_ID, text);
|
|
115
|
+
const result = evaluate_demotion(thinned);
|
|
116
|
+
|
|
117
|
+
if (asJson) {
|
|
118
|
+
process.stdout.write(
|
|
119
|
+
JSON.stringify({ ...result, hosts: HOSTS, keyword: KEYWORD, sentinel: SENTINEL }, null, 2) + '\n',
|
|
120
|
+
);
|
|
121
|
+
return result.ok ? 0 : 2;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
process.stdout.write(
|
|
125
|
+
`${result.ok ? '✅' : '❌'} mechanical demotion: ` +
|
|
126
|
+
`pointer=${result.pointer_present} body-removed=${result.body_removed} ` +
|
|
127
|
+
`hint=${result.trigger_hint_preserved} link=${result.link_present}\n`,
|
|
128
|
+
);
|
|
129
|
+
if (!result.ok) {
|
|
130
|
+
process.stdout.write('❌ the thin projector did NOT demote the canary correctly.\n');
|
|
131
|
+
return 2;
|
|
132
|
+
}
|
|
133
|
+
process.stdout.write('\n' + operator_checklist());
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const _IS_MAIN =
|
|
138
|
+
process.argv[1] !== undefined &&
|
|
139
|
+
import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
|
140
|
+
|
|
141
|
+
if (_IS_MAIN) {
|
|
142
|
+
process.exit(main(process.argv.slice(2)));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export { main };
|
|
@@ -97,6 +97,39 @@ export function _spawn_subagent(
|
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Count "findings" in an eval output for the `finding_floor` assertion
|
|
102
|
+
* (roadmap `road-to-operator-runtime-harvest`, Phase 1). With an explicit
|
|
103
|
+
* `pattern`, counts non-overlapping global regex matches; without one, counts
|
|
104
|
+
* markdown list-item lines (the default shape a skill's findings take).
|
|
105
|
+
*
|
|
106
|
+
* Deterministic on purpose: this only *counts*. The substantive judgement —
|
|
107
|
+
* is each match a real finding, and what should `n` be per host — is the
|
|
108
|
+
* calibration layer (Phase 1 gold set + per-host floor), which is gated on the
|
|
109
|
+
* P0 cross-model distributions and therefore NOT wired here yet. So
|
|
110
|
+
* `finding_floor` is available as a mechanism and exercised by fixtures, but is
|
|
111
|
+
* not an enforcing CI gate until calibrated.
|
|
112
|
+
*/
|
|
113
|
+
export function _count_findings(output: string, pattern?: string): number {
|
|
114
|
+
if (pattern !== undefined && pattern !== '') {
|
|
115
|
+
let re: RegExp;
|
|
116
|
+
try {
|
|
117
|
+
re = new RegExp(pattern, 'g');
|
|
118
|
+
} catch {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
const m = output.match(re);
|
|
122
|
+
return m ? m.length : 0;
|
|
123
|
+
}
|
|
124
|
+
let count = 0;
|
|
125
|
+
for (const line of output.split('\n')) {
|
|
126
|
+
if (/^\s*(?:[-*+]|\d+[.)])\s+\S/.test(line)) {
|
|
127
|
+
count += 1;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return count;
|
|
131
|
+
}
|
|
132
|
+
|
|
100
133
|
export function _grade_assertions(
|
|
101
134
|
output: string,
|
|
102
135
|
run_dir: string,
|
|
@@ -119,6 +152,11 @@ export function _grade_assertions(
|
|
|
119
152
|
pass: null,
|
|
120
153
|
note: 'rubric grading requires sub-agent — fill in manually or via grader',
|
|
121
154
|
});
|
|
155
|
+
} else if (kind === 'finding_floor') {
|
|
156
|
+
const n = (a['n'] as number | undefined) ?? 1;
|
|
157
|
+
const pattern = a['pattern'] as string | undefined;
|
|
158
|
+
const count = _count_findings(output, pattern);
|
|
159
|
+
results.push({ kind, n, count, pass: count >= n });
|
|
122
160
|
} else {
|
|
123
161
|
results.push({ kind: kind ?? null, pass: false, note: `unknown assertion kind ${_pyRepr(kind)}` });
|
|
124
162
|
}
|
|
@@ -1667,7 +1667,7 @@ export function validate_evals_json(skillPath: string): Issue[] {
|
|
|
1667
1667
|
);
|
|
1668
1668
|
return issues;
|
|
1669
1669
|
}
|
|
1670
|
-
const validKinds = ['contains', 'file_exists', 'rubric'];
|
|
1670
|
+
const validKinds = ['contains', 'file_exists', 'rubric', 'finding_floor'];
|
|
1671
1671
|
const validKindsSet = new Set(validKinds);
|
|
1672
1672
|
scenarios.forEach((scenario, idx) => {
|
|
1673
1673
|
const loc = `scenarios[${idx}]`;
|
|
@@ -1709,15 +1709,31 @@ export function validate_evals_json(skillPath: string): Issue[] {
|
|
|
1709
1709
|
);
|
|
1710
1710
|
return;
|
|
1711
1711
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
`${aLoc} (kind
|
|
1719
|
-
)
|
|
1720
|
-
|
|
1712
|
+
if (kind === 'finding_floor') {
|
|
1713
|
+
// finding_floor (run_skill_evals): `n` (number; runtime-defaults to
|
|
1714
|
+
// 1) and `pattern` (regex string) are both OPTIONAL — validate type
|
|
1715
|
+
// only when present, require neither.
|
|
1716
|
+
if ('n' in a && typeof a.n !== 'number') {
|
|
1717
|
+
issues.push(
|
|
1718
|
+
new Issue('warning', 'evals_json_assertion_field_type', `${aLoc} (kind=finding_floor) 'n' must be a number`),
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1721
|
+
if ('pattern' in a && typeof a.pattern !== 'string') {
|
|
1722
|
+
issues.push(
|
|
1723
|
+
new Issue('warning', 'evals_json_assertion_field_type', `${aLoc} (kind=finding_floor) 'pattern' must be a string`),
|
|
1724
|
+
);
|
|
1725
|
+
}
|
|
1726
|
+
} else {
|
|
1727
|
+
const requiredField = { contains: 'value', file_exists: 'path', rubric: 'criterion' }[kind] as string;
|
|
1728
|
+
if (!(requiredField in a) || typeof a[requiredField] !== 'string') {
|
|
1729
|
+
issues.push(
|
|
1730
|
+
new Issue(
|
|
1731
|
+
'warning',
|
|
1732
|
+
'evals_json_assertion_missing_field',
|
|
1733
|
+
`${aLoc} (kind=${kind}) missing required string field '${requiredField}'`,
|
|
1734
|
+
),
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1721
1737
|
}
|
|
1722
1738
|
});
|
|
1723
1739
|
});
|