Skip to content

fix(aqe): make generation and execution evidence trustworthy - #577

Open
stuinfla wants to merge 1 commit into
proffesor-for-testing:mainfrom
stuinfla:fix/aqe-trustworthy-generation-execution
Open

fix(aqe): make generation and execution evidence trustworthy#577
stuinfla wants to merge 1 commit into
proffesor-for-testing:mainfrom
stuinfla:fix/aqe-trustworthy-generation-execution

Conversation

@stuinfla

Copy link
Copy Markdown

Summary

Makes AQE test generation, execution, retries, and quality evidence fail closed and report only measured results. Batches framework execution under the runner, clamps retry confidence, validates generated syntax/assertions, and persists test-run evidence in AgentDB.

Verification

  • npm run test:unit:fast: 330 files passed, 8,383 tests passed, 6 skipped, 0 failed.
  • npm run test:unit:heavy: 243 files passed, 7,118 tests passed, 2 skipped, 0 failed.
  • npm run test:unit:mcp: 45 files passed, 1,362 tests passed, 2 skipped, 0 failed.
  • Focused repair suite: 114/114 passed.
  • npm run typecheck: passed.
  • npm run build: passed.
  • Clean packed-package consumer install: passed.
  • Real RuvNet Brain execution: 151 test files, 2,381 tests total, 2,371 passed, 10 skipped, 0 failed in 77.167s.
  • Full-repo npm run lint remains red on the upstream baseline with 385 errors. Scoped comparison confirmed all 7 lint errors in touched source files already exist identically in HEAD; this change introduces no new lint findings.

Failure modes

  • Invalid or assertion-free LLM output falls back to the deterministic template; covered by generator and quality-gate tests.
  • Missing or malformed coverage/test evidence now fails closed; covered by quality-evidence tests.
  • Large suites execute as one runner-owned batch with a scaled outer timeout; covered by executor command tests and the real 151-file run.
  • Retry confidence is clamped to the valid range; covered by the 31-failure coordinator regression.

Required check (issue #401)

  • Every failure mode mentioned in this PR description has either (a) a test that exercises it, or (b) a linked tracking issue.

Optional context

  • Linked issues: none
  • Trust tier change: none
  • Affects published API or CLI surface: yes, test and quality CLI behavior
  • Touches the init flow / npm-publish workflow / init corpus: no

@proffesor-for-testing proffesor-for-testing left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the direction is right and it continues the #569 line of work (stop presenting unmeasured data as measured). The AST-based syntax and assertion gates are real analysis rather than regex theater, and scoping the regex fallback to non-JS languages is honest. The evidence keys check out too: test-run:latest is written at test.ts:164 with { namespace: 'test-execution' } and read with the same namespace, coverage:latest is namespace-less on both sides with real writers — so no always-throws trap.

Two things I'd like resolved before merge, both unmentioned in the description.

1. typescript promoted from devDependencies → dependencies

  "secure-json-parse": "^4.1.0",
+ "typescript": "^5.9.3",

This reverses a deliberate architectural decision. Both scripts/build-cli.mjs:76 and scripts/build-mcp.mjs:73 carry a typescriptLazyPlugin whose stated purpose is:

"typescript is a devDependency — it won't be available when users install agentic-qe globally. A top-level ESM import would crash the entire CLI (even aqe --version). This plugin replaces the static import with a lazy createRequire() call that only executes when the TypeScript parser is actually used, and throws a helpful error if typescript is missing."
// Keep typescript external so it's not bundled (~9MB)

The plugin resolves on the specifier ^typescript$ and exports a default Proxy. The new import at test-quality-gate.ts:14 is import ts from 'typescript' — identical in form to the three that already exist (pattern-matcher.ts:10, test-generator.ts:14, typescript-parser.ts:6), all of which are already handled by the lazy path. So as far as I can tell the promotion isn't required by this change.

Its effects: ~9MB added to every consumer install, and the graceful-degradation branch ("TypeScript is required for code analysis. Install it: npm install -g typescript") becomes unreachable. The Degraded-Mode drill passed precisely because the dep is now always present, so it can't catch this.

Could you revert the two package.json / package-lock hunks? If the lazy path genuinely fails for this call site, that's worth knowing and belongs in the description with a repro — it'd mean the existing three are fragile too.

2. aqe quality --gate narrows from 7 checks to 2

quality.ts now bypasses the quality-assessment domain API and reads two memory keys with thresholds hardcoded in the CLI. Dropped: criticalBugs, securityVulnerabilities, codeSmells, technicalDebt, duplications. Also gone: exit code 2 (the documented "within 5% of threshold" warning), and score is now always 'N/A'.

I want to be fair to the change: those checks were vacuous — metrics were hardcoded to 0, so securityVulnerabilities: {max: 0} always fake-passed. Deleting a lie is an improvement, and that's the same instinct as the rest of the PR.

But the result is a published CLI gate that no longer covers security at all, with thresholds living as CLI literals rather than in the domain — which cuts against the DDD boundary and ADR-119's two-gate model. And the exit-code contract changed on a surface the description marks as "affects published CLI".

Either restore the domain path with the fail-closed evidence feeding it real metrics (my preference — keeps the honesty win without shrinking coverage), or state the narrowing explicitly, update the CLI docs and exit-code contract, and open a tracking issue for restoring the dropped checks.

3. Minor — private TS API on a floating range

getGeneratedTestSyntaxIssues reads sourceFile.parseDiagnostics, which is internal, not public API. Combined with ^5.9.3, a consumer's TS 5.x bump can silently return [] — the syntax gate degrades to a no-op without failing, which is the exact failure mode this PR exists to prevent. Consider ts.createProgram / getPreEmitDiagnostics, or a canary test asserting the gate still catches a known-bad snippet.

CI

The three red checks are not caused by this PR, so don't burn time on them:

Check Cause
MCP Test Summary HttpError: Resource not accessible by integration — 403 posting a PR comment from a fork
Test Dashboard Same 403
Coverage Analysis 3 timing failures — milestone1-baselines (11877ms vs 5000) ×2, hopfield-memory (3.77ms vs 2ms). 12564 passed. Known flakes; the perf-bound half is tracked in #572.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants