trim: remove dead code and move large spec docs to attic

- Remove unused exports: renderProgress, formatTripleBoundaryCounterexample, clearCapturedRoutes
- Remove dead BUILTIN_PLUGIN_CONTRACTS constant (auto-registration removed earlier)
- Fix app-loader error messages to mention multiple export patterns
- Move to attic: protocol-extensions-spec, OUTBOUND_CONTRACT_MOCKING_SPEC, PLUGIN_CONTRACTS_SPEC, fastify-structure
- Build: clean | Tests: 849 pass, 0 fail
This commit is contained in:
John Dvorak
2026-04-30 12:47:40 -07:00
parent 115d3465b1
commit 5921b1437f
14 changed files with 7 additions and 120 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ See [docs/llm-safe-adoption.md](docs/llm-safe-adoption.md) for templates and CI
- [Qualify Mode](docs/qualify.md) — Scenarios, stateful testing, chaos - [Qualify Mode](docs/qualify.md) — Scenarios, stateful testing, chaos
- [Performance](docs/performance.md) — Repeatable benchmarks and CPU profiling - [Performance](docs/performance.md) — Repeatable benchmarks and CPU profiling
- [LLM-Safe Adoption](docs/llm-safe-adoption.md) — Scaffolds and CI guards - [LLM-Safe Adoption](docs/llm-safe-adoption.md) — Scaffolds and CI guards
- [Protocol Extensions](docs/protocol-extensions-spec.md) — JWT, X.509, SPIFFE, WIMSE - [Protocol Extensions](docs/attic/protocol-extensions-spec.md) — JWT, X.509, SPIFFE, WIMSE
## License ## License
+1 -1
View File
@@ -407,7 +407,7 @@ Then execute APOPHIS from the project test harness or CLI as appropriate. For mo
1. `README.md` for canonical usage. 1. `README.md` for canonical usage.
2. `docs/getting-started.md` for quick setup. 2. `docs/getting-started.md` for quick setup.
3. `docs/cli.md` and command docs for CLI flags and machine output. 3. `docs/cli.md` and command docs for CLI flags and machine output.
4. `docs/protocol-extensions-spec.md` for protocol-specific direction. 4. `docs/attic/protocol-extensions-spec.md` for protocol-specific direction.
## Final Check ## Final Check
+1 -1
View File
@@ -135,7 +135,7 @@ fastify.get('/wimse/wit', {
}) })
``` ```
See `docs/protocol-extensions-spec.md` for full JWT extension configuration. See `docs/attic/protocol-extensions-spec.md` for full JWT extension configuration.
--- ---
+2 -2
View File
@@ -116,8 +116,8 @@ export async function checkRouteDiscovery(options: RouteCheckOptions): Promise<R
name: 'route-discovery', name: 'route-discovery',
status: 'fail', status: 'fail',
message: `App file ${appFile} does not export a valid object.`, message: `App file ${appFile} does not export a valid object.`,
detail: 'Ensure the app file exports a Fastify instance as default.', detail: 'Ensure the app file exports a Fastify instance or a factory function.',
remediation: 'Export your Fastify instance as default: export default app;', remediation: 'Export your Fastify instance: export default app; or export const createApp = () => app; or module.exports = app;',
mode: 'all', mode: 'all',
}; };
} }
+1 -1
View File
@@ -642,7 +642,7 @@ export async function qualifyCommand(
} }
return { return {
exitCode: USAGE_ERROR, exitCode: USAGE_ERROR,
message: 'No Fastify app found. Ensure app.js exports a Fastify instance.', message: 'No Fastify app found. Ensure app.js exports a Fastify instance or a factory function.\n\nSupported patterns:\n export default app\n export const createApp = () => app\n module.exports = app',
} }
} }
+1 -1
View File
@@ -468,7 +468,7 @@ export async function verifyCommand(
const errorMessage = err instanceof Error ? err.message : String(err) const errorMessage = err instanceof Error ? err.message : String(err)
return { return {
exitCode: USAGE_ERROR, exitCode: USAGE_ERROR,
message: `No Fastify app found. Ensure app.js exports a Fastify instance.\n\nError: ${errorMessage}\n\nNext:\n Run \`apophis init\` to scaffold a working app.js and config.`, message: `No Fastify app found. Ensure app.js exports a Fastify instance or a factory function.\n\nSupported patterns:\n export default app\n export const createApp = () => app\n module.exports = app\n\nError: ${errorMessage}\n\nNext:\n Run \`apophis init\` to scaffold a working app.js and config.`,
} }
} }
-23
View File
@@ -183,29 +183,6 @@ function generateNextSteps(failure: FailureRecord): string {
// Progress and summary rendering // Progress and summary rendering
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/**
* Render progress for a running command.
* Safe for CI (no spinners, just text updates).
*/
export function renderProgress(
current: number,
total: number,
label: string,
ctx: OutputContext,
): string {
const c = getColorizer(ctx);
const pct = total > 0 ? Math.round((current / total) * 100) : 0;
if (ctx.isCI || !ctx.isTTY) {
// CI mode: simple text, no spinner
return `${label} [${current}/${total}] ${pct}%`;
}
// TTY mode: with color
const bar = renderProgressBar(current, total, 20, ctx);
return `${c.dim(label)} ${bar} ${c.bold(`${pct}%`)}`;
}
/** /**
* Render a simple ASCII progress bar. * Render a simple ASCII progress bar.
*/ */
-6
View File
@@ -87,9 +87,3 @@ export const discoverRoutes = (instance: { routes?: Array<{ method: string; url:
// Fastify 5 fallback: routes registered before plugin // Fastify 5 fallback: routes registered before plugin
return discoverRoutesFallback(instance) return discoverRoutesFallback(instance)
} }
/**
* Clear captured routes for an instance (useful for testing).
*/
export const clearCapturedRoutes = (instance: object): void => {
capturedRoutes.delete(instance)
}
-40
View File
@@ -143,46 +143,6 @@ export class PluginContractRegistry {
} }
} }
// ============================================================================ // ============================================================================
// Built-in Plugin Contracts
// ============================================================================
export const BUILTIN_PLUGIN_CONTRACTS: Record<string, PluginContractSpec> = {
'@fastify/auth': {
appliesTo: '**',
hooks: {
onRequest: {
requires: ['request_headers(this).authorization != null'],
},
},
},
'@fastify/compress': {
appliesTo: '**',
hooks: {
onSend: {
ensures: ['response_headers(this).content-encoding != null'],
},
},
},
'@fastify/cors': {
appliesTo: '**',
hooks: {
onRequest: {
ensures: ['response_headers(this).access-control-allow-origin != null'],
},
},
},
'@fastify/rate-limit': {
appliesTo: '**',
hooks: {
onRequest: {
ensures: [
'response_headers(this).x-ratelimit-limit != null',
'response_headers(this).x-ratelimit-remaining != null',
],
},
},
},
}
// ============================================================================
// Factory // Factory
// ============================================================================ // ============================================================================
export function createPluginContractRegistry(): PluginContractRegistry { export function createPluginContractRegistry(): PluginContractRegistry {
-44
View File
@@ -360,47 +360,3 @@ export function applyChaosToAllResponses(
) )
}) })
} }
// ============================================================================
// Formatting
// ============================================================================
export function formatTripleBoundaryCounterexample(result: TripleBoundaryResult): string {
const lines: string[] = []
lines.push('Triple-boundary counterexample:')
lines.push('')
lines.push(`Route: ${result.command.route.method} ${result.command.route.path}`)
lines.push('')
lines.push('Request:')
lines.push(JSON.stringify(result.command.request, null, 2))
lines.push('')
if (result.command.dependencyResponses.length > 0) {
lines.push('Dependency responses:')
for (const dep of result.command.dependencyResponses) {
lines.push(` ${dep.contractName}: ${dep.statusCode}`)
lines.push(` ${JSON.stringify(dep.body)}`)
}
lines.push('')
}
if (result.command.chaosEvents.length > 0) {
lines.push('Chaos events:')
for (const chaos of result.command.chaosEvents) {
if (chaos.type === 'none') continue
lines.push(` ${chaos.type}`)
if (chaos.contractName) lines.push(` Target: ${chaos.contractName}`)
if (chaos.delayMs) lines.push(` Delay: ${chaos.delayMs}ms`)
if (chaos.statusCode) lines.push(` Status: ${chaos.statusCode}`)
if (chaos.corruptionStrategy) lines.push(` Corruption: ${chaos.corruptionStrategy}`)
if (chaos.corruptionField) lines.push(` Field: ${chaos.corruptionField}`)
}
lines.push('')
}
if (result.failureBoundary) {
lines.push(`Failure boundary: ${result.failureBoundary}`)
}
if (result.failureDescription) {
lines.push(`Description: ${result.failureDescription}`)
}
if (result.error) {
lines.push(`Error: ${result.error}`)
}
return lines.join('\n')
}