fix: address code-level issues from subworker audit

- Remove unused generationProfile parameter from verify runner
- Integrate PluginContractRegistry into petit-runner and stateful-runner
- Add deterministic hashStringToSeed to doctor (replaces Math.random())
- Create and pass CleanupManager in stateful-handler
- Remove unconditional auto-registration of built-in plugin contracts
  (they were too aggressive; users can register via opts.pluginContracts)
- Build: clean | Tests: 849 pass, 0 fail
This commit is contained in:
John Dvorak
2026-04-30 12:07:03 -07:00
parent dc7a4205ec
commit 115d3465b1
7 changed files with 68 additions and 12 deletions
+21 -1
View File
@@ -105,7 +105,7 @@ export const runPetitTests = async (
config: TestConfig,
scopeRegistry?: ScopeRegistry,
extensionRegistry?: ExtensionRegistry,
_pluginContractRegistry?: import('../domain/plugin-contracts.js').PluginContractRegistry,
pluginContractRegistry?: import('../domain/plugin-contracts.js').PluginContractRegistry,
outboundContractRegistry?: OutboundContractRegistry
): Promise<TestSuite> => {
const startTime = Date.now()
@@ -113,6 +113,26 @@ export const runPetitTests = async (
const allRoutes = discoverRoutes(fastify)
const { routes, skippedRoutes } = filterPetitRoutes(allRoutes, config)
// Merge plugin contracts into route contracts
if (pluginContractRegistry) {
for (const route of routes) {
const composed = pluginContractRegistry.composeContracts(route)
for (const phase of Object.values(composed.phases)) {
for (const req of phase.requires) {
if (!route.requires.includes(req.formula)) {
route.requires.push(req.formula)
}
}
for (const ens of phase.ensures) {
if (!route.ensures.includes(ens.formula)) {
route.ensures.push(ens.formula)
}
}
}
}
}
const depth = resolveDepth(config.depth ?? 'standard')
const generationProfile = config.generationProfile ?? resolveGenerationProfile(config.depth)
const { commands: commandGroups, cacheHits, cacheMisses } = generateCommands(routes, depth, config.seed, generationProfile)
+20
View File
@@ -102,6 +102,26 @@ export const runStatefulTests = async (
// Skip HEAD routes — auto-generated by Fastify for GET routes, no response body
const filteredRoutes = allRoutes.filter((r) => r.category !== 'utility' && r.method !== 'HEAD')
const routes = filterByScope(filteredRoutes, config.scope)
// Merge plugin contracts into route contracts
if (pluginContractRegistry) {
for (const route of routes) {
const composed = pluginContractRegistry.composeContracts(route)
for (const phase of Object.values(composed.phases)) {
for (const req of phase.requires) {
if (!route.requires.includes(req.formula)) {
route.requires.push(req.formula)
}
}
for (const ens of phase.ensures) {
if (!route.ensures.includes(ens.formula)) {
route.ensures.push(ens.formula)
}
}
}
}
}
if (routes.length === 0) {
return {
tests: [],