feat(campaign): preflightModels/assertModelsServed + building-doctrine doc#231
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The PRE-hoc complement to
assertRealBackend. That guard inspectsRunRecord[]after a run to catch a stub/unconfigured backend; this verifies the campaign's models are actually served by the router before spending tokens, so a dead default surfaces as a config error rather than a silent stub run.Part 1 —
preflightModels/assertModelsServed(src/integrity/preflight.ts)Colocated with
assertRealBackendinsrc/integrity/, exported from the same root-barrel tier.preflightModels({ baseUrl, apiKey, models, probe?, fetchImpl? })→{ succeeded, value: ModelPreflight[] | null, error }.GET {baseUrl}/models;listed= id is in the served set.POST {baseUrl}/chat/completionswith a 1-message,max_tokens: 5request;served= 2xx,status= HTTP status,detail= the body'serror.message(e.g.No API key configured for model ...).servedisnullwhen not probed;probedefaults tofalse.succeeded: false+error). No retries, no fallbacks.assertModelsServed(opts)throws oneModelsUnreachableErrornaming EVERY model that is unlisted or failed its probe, with status + detail per model. A network failure rethrows rather than reporting a partial pass. Callers gate a campaign on it before spending.fetchImplfakes: listed/unlisted, probe 200/401-with-body/503/nested-error, network failures → typed outcome,assertModelsServednaming all dead models, no partial silent pass.Part 2 —
docs/building-doctrine.mdFive present-tense doctrine sections (reachable defaults; platform-first debugging; agent findings are hypotheses; experiment-integrity checklist; fix the class not the instance). Each carries an "Enforced by" line naming the primitive/test that makes it mechanical —
preflightModels/assertModelsServed/assertRealBackend/pairedBootstrap/assertCrossFamily/interRaterReliability(all verified to exist in the repo). One pointer line added toCLAUDE.md; no content duplicated.Verification
pnpm buildgreen (incl. OpenAPI emit)pnpm typecheckgreenpnpm testgreen — 201 files, 1926 passed, 2 skipped (pre-existing)origin/main(git merge-treeexit 0)