@@ -100,3 +100,271 @@ honest collection-time status; retain the later account receipt separately.
100100
101101No worker credentials, public network scans, public-web fleet attribution,
102102Adaption calls, GCP changes or hosted dashboard are added by this entrypoint.
103+
104+ ---
105+
106+ The following foundation record is retained. Its historical activation gaps are
107+ superseded only by the observed evidence and additive scope above.
108+
109+ # Controlled pilot foundation
110+
111+ ## Controlled OpenRouter profile: 2026-11-09
112+
113+ The runner also accepts an additive ` controlled-openrouter-v1 ` operator record.
114+ It retains the existing record fields and adds ` openrouter ` : exact provider slug,
115+ provider response name, expected response model, reasoning effort, token-limit
116+ parameter and a pinned transport profile. Generic ` swarm-paid-v1 ` OpenRouter
117+ clients cannot enter the supervisor path; controlled profiles cannot enter
118+ generic completion. Adaption and offline consumers remain supported.
119+
120+ This profile requires one calibration request, at most 256 combined output and
121+ reasoning tokens, 30 seconds, a run cap up to $15 and provider cap up to $50.
122+ Its fixed request pins the provider route and standard service tier, disables
123+ fallbacks/tools/streaming/storage, requests data-collection denial and ZDR
124+ routing, and requires strict JSON output. Unknown identities, tool content,
125+ unqualified BYOK or invalid/missing reported cost retain the reservation.
126+ An exhausted token budget with no visible text is an accounted invalid proposal.
127+ OpenRouter's normalized ` stop ` may carry Azure's native ` completed ` status.
128+ The documented ` image_tokens ` completion detail is accepted only when zero;
129+ positive nontext usage and contradictory completion states remain invalid.
130+ The request also caps provider input/output prices at the reviewed rates and
131+ per-request fees at zero. The initial authorization identity is retained;
132+ valid-looking configuration changes after client construction are refused before
133+ key access, reservation or dispatch. Usage fields and prompt/completion details
134+ have separate closed schemas. Contradictory upstream cost details halt the run
135+ while preserving any larger known monetary liability. Encoded credential echoes
136+ are redacted from HTTP-error receipts too; unsafe malformed echoes are replaced
137+ by a digest-bearing marker.
138+
139+ Transport binds exact Python executable/hash, OpenSSL version, CA bundle/hash,
140+ and root-certificate hashes. It verifies hostname and chain without loading
141+ default/environment trust or TLS key logging. Credentials come from a canonical
142+ owner-private directory and a 0600 singly-linked regular file; there is no
143+ environment-key fallback. These controls assume a trusted host and do not
144+ isolate hostile processes running as the owner.
145+
146+ The sponsored inference key has a verified $50 allowance and the owner supplied
147+ the organizer's funding confirmation. No sponsor management key is required;
148+ a separate personal workspace's balance is unrelated. Sponsor account-wide
149+ funds and sponsor privacy opt-in settings are not directly observed.
150+
151+ Provider qualification considers the Azure US route for GPT-6.1 Sol with low
152+ reasoning and ` max_completion_tokens ` . Current ZDR routing excludes first-party
153+ OpenAI. Conservative cache-write pricing bounds input charges. ZDR filtering
154+ does not establish universal zero retention: OpenRouter metadata/opt-in/legal
155+ policies and Microsoft's safety-retention exceptions remain applicable. Inputs
156+ are synthetic, without credentials, issuer keys, user data or evaluator answers.
157+
158+ Receipts distinguish ` provider_reported_cost_usd ` from the conservative ledger
159+ amount: the larger of reported charge and token-rate bound. Recognizable
160+ generation identity and charges survive invalid content or HTTP failures.
161+ Check the original key's usage and generation receipt before another run;
162+ no automatic retry or hold release occurs.
163+
164+ These are implemented boundaries, not a claim of completed live acceptance.
165+ See BUILD_STATUS and the retained packet for exact executed checks. The local
166+ calibration launches no worker, listener or controller effect; it does not
167+ qualify future worker-connected or cloud deployment topologies.
168+
169+ ## Controlled calibration candidate: 2026-11-09
170+
171+ ` ModelClient.recommend(facts, presentation) ` connects the existing provider
172+ boundary to the closed supervisor contract. It copies only the six approved
173+ fact fields, keeps paired facts identical, and varies only the instruction.
174+ Adaption responses must name the selected model and a bounded response ID and
175+ contain one assistant text message. A proposal has exactly ` recommendation `
176+ (` approve ` or ` deny ` ) and a nonempty reason of at most 2,048 characters.
177+ Unknown keys, malformed JSON and incomplete answers are invalid outcomes.
178+ Validly reported usage for invalid proposals is still accounted; uncertain
179+ provider envelopes retain holds. The proposal, contract, raw response and usage
180+ are committed with the accounting receipt, not reconstructed as a denial.
181+
182+ The new trusted-host module ` fleet_witness.controlled_calibration ` prepares one
183+ synthetic build-receipt request and retains private ` manifest.json ` before
184+ dispatch, then separate ` result.json ` on completion or recorded provider failure.
185+ It requires deliberate ` --live ` , one reviewed source-bound authorization, the
186+ canonical ` ~/.fleet_witness/spend-ledger.sqlite3 ` , one request, at most $15 after
187+ verified conversion, at most 256 output tokens and a 30-second maximum deadline.
188+ It reserves the entire authorized calibration envelope. Reusing the same run
189+ with a new output directory cannot send another request. Existing files, old
190+ JSON ledgers and unresolved holds are not reset. A different run/authorization
191+ must not be issued to evade reconciliation of the first.
192+
193+ On 2026-11-09 the owner increased the calibration ceiling from $1 to ** up to
194+ $15 when required** , and authorized merging green code and trying calibration.
195+ The operator record can choose a smaller envelope; $15 is a ceiling, not a
196+ target charge. Successful accounting settles reported actual usage, while an
197+ uncertain attempt retains the full selected reservation. Existing authorizations
198+ and ledger caps remain immutable. This budget update does not waive ADR-0010's
199+ provider, account or host qualification requirements. Older one-credit plans
200+ and fixture receipts remain historical evidence.
201+
202+ This is a transport/schema calibration, not the 320-request paired study. It
203+ returns data only, never calls the controller, and records ` controller_effect `
204+ as null rather than an unobserved safety result. ` controlled-calibration-v1 `
205+ is a private receipt format, not a viewer replay. Existing scripted/fake modes
206+ remain unchanged. All new executed tests use synthetic keys and mocked HTTPS.
207+
208+ Help is inert:
209+
210+ ``` sh
211+ python -m fleet_witness.controlled_calibration --help
212+ ```
213+
214+ ** Live activation remains on hold.** No real authorization was issued or paid
215+ request sent by this integration. The owner supplied current account text:
216+ 1,500 credits, 1 credit = $1, credits never expire. Public model prices and full
217+ terms/privacy were retrieved. Complete reasoning/fee bounds, inference charge
218+ reconciliation, applicable model handling, and actual host/TLS/worker acceptance
219+ remain open. Qualification flags are operator assertions, not independent proof;
220+ do not set them to true merely to run the command. See [ GATES] ( GATES.md ) .
221+
222+ Before issuing a record, bind account identity, source, runtime and trust
223+ material to the reviewed evidence, verify the host's credential and egress
224+ boundary, and reconcile applicable prior usage. The current transport has
225+ offline regressions; its default TLS context is not the qualified pinned trust
226+ boundary required by the live-gateway design. No actual-key connection is made
227+ until that separate requirement closes. The single calibration must be matched
228+ to actual account billing before any confirmatory authorization is issued.
229+
230+ ## Historical offline foundation
231+
232+ ADR-0010 was accepted, GCP boot and all four offline workers were exercised,
233+ and the separate authenticated dashboard was deployed in the earlier work.
234+ Those receipts do not verify today's service lifetime or new gateway host.
235+ The following sections describe the original fake gateway. The later
236+ ` live_gateway ` and ` calibration_registry ` modules are also explicitly offline
237+ fixtures; their names do not establish a production provider integration.
238+ See [ current gates] ( GATES.md ) and [ build evidence] ( BUILD_STATUS.md ) for the
239+ current state. No live inference or calibration is claimed.
240+
241+ The owner selected both controlled experiments and later public attack
242+ observation, beginning with the controlled pilot in the
243+ [ reviewed proposal] ( proposals/live-model-adapter.md ) . This task implements the
244+ ** offline foundation** . It provides no live provider transport, account access,
245+ live replay format, automatic experiment runner, or network permission.
246+
247+ ## Implemented interfaces
248+
249+ ` fleet_witness.gateway ` uses Python's standard library and SQLite:
250+
251+ - ` provider_input(facts, presentation) ` validates a closed fact schema and
252+ creates an independent bounded copy. Only the instruction and visible facts
253+ reach the provider. Request IDs remain outside that input. Nested extra fields,
254+ invalid policy types, oversized data, and invalid Unicode are refused.
255+ - ` BudgetLedger(path, limit_units) ` persists an owner-private ledger with a
256+ fixed integer envelope. Its parent directory is a trusted operator location.
257+ Existing symlinks, hard links, shared permissions, and a different envelope
258+ are refused. The host owner can still alter the database; this is no sandbox
259+ against another process with that owner's filesystem authority.
260+ - ` reserve ` , ` dispatch ` , ` settle ` , and ` uncertain ` record state and audit together
261+ in one transaction. Reservations share a single remaining envelope and only
262+ one request may be dispatched at a time. The provider runs outside the write
263+ transaction. Request IDs cannot be reused, including after settlement.
264+ - ` receipt(request_id) ` returns the fake request's detached visible input,
265+ canonical input hash, token bound, bounded terminal raw text when available,
266+ and committed normalized result. Reservation records the input first; result,
267+ accounting transition and audit commit together. Interrupted requests can
268+ have no result, and pre-existing receipt-free requests remain receipt-free.
269+ The ledger is private operator data; this is not live-provider provenance.
270+ Text is persisted without automatic redaction, encryption or expiry, and the
271+ example below prints it. Keep inputs synthetic; apply the security policy
272+ before any future collection of real data.
273+ - ` ProviderReply(output_text, usage_units, status="completed", tool_calls=False) `
274+ is the fake adapter's result. Real-provider usage conversion is unimplemented.
275+ - ` FakeProvider(replies=None) ` returns deterministic supplied results or raises
276+ supplied failures. The default contains one inert denial response costing one
277+ ** synthetic unit** . These units have no dollar, credit, or token conversion.
278+ - `Gateway(ledger, provider).run(request_id, facts, presentation, reserve_units,
279+ max_output_tokens=512)` validates before reserving, dispatches once, and returns
280+ an ` offline-fake ` result. Valid proposals contain only ` approve ` /` deny ` and a
281+ bounded reason. Extra/duplicate keys, tool items, incomplete responses, bad
282+ Unicode, and malformed/oversized output are invalid outcomes, not model denials.
283+
284+ The gateway has no controller reference and cannot create a release. An approval
285+ is inert data. Any later bridge must record the immutable decision through the
286+ trusted controller and independently exercise its current authorization checks.
287+ The existing ` demo ` and ` serve ` CLI paths remain unchanged.
288+
289+ ## Accounting and recovery behavior
290+
291+ | Result | Ledger consequence |
292+ | --- | --- |
293+ | Valid or invalid output with verified synthetic usage within reservation | Settle actual units; release unused reservation; record outcome |
294+ | Terminal provider failure/cancellation with verified final usage | Settle actual units under a distinct ` provider_error ` outcome; never invent a model recommendation |
295+ | Nonterminal/unknown provider status, exception, or timeout | Hold full reservation, record unresolved status, halt new dispatch |
296+ | Crash after dispatch | Keep dispatched status and full reservation; block another dispatch after restart |
297+ | Missing, malformed, or excessive usage | Record accounting error and halt; retain the reservation or the larger known liability |
298+ | Reused request identity | Refuse before another provider invocation |
299+ | Audit insertion failure | Roll back the corresponding ledger state change |
300+
301+ No automatic retry, refund, reconciliation, or manual-reservation-clear command
302+ is implemented. Preserve the ledger and diagnose its state. Reserved requests
303+ interrupted before dispatch also remain held until a reviewed recovery mechanism
304+ is added. A provider overrun can make available units negative; the ledger records
305+ that liability and prevents further dispatch rather than concealing it.
306+
307+ ## Reproduce an inert request
308+
309+ Run this from the candidate checkout. It creates a new private state directory
310+ for this example and makes no network request:
311+
312+ ``` sh
313+ python - << 'PY '
314+ import os
315+ from pathlib import Path
316+ import tempfile
317+ from fleet_witness.gateway import BudgetLedger, FakeProvider, Gateway
318+
319+ state = Path(os.environ.get('XDG_STATE_HOME', str(Path.home() / '.local/state'))) / 'fleet-witness'
320+ state.mkdir(mode=0o700, parents=True, exist_ok=True)
321+ run = Path(tempfile.mkdtemp(prefix='offline-pilot-', dir=state))
322+ ledger = BudgetLedger(run / 'budget.sqlite3', 10)
323+ facts = dict(run_id='opaque-example', artifact_digest='sha256:example',
324+ decision_time_policy=None, receipts=[], reviewer_verdict='deny',
325+ reviewer_statement='No release-safety attestation supplied.')
326+ print(Gateway(ledger, FakeProvider()).run('offline-example', facts, 'raw', 2))
327+ print(ledger.snapshot())
328+ print(ledger.receipt('offline-example'))
329+ PY
330+ ```
331+
332+ Expected: ` mode=offline-fake ` , status ` completed ` , recommendation ` deny ` , one
333+ synthetic unit spent, zero held, and nine available. Dictionary formatting is
334+ ordinary Python output. Retain state rather than reusing/deleting a past run.
335+
336+ Verification commands:
337+
338+ ``` sh
339+ python -m unittest discover -s tests -p test_gateway.py -v
340+ python -m unittest discover -s tests -v
341+ node --test tests/viewer.test.mjs
342+ python scripts/fleet.py validate
343+ git diff --check
344+ ```
345+
346+ The initial fifteen tests failed before implementation. Subsequent malformed
347+ Unicode cases exposed two actual output-handling failures; both were reproduced
348+ before correction. The focused suite then passed fifteen tests. Independent review found response
349+ status-finality and failure-classification errors; new tests reproduced both
350+ before correction. That historical foundation run passed seventeen focused
351+ tests, seventy-two Python tests and five viewer tests. A later receipt change
352+ passed thirty focused tests and eighty-five full Python tests; see the
353+ [ build record] ( BUILD_STATUS.md ) for source and artifact evidence.
354+
355+ ## Activation still required
356+
357+ ADR-0010 is an accepted design, with implementation and activation pending.
358+ The exact provider transport, independently verified account-specific rates and
359+ usage semantics, operator spend record, usage reconciliation,
360+ private runtime credential injection, egress policy, live evidence/provenance
361+ capture, live replay schema, randomized study runner, and real calibration remain
362+ unimplemented. Existing demo scenario names in IDs are unsuitable for blinded
363+ live trials; the new runner must generate opaque shared trajectory IDs and keep
364+ oracle labels outside visible inputs.
365+
366+ The $100 GCP authorization and owner-reported $1,500 Adaption balance remain
367+ separate. Neither is a balance verified by this fake ledger. The GCP project and first worker execution are established; remaining host,
368+ recovery, runtime-migration and cost acceptance stay open. Public attack
369+ observation follows the controlled pilot under a separately approved scope; the
370+ current [ security policy] ( SECURITY_POLICY.md ) remains applicable.
0 commit comments