test(hooks): resolve context-gate fixture roots with realpath

Wrap #3106's mkdtemp fixture roots in realpathSync, matching the existing
atomic-write tests, so CodeQL no longer traces shared-temp paths from
these fixtures into read handles. Assertions are unchanged.
This commit is contained in:
haelyra committed 2026-11-17 00:45:14 -05:00
1 parent 562b541581
commit 8a5cbb7e14
5 files changed
+10 -10

No files matched your search

+1 -1
View File
@@ -33,7 +33,7 @@ function test(name, fn) {
}
function createSandbox() {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-context-gate-owner-'));
const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-context-gate-owner-')));
const dataHome = path.join(root, 'data');
const resumeDir = path.join(dataHome, 'session-data', 'resume');
fs.mkdirSync(resumeDir, { recursive: true });
+5 -5
View File
@@ -27,7 +27,7 @@ function test(name, fn) {
// Private per-run directory for fixtures, so no test writes a predictable name
// directly under the shared OS temp directory.
const FIXTURE_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-context-gate-test-'));
const FIXTURE_DIR = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-context-gate-test-')));
process.on('exit', () => fs.rmSync(FIXTURE_DIR, { recursive: true, force: true }));
let fixtureSeq = 0;
@@ -387,7 +387,7 @@ function runTests() {
// cases that follow.
if (
test('a pre-existing project RESUME.md is never targeted and is left untouched', () => {
const projDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-proj-'));
const projDir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-proj-')));
const existing = path.join(projDir, 'RESUME.md');
fs.writeFileSync(existing, 'OPERATOR CONTENT — must survive\n', 'utf8');
const t = writeTranscript(950000);
@@ -429,7 +429,7 @@ function runTests() {
test('missing identity: same-named projects never collide on a shared destination', () => {
// Sandbox the handoff home so the fire touches tmp only. ECC_AGENT_DATA_HOME
// is read by getSessionsDir() from process.env, so it must be set there.
const sandbox = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-home-'));
const sandbox = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-home-')));
const resumeDir = path.join(sandbox, 'session-data', 'resume');
fs.mkdirSync(resumeDir, { recursive: true });
// A pre-existing handoff at the exact path the OLD literal-fallback code
@@ -476,7 +476,7 @@ function runTests() {
if (
test('a destination owned by a different session is disambiguated, not overwritten', () => {
const sandbox = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-home-'));
const sandbox = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-home-')));
const resumeDir = path.join(sandbox, 'session-data', 'resume');
fs.mkdirSync(resumeDir, { recursive: true });
// Seed the exact path this session resolves to, owned by ANOTHER session.
@@ -509,7 +509,7 @@ function runTests() {
if (
test('a destination owned by the same session is reused (idempotent)', () => {
const sandbox = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-home-'));
const sandbox = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-home-')));
const resumeDir = path.join(sandbox, 'session-data', 'resume');
fs.mkdirSync(resumeDir, { recursive: true });
let own;
+2 -2
View File
@@ -148,7 +148,7 @@ function runTests() {
test('run(): readable transcript in the gate band suppresses the context warning', () => {
const sessionId = `ctx-monitor-gate-active-${process.pid}-${Date.now()}`;
const warnPath = path.join(os.tmpdir(), `ecc-ctx-warn-${sessionId}.json`);
const transcript = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-ctx-monitor-')), 'transcript.jsonl');
const transcript = path.join(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-ctx-monitor-'))), 'transcript.jsonl');
// 190k of an assumed 200k window = 95% >= the 90% gate threshold.
fs.writeFileSync(
transcript,
@@ -185,7 +185,7 @@ function runTests() {
// Same in-band transcript, but with no ECC_CONTEXT_GATE_MODE the gate is
// inert — the monitor must keep emitting CONTEXT CRITICAL.
const sessionId = `ctx-monitor-gate-advisory-${process.pid}-${Date.now()}`;
const transcript = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-ctx-monitor-')), 'transcript.jsonl');
const transcript = path.join(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-ctx-monitor-'))), 'transcript.jsonl');
fs.writeFileSync(
transcript,
JSON.stringify({
+1 -1
View File
@@ -670,7 +670,7 @@ function runTests() {
return path.join(suiteTempDir, `claude-context-bucket-${sessionId}`);
}
const transcriptDir = fs.mkdtempSync(path.join(suiteTempDir, 'ecc-compact-transcripts-'));
const transcriptDir = fs.realpathSync(fs.mkdtempSync(path.join(suiteTempDir, 'ecc-compact-transcripts-')));
process.once('exit', () => fs.rmSync(transcriptDir, { recursive: true, force: true }));
let transcriptSeq = 0;
+1 -1
View File
@@ -49,7 +49,7 @@ function test(desc, fn) {
// Private per-run directory for fixtures, so no test writes a predictable name
// directly under the shared OS temp directory.
const FIXTURE_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-state-test-'));
const FIXTURE_DIR = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-gate-state-test-')));
process.on('exit', () => fs.rmSync(FIXTURE_DIR, { recursive: true, force: true }));
let fixtureSeq = 0;