Skip to content

Commit cd6d91e

Browse files
committed
Complete normalized provider abstraction
Change-Log: CL-20260730-060 Dev-Log: DL-20260730-061
1 parent 777d81f commit cd6d91e

55 files changed

Lines changed: 18658 additions & 89 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ Dev-Log:
3030

3131
Entries
3232
-------
33+
Change-ID: CL-20260730-060
34+
Date: 2026-07-30
35+
Type: Provider abstraction and exact accounting
36+
Request-or-TODO: M12-001 through M12-055 and M12-G01 through M12-G04
37+
Outcome: Added normalized OpenAI Responses, Anthropic Messages, and
38+
OpenAI-compatible adapters with streaming, tools, structured output,
39+
cancellation, bounded retry, immutable pricing evidence, and durable
40+
per-attempt attribution
41+
Affected-behavior: Provider requests now retain exact provider/model/revision
42+
identity, sealed known or explicit-unknown pricing, normalized standard and
43+
provider-specific usage, exact rational cost, safe metadata, partial-effect
44+
evidence, latency, retry decisions, recovery choices, and terminal status.
45+
Observable partial work cannot be retried, provider switching requires
46+
explicit authority, and an opt-in live gate uses only OS credential
47+
references and an external database without printing response content.
48+
Compatibility-or-migration: Adds migration 000009 for provider configuration,
49+
sealed pricing revisions, logical requests, physical attempts, accounting,
50+
partial evidence, and live-smoke attribution; schema version advances from
51+
8 to 9.
52+
Verification: Deterministic adapter conformance, mock-server, cancellation,
53+
deadline, retry, recovery, provider-specific accounting, migration,
54+
generation, integration, security, and complete local test-all gates pass.
55+
Three independent adversarial contract, runtime, and storage audits accept
56+
the final tree.
57+
Dev-Log: DL-20260730-061
58+
3359
Change-ID: CL-20260730-059
3460
Date: 2026-07-30
3561
Type: Cross-platform worker directory identity

DEVLOG

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,53 @@ Next-safe-step:
2424

2525
Entries
2626
-------
27+
Dev-Log: DL-20260730-061
28+
Date: 2026-07-30
29+
Status: Complete
30+
Change-ID: CL-20260730-060
31+
Request-or-TODO: M12-001 through M12-055 and M12-G01 through M12-G04
32+
Goal: Normalize the initial provider set while preserving exact identity,
33+
usage, pricing, retry, cancellation, privacy, and recovery evidence
34+
Assumptions: Provider capabilities and prices are revision-bound evidence;
35+
missing usage or pricing is unknown rather than zero; credentials remain in
36+
the operating-system store; a provider or model switch always requires
37+
explicit user authority
38+
Decisions: Use one normalized request and ordered stream contract; implement
39+
OpenAI Responses, Anthropic Messages, and configurable OpenAI-compatible
40+
adapters; reject remote endpoints without approval; persist intent before
41+
provider I/O; seal pricing snapshots; reconcile standard and
42+
provider-specific categories; block retries after observable partial
43+
effects; compensate bounded pre-I/O, accounting, and terminal-write
44+
failures; pause after retry exhaustion; redact metadata before UI and again
45+
before persistence; keep live requests opt-in, cost-warned, content-free,
46+
OS-credential-only, and outside the repository database boundary
47+
Files-or-schemas: Migration 000009; provider contracts, transports, adapters,
48+
retry, pricing, usage, and recovery; coordinator credential, attempt,
49+
execution, and recovery services; provider accounting and live-smoke
50+
repositories; cross-platform physical path resolution; run-live command and
51+
deterministic tests
52+
Validation: Adapter mock and common-conformance suites, explicit and buffered
53+
cancellation, deadline classification, retry safety, exact rational and
54+
provider-specific accounting, sealed snapshot, recovery/finalization,
55+
Windows junction, no-network live-gate, migration, generation, lint,
56+
security, integration, and complete local test-all gates pass. Independent
57+
contract, runtime, and storage audits all return ACCEPT.
58+
Failures-or-discarded-approaches: Cancellation initially raced buffered OpenAI
59+
output and mislabeled deadlines; accounting and terminal write failures
60+
could strand attribution; pricing components were appendable after snapshot
61+
creation; live finalization trusted caller outcomes; retry exhaustion
62+
failed to expose recovery choices; provider-specific usage was initially
63+
dropped. Each path now has a regression and durable invariant. Raw API keys,
64+
environment credential fallback, silent provider switching, unsealed or
65+
zero-valued unknown pricing, response-content logging, and repository-local
66+
live databases were rejected.
67+
Known-limitations: Real billable provider smoke execution remains explicitly
68+
opt-in and is not run by CI. Browser E2E begins with the planned M16 GWC
69+
harness; public CI supplies cross-platform and Ubuntu race evidence after
70+
push.
71+
Next-safe-step: Push M12, require public CI to pass, then implement M13 fixed
72+
routing, forecasts, reservations, and hard budget enforcement.
73+
2774
Dev-Log: DL-20260730-060
2875
Date: 2026-07-30
2976
Status: Complete

TODOS.md

Lines changed: 82 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,80 +1886,103 @@ Milestone output: normalized OpenAI, Anthropic, and OpenAI-compatible adapters w
18861886

18871887
## Provider Interface
18881888

1889-
- [ ] `M12-001 BLOCKER` Define provider discovery and capability methods.
1890-
- [ ] `M12-002 BLOCKER` Define streaming response and cancellation.
1891-
- [ ] `M12-003` Define request messages, tool declarations, tool results, and structured-output requirements.
1892-
- [ ] `M12-004` Define normalized stop reasons.
1893-
- [ ] `M12-005` Define normalized usage accounting.
1894-
- [ ] `M12-006` Define provider-specific raw metadata retention after redaction.
1895-
- [ ] `M12-007` Define timeout, retryable, rate-limit, authentication, invalid-request, safety, and unavailable errors.
1896-
- [ ] `M12-008` Define model capabilities: tools, structured output, context length, image input, and reasoning controls.
1897-
- [ ] `M12-009` Define exact provider/model/version identity recorded per request.
1898-
- [ ] `M12-010` Define pricing snapshots separately from mutable current pricing.
1899-
- [ ] `M12-011` Define cancellation semantics and late-response handling.
1900-
- [ ] `M12-012` Define request idempotency where providers support it.
1889+
- [x] `M12-001 BLOCKER` Define provider discovery and capability methods.
1890+
- [x] `M12-002 BLOCKER` Define streaming response and cancellation.
1891+
- [x] `M12-003` Define request messages, tool declarations, tool results, and structured-output requirements.
1892+
- [x] `M12-004` Define normalized stop reasons.
1893+
- [x] `M12-005` Define normalized usage accounting.
1894+
- [x] `M12-006` Define provider-specific raw metadata retention after redaction.
1895+
- [x] `M12-007` Define timeout, retryable, rate-limit, authentication, invalid-request, safety, and unavailable errors.
1896+
- [x] `M12-008` Define model capabilities: tools, structured output, context length, image input, and reasoning controls.
1897+
- [x] `M12-009` Define exact provider/model/version identity recorded per request.
1898+
- [x] `M12-010` Define pricing snapshots separately from mutable current pricing.
1899+
- [x] `M12-011` Define cancellation semantics and late-response handling.
1900+
- [x] `M12-012` Define request idempotency where providers support it.
19011901

19021902
## OpenAI Adapter
19031903

1904-
- [ ] `M12-013` Implement model configuration.
1905-
- [ ] `M12-014` Implement credential lookup.
1906-
- [ ] `M12-015` Implement streaming text.
1907-
- [ ] `M12-016` Implement tool calls and tool results.
1908-
- [ ] `M12-017` Implement structured output needed by the planner.
1909-
- [ ] `M12-018` Implement cancellation.
1910-
- [ ] `M12-019` Normalize usage and stop reasons.
1911-
- [ ] `M12-020` Capture request IDs and safe provider metadata.
1912-
- [ ] `M12-021` Classify errors and retry hints.
1913-
- [ ] `M12-022 TEST` Test against a deterministic mock server.
1914-
- [ ] `M12-023 TEST` Add an opt-in live smoke test.
1904+
- [x] `M12-013` Implement model configuration.
1905+
- [x] `M12-014` Implement credential lookup.
1906+
- [x] `M12-015` Implement streaming text.
1907+
- [x] `M12-016` Implement tool calls and tool results.
1908+
- [x] `M12-017` Implement structured output needed by the planner.
1909+
- [x] `M12-018` Implement cancellation.
1910+
- [x] `M12-019` Normalize usage and stop reasons.
1911+
- [x] `M12-020` Capture request IDs and safe provider metadata.
1912+
- [x] `M12-021` Classify errors and retry hints.
1913+
- [x] `M12-022 TEST` Test against a deterministic mock server.
1914+
- [x] `M12-023 TEST` Add an opt-in live smoke test.
19151915

19161916
## Anthropic Adapter
19171917

1918-
- [ ] `M12-024` Implement model configuration.
1919-
- [ ] `M12-025` Implement credential lookup.
1920-
- [ ] `M12-026` Implement streaming text.
1921-
- [ ] `M12-027` Implement tool calls and tool results.
1922-
- [ ] `M12-028` Implement structured output needed by the planner.
1923-
- [ ] `M12-029` Implement cancellation.
1924-
- [ ] `M12-030` Normalize usage and stop reasons.
1925-
- [ ] `M12-031` Capture request IDs and safe provider metadata.
1926-
- [ ] `M12-032` Classify errors and retry hints.
1927-
- [ ] `M12-033 TEST` Test against a deterministic mock server.
1928-
- [ ] `M12-034 TEST` Add an opt-in live smoke test.
1918+
- [x] `M12-024` Implement model configuration.
1919+
- [x] `M12-025` Implement credential lookup.
1920+
- [x] `M12-026` Implement streaming text.
1921+
- [x] `M12-027` Implement tool calls and tool results.
1922+
- [x] `M12-028` Implement structured output needed by the planner.
1923+
- [x] `M12-029` Implement cancellation.
1924+
- [x] `M12-030` Normalize usage and stop reasons.
1925+
- [x] `M12-031` Capture request IDs and safe provider metadata.
1926+
- [x] `M12-032` Classify errors and retry hints.
1927+
- [x] `M12-033 TEST` Test against a deterministic mock server.
1928+
- [x] `M12-034 TEST` Add an opt-in live smoke test.
19291929

19301930
## OpenAI-Compatible Local Adapter
19311931

1932-
- [ ] `M12-035` Implement configurable loopback or user-approved endpoint.
1933-
- [ ] `M12-036` Support optional credentials.
1934-
- [ ] `M12-037` Implement model listing where the endpoint provides it.
1935-
- [ ] `M12-038` Implement streaming text.
1936-
- [ ] `M12-039` Detect and advertise tool-call support.
1937-
- [ ] `M12-040` Handle endpoints without usage reporting.
1938-
- [ ] `M12-041` Handle nonstandard error bodies safely.
1939-
- [ ] `M12-042` Require approval before connecting to a non-loopback endpoint.
1940-
- [ ] `M12-043 TEST` Test against a local deterministic fake endpoint.
1932+
- [x] `M12-035` Implement configurable loopback or user-approved endpoint.
1933+
- [x] `M12-036` Support optional credentials.
1934+
- [x] `M12-037` Implement model listing where the endpoint provides it.
1935+
- [x] `M12-038` Implement streaming text.
1936+
- [x] `M12-039` Detect and advertise tool-call support.
1937+
- [x] `M12-040` Handle endpoints without usage reporting.
1938+
- [x] `M12-041` Handle nonstandard error bodies safely.
1939+
- [x] `M12-042` Require approval before connecting to a non-loopback endpoint.
1940+
- [x] `M12-043 TEST` Test against a local deterministic fake endpoint.
19411941

19421942
## Retry, Fallback, and Accounting
19431943

1944-
- [ ] `M12-044 BLOCKER` Implement bounded retry for transient transport failures.
1945-
- [ ] `M12-045` Respect provider retry-after guidance within the task deadline and budget.
1946-
- [ ] `M12-046` Do not retry invalid, authentication, or policy errors.
1947-
- [ ] `M12-047` Record each physical request attempt.
1948-
- [ ] `M12-048` Attribute retry usage and cost to the task.
1949-
- [ ] `M12-049` Preserve partial streamed output as non-final evidence.
1950-
- [ ] `M12-050` Pause after retry budget exhaustion.
1951-
- [ ] `M12-051` Offer retry, resume, or explicitly approved provider switch.
1952-
- [ ] `M12-052` Never silently switch providers or models.
1953-
- [ ] `M12-053` Handle missing pricing as unknown rather than zero.
1954-
- [ ] `M12-054` Reconcile estimated and provider-reported usage.
1955-
- [ ] `M12-055` Surface accounting discrepancies.
1944+
- [x] `M12-044 BLOCKER` Implement bounded retry for transient transport failures.
1945+
- [x] `M12-045` Respect provider retry-after guidance within the task deadline and budget.
1946+
- [x] `M12-046` Do not retry invalid, authentication, or policy errors.
1947+
- [x] `M12-047` Record each physical request attempt.
1948+
- [x] `M12-048` Attribute retry usage and cost to the task.
1949+
- [x] `M12-049` Preserve partial streamed output as non-final evidence.
1950+
- [x] `M12-050` Pause after retry budget exhaustion.
1951+
- [x] `M12-051` Offer retry, resume, or explicitly approved provider switch.
1952+
- [x] `M12-052` Never silently switch providers or models.
1953+
- [x] `M12-053` Handle missing pricing as unknown rather than zero.
1954+
- [x] `M12-054` Reconcile estimated and provider-reported usage.
1955+
- [x] `M12-055` Surface accounting discrepancies.
1956+
1957+
M12 test evidence:
1958+
1959+
- Deterministic OpenAI Responses, Anthropic Messages, and OpenAI-compatible
1960+
mock endpoints pass the same normalized text, partial tool-arguments,
1961+
completed tool-call, usage, stop-reason, identity, and metadata conversation.
1962+
- Provider execution tests cover cancellation-authoritative UI delivery,
1963+
explicit provider cancellation, deadline classification, late buffered-event
1964+
suppression, bounded retry, retry-after limits, no retry after observable
1965+
output or tool effects, and no automatic provider or model switching.
1966+
- SQLite tests cover sealed immutable known and explicit-unknown pricing
1967+
snapshots, attributable logical and physical requests, exact rational cost,
1968+
latest-record reconciliation, provider-specific usage, discrepancy states,
1969+
partial evidence hashes, retry exhaustion pause, and bounded compensation
1970+
for pre-I/O, accounting, and terminal-write failures.
1971+
- `codeflux-dev run-live` is an opt-in, cost-warned path for OpenAI or
1972+
Anthropic. It reads only an `os://service/account` credential, requires an
1973+
external database outside physical repository aliases, emits no response
1974+
content, and is covered by a deterministic no-network end-to-end test.
1975+
- Lint, generation, migration, fast, integration, security, repeated
1976+
cancellation/accounting regressions, and the complete local `test-all` gate
1977+
pass. The real billable live request remains deliberately opt-in and is not
1978+
executed by CI.
19561979

19571980
## Gate
19581981

1959-
- [ ] `M12-G01 GATE` The same normalized mock conversation passes through all three adapters.
1960-
- [ ] `M12-G02 GATE` Cancellation stops UI streaming and prevents additional tool execution.
1961-
- [ ] `M12-G03 GATE` Every request has attributable provider, model, version, usage, price snapshot, latency, and final status.
1962-
- [ ] `M12-G04 GATE` Provider switching never occurs without explicit user authority.
1982+
- [x] `M12-G01 GATE` The same normalized mock conversation passes through all three adapters.
1983+
- [x] `M12-G02 GATE` Cancellation stops UI streaming and prevents additional tool execution.
1984+
- [x] `M12-G03 GATE` Every request has attributable provider, model, version, usage, price snapshot, latency, and final status.
1985+
- [x] `M12-G04 GATE` Provider switching never occurs without explicit user authority.
19631986

19641987
---
19651988

0 commit comments

Comments
 (0)