JuliusBrussee/caveman · error · Error

expected exactly 2 agent conformance fixtures, found

Error message

expected exactly 2 agent conformance fixtures, found ${fixtureFiles.length}

What it means

The script pins the agent conformance fixture set to exactly two files — one for the claude harness and one for the pi harness (later destructured as const [claude, pi]). Any other count means the fixture set drifted from the contract, so it throws with the actual count found.

Solutions

  1. Remove any stray non-conformance .json files from fixtures/agent so exactly the claude and pi fixtures remain
  2. If a third harness is intentional, update the script to expect 3 and destructure the new fixture
  3. Restore a deleted fixture from git history
  4. Consider a glob/subdirectory if scratch files keep landing in the fixtures dir

Example fix

# before
fixtures/agent/claude.json fixtures/agent/pi.json fixtures/agent/scratch.json
# after
fixtures/agent/claude.json fixtures/agent/pi.json
Defensive patterns

Strategy: validation

Validate before calling

const fixtureFiles = (await readdir(agentFixtureRoot)).filter(n => n.endsWith('.json'));
const expected = ['claude.json', 'pi.json'];
if (fixtureFiles.length !== 2 || !expected.every(f => fixtureFiles.includes(f))) {
  throw new Error(`fixtures/agent must contain exactly ${expected.join(', ')}; found ${fixtureFiles}`);
}

Try / catch

try { loadAgentFixtures(); } catch (e) { if (e.message.includes('expected exactly 2 agent conformance fixtures')) { console.error('Fixture set drifted:', e.message); process.exitCode = 1; } else throw e; }

Prevention

When it happens

Trigger: Running scripts/validate-schemas.mjs when packages/shared/contracts/fixtures/agent contains more or fewer than two *.json files — e.g. adding a third harness fixture, a leftover scratch JSON, or deleting one of the two required fixtures.

Common situations: Adding a new harness (e.g. codex) fixture without updating the script's expected count/destructuring; a test artifact .json file left in the directory; renaming a fixture while a copy remains.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/e0cb40a7f00ba461. Report an issue: GitHub.

Appendix: source

Thrown at packages/shared/contracts/scripts/validate-schemas.mjs:41

    throw new Error(`${file}: missing $id`);
  }
  schemas.push(schema);
}

const ajv = new Ajv2020({ allErrors: true, strict: true });
ajv.addSchema(schemas);
for (const schema of schemas) {
  const validate = ajv.getSchema(schema.$id);
  if (!validate) throw new Error(`schema failed to compile: ${schema.$id}`);
}

const agentFixtureRoot = path.join(packageRoot, "fixtures", "agent");
const fixtureFiles = (await readdir(agentFixtureRoot))
  .filter((name) => name.endsWith(".json"))
  .sort();

if (fixtureFiles.length !== 2) {
  throw new Error(`expected exactly 2 agent conformance fixtures, found ${fixtureFiles.length}`);
}

const fixtures = await Promise.all(
  fixtureFiles.map(async (file) => JSON.parse(await readFile(path.join(agentFixtureRoot, file), "utf8"))),
);
const validateAdapterConformance = ajv.getSchema(
  "https://caveman.so/schemas/adapter-conformance.schema.json",
);
if (!validateAdapterConformance) {
  throw new Error("adapter conformance schema failed to compile");
}
for (const [index, fixture] of fixtures.entries()) {
  if (!validateAdapterConformance(fixture)) {
    throw new Error(
      `${fixtureFiles[index]}: ${ajv.errorsText(validateAdapterConformance.errors)}`,
    );
  }
}

View on GitHub (pinned to 3ee70a1026)