Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

test(gateguard): pin questions for classes that skip profiling

Jeffrey Montoyaab45ed1edf0f
diff --git a/docs/security/evidence/gateguard-fact-force.md b/docs/security/evidence/gateguard-fact-force.md
index 154809a99..65fd57bbc 100644
--- a/docs/security/evidence/gateguard-fact-force.md
+++ b/docs/security/evidence/gateguard-fact-force.md
@@ -73,7 +73,7 @@ bypasses as SARIF errors. They are:
| --- | --- | --- |
| `tests/hooks/gateguard-fact-force.test.js` | 1019 passed, 0 failed | 704 passed, 0 failed |
| `tests/hooks/gateguard-scenarios.test.js` | 25 passed, 0 failed | — |
-| `tests/lib/gateguard-target-class.test.js` | 30 passed, 0 failed | — |
+| `tests/lib/gateguard-target-class.test.js` | 31 passed, 0 failed | — |
| `tests/lib/gateguard-readonly-shell.test.js` | 18 passed, 0 failed | — |
| `tests/lib/gateguard-change-profile.test.js` | 47 passed, 0 failed | — |
| `tests/lib/gateguard-code-lexer.test.js` | 15 passed, 0 failed | — |
diff --git a/scripts/lib/gateguard-target-class.js b/scripts/lib/gateguard-target-class.js
index 218b425e4..0cc330eba 100644
--- a/scripts/lib/gateguard-target-class.js
+++ b/scripts/lib/gateguard-target-class.js
@@ -192,12 +192,12 @@ function codeQuestionIds(isWrite, profile) {
return data ? [...opening, 'data-schema'] : opening;
}
-/** Stable ids of the first-touch questions for a class, action and change profile. */
/** True when a class's questions depend on the change profile. */
function questionsUseProfile(cls) {
return !Object.hasOwn(CLASS_QUESTION_IDS, cls);
}
+/** Stable ids of the first-touch questions for a class, action and change profile. */
function questionIdsFor(cls, isWrite, profile) {
const ids = Object.hasOwn(CLASS_QUESTION_IDS, cls) ? CLASS_QUESTION_IDS[cls](Boolean(isWrite)) : codeQuestionIds(Boolean(isWrite), profile);
return [...ids, 'quote-instruction'];
diff --git a/tests/lib/gateguard-target-class.test.js b/tests/lib/gateguard-target-class.test.js
index f21d2a156..14da04545 100644
--- a/tests/lib/gateguard-target-class.test.js
+++ b/tests/lib/gateguard-target-class.test.js
@@ -18,6 +18,7 @@ const {
CLASS_CONDENSED_HINTS,
QUOTE_INSTRUCTION,
questionIdsFor,
+ questionsUseProfile,
questionText,
condensedHintFor,
condensedQuestionPhrase,
@@ -377,6 +378,24 @@ test('code condensed hints name exactly the questions of the change profile', ()
}
});
+test('a class that skips profiling asks the same questions under every profile', () => {
+ const profiles = [null, { known: false }];
+ for (const s of [true, false]) for (const d of [true, false]) profiles.push({ known: true, language: 'js', touchesPublicSurface: s, touchesData: d, trivial: false });
+ const classes = ['code', 'test', 'prose', 'instruction', 'config', 'unknown-class'];
+ for (const cls of classes) {
+ for (const isWrite of [false, true]) {
+ const asked = profiles.map(profile => JSON.stringify(questionIdsFor(cls, isWrite, profile)));
+ const hints = profiles.map(profile => condensedHintFor(cls, isWrite, profile));
+ if (!questionsUseProfile(cls)) {
+ assert.strictEqual(new Set(asked).size, 1, `${cls} ${isWrite} questions vary with the profile`);
+ assert.strictEqual(new Set(hints).size, 1, `${cls} ${isWrite} hints vary with the profile`);
+ }
+ }
+ }
+ assert.strictEqual(questionsUseProfile('code'), true);
+ for (const cls of ['test', 'prose', 'instruction', 'config']) assert.strictEqual(questionsUseProfile(cls), false, cls);
+});
+
test('code condensed hints read as one sentence', () => {
const known = (touchesPublicSurface, touchesData) => ({ known: true, language: 'js', touchesPublicSurface, touchesData, trivial: false });
assert.strictEqual(