Files
canina/infra/hermes-pilot/ADAPTER.md
T
2026-10-23 19:36:56 +00:00

25 lines
4.8 KiB
Markdown

# Authenticated one-shot Tech adapter (not deployed)
`tech_adapter.py` is trusted host-side orchestration, not a web endpoint. It takes an explicit task UUID, service origin, private artifact root and reviewed admission JSON file. Credential is read exclusively from `/run/secrets/prepare_worker_credential`, with descriptor-relative no-symlink traversal, private file permissions, ownership, regular-file/one-link and bounded-read checks. No token is emitted. HTTPS only in CLI; loopback HTTP exists only in the Python disposable-test interface. Redirects are never followed.
Contract frozen with parent:
- POST `/internal/prepare-worker/tech-claim` `{taskId}` -> `{lease}` or `{lease:null}`. Backend owns stored task admission, READY and independent Gate1. Lease must include exact `pilotKind:tech-dev-clamp-quantity-v1`; removing that sole extension must yield the existing strict staging/first-attempt/20-cent/30-second lease. Task ID must match explicit caller UUID. No arbitrary task text enters inference.
- POST existing `heartbeat` with only taskId/runId/leaseToken -> `{leaseUntil}`. No retries. Entire DNS/connect/response-body operation is isolated in a spawned process, killed after 4.5s plus <=.2s reap. This avoids socket timeout slow-drip gaps. Existing LeaseGuard aborts cancellable inference on denial; no local lease extension.
- POST `tech-complete` with binding plus <=2048-byte generated `source`, only after independent local QA9 and final heartbeat. Acknowledge only exact matching task/run, VERIFYING, 64hex artifactSha256 and `upper-bound-reserved`. Backend's independent validator, artifact registration and reservation retention remain separate authority. Never call existing deterministic tracer `complete` with model output.
Admission file must exactly contain:
{"maxCalls":1,"maxTokens":160,"reservationCents":20,"monetaryCapVerified":false,"acceptUnverifiedMonetaryCap":true}
This is explicit conservative acceptance, **not a hard monetary cap**. Provider authenticated GET `/v1/models` on 2026-10-23 returned `[{"id":"Free"}]` after filtering to id/pricing/cost/limits: no price or cap fields. Anonymous GET returned401. Therefore neither zero price nor independently enforced20c spend cap was verified. Retain the complete20c server reservation; no cost-zero/release/reconcile claim.
Installed pinned Hermes source inspection revealed default API retries3 and automatic recovery5. `inference_budget.SingleCall` now gates the OpenAI-compatible `Completions.create` resource class across client rebuilds, forces nonstreaming/max_tokens160 and denies second invocation. `infer.py` sets app attempts1, recovery0 and checks SDK retries0 before calling the fixed prompt. `runtime.py` injects that trusted gate from source into the isolated pinned process. This bounds requests/output, not provider accounting/input token cost. No new real provider inference was run or represented as authorized by this discovery.
## Verification (remote worktree only)
`python3 -m unittest discover -s infra/hermes-pilot -v`:19 tests passed, including adapter process fixture through independent QA9/Git fixture; real TCP Bearer transmission and403 rejection; total slow-drip body deadline<5s; admission rejection before network; exact pilot denial before runner construction; second provider-call prevention; existing real child/descendant cancellation regressions. Source fixture is deterministic and is **not actual model output**. TDD observed missing module, missing end-to-end behavior, missing credential validation and missing SingleCall failures before implementation.
`disposable_backend.ts` is an isolated Nest/PostgreSQL harness importing sibling's backend module read-only. It is never AppModule code. It records separate author/reviewer Gate1, checks pre-Gate1 denial and VERIFYING/persisted reservation/artifact retrieval. Combined execution PASSED against sibling ingestion source snapshot: task d4e88f7c-3772-47ab-a6fd-dbe00ff8bd2e, run b93a5dbf-3185-4f29-a69d-be8ad85e720c, VERIFYING, artifact b9382f575e9f27f7ad54e0cfb61ba91bc66536fa0e5df5be955563a03c285e17, retrievable with QA9, full20c reservation and zero reconciliations. Evidence: /opt/services/canina/validation/v4-tech-adapter/{adapter-proof,backend-proof}.json. Initial Docker host networking/mounts and stale generated Prisma client failed; corrected with loopback-only disposable backend, copied source and privately generated Prisma client (shared dependencies read-only). Dedicated disposable PostgreSQL had no published ports. No actual authenticated Gate1/model run, Stage change, Production, push/deploy or RELEASE_AUTHORIZE.
Created/changed files are confined to infra/hermes-pilot. Original dirty core/Stage remain untouched. Parent must combine sibling ingestion commit, run disposable integration and decide whether conservative admission suffices for any later model proof.