Skip to content

SOW-0001 Chunk 1: spec deltas (pricing, OS-theme matching)#2

Merged
ktsaou merged 1 commit into
masterfrom
sow-0001-chunk-1-spec-deltas
May 26, 2026
Merged

SOW-0001 Chunk 1: spec deltas (pricing, OS-theme matching)#2
ktsaou merged 1 commit into
masterfrom
sow-0001-chunk-1-spec-deltas

Conversation

@ktsaou
Copy link
Copy Markdown
Member

@ktsaou ktsaou commented May 26, 2026

Summary

First implementation chunk of SOW-0001 Phase 1 Foundation. Per the discipline contract, specs change first — this PR is pure specs, zero code.

Closes the three product-scope decisions the operator recorded on 2026-05-26:

  • Pricing: new spec pricing.md covering the embedded JSON schema, cost computation algorithm, and the scripts/refresh-pricing.sh CLI-AI-tool flow with PR-visible diffs.
  • UI theme: matches OS by default via prefers-color-scheme, with manual Auto/Dark/Light override in localStorage. Full resolution algorithm + no-flash inline script + tests in frontend-architecture.md. Bootstrap-era "Dark mode default" claim in ui-pages.md corrected to "OS preference is the default".

Files

  • New: .agents/sow/specs/pricing.md
  • Updated: .agents/sow/specs/frontend-architecture.md (Theming section)
  • Updated: .agents/sow/specs/ui-pages.md (Theme section + t shortcut)
  • Updated: .agents/sow/specs/index.md (register pricing.md)
  • Updated: .agents/sow/current/SOW-0001-phase-1-foundation.md (Chunk 1 evidence)

Discipline notes

  • Specs-first per project-workflow skill: this PR lands before any test or code touching pricing/theme.
  • External-reviewer round skipped: chunk is spec-only, no runtime behavior changes yet. Reviewers will run on the code chunks that implement these specs (Chunks 3+ where pricing/theme become executable).
  • Adapter-v2/v3 spec refinements anticipated in the original SOW-0001 plan are unnecessary — SOW-0002's evidence-based rewrites already covered the 5-second resolver-pass and fast-path linkage.

Next chunk: CI scaffolding.

Lands the three spec deltas that close the operator's recorded
decisions on Phase 1 product scope. Per the discipline contract,
specs change first; code follows in subsequent chunks.

New: .agents/sow/specs/pricing.md (~280 lines)
- Schema for internal/pricing/pricing.json embedded via go:embed.
- Per-provider, per-model, per-unit price fields (input, output,
  cache read, cache write 5m/1h, reasoning).
- Cost computation algorithm and source-recorded-cost-takes-
  precedence rule.
- Refresh script contract: scripts/refresh-pricing.sh invokes an
  external CLI AI tool (claude/codex/gemini/opencode), validates
  schema, prints diff, prompts before write, never auto-commits.
- Initial seed strategy via discovery query against the backfilled
  ops table.

Updated: .agents/sow/specs/frontend-architecture.md
- Theming section expanded with full resolution algorithm.
- Precedence: manual override in localStorage > OS preference via
  prefers-color-scheme.
- Three-state header control (Auto / Dark / Light) with explicit
  reset-to-auto.
- matchMedia 'change' listener re-applies only when no manual
  override is set.
- Inline pre-React script in index.html prevents flash-of-wrong-
  theme on first paint.
- Tests enumerated: unit on resolution algorithm, Playwright E2E
  + axe on both themes, OS-change simulation.

Updated: .agents/sow/specs/ui-pages.md
- Corrected the bootstrap-era "Dark mode default" claim to "OS
  preference is the default".
- Clarified the three-state control matches the resolution algo.
- Keyboard shortcut `t` cycles Auto -> Dark -> Light -> Auto.

Updated: .agents/sow/specs/index.md — pricing.md registered.

Updated: .agents/sow/current/SOW-0001-phase-1-foundation.md
- Implementation section records Chunk 1 evidence.
- Notes that anticipated adapter spec refinements are
  already covered by SOW-0002's evidence-based rewrites.

No code changes. Next chunk: CI scaffolding.
@ktsaou ktsaou merged commit 4f0274f into master May 26, 2026
1 check passed
@ktsaou ktsaou deleted the sow-0001-chunk-1-spec-deltas branch May 26, 2026 11:46
ktsaou added a commit that referenced this pull request May 30, 2026
…b_search

Round-2 fixes after external review found real spec-conformance gaps that
the per-chunk goldens (built from the same assumptions as the code) missed.
Verified against the real ~/.codex corpus (2,660 files).

- Turn lifecycle (the P1): old-format turn_context-only sessions (1,006
  real files, 38%) ended cleanly but were mislabeled failed/incomplete.
  Track NEW- vs OLD-format per turn; a new turn now finalizes the prior
  one (NEW->failed/replaced per edge #2; OLD->completed per edge #3);
  finalizeStale becomes finalizeAtEOF(stale): OLD-format turns close
  completed at EOF regardless of staleness (no SessionFinalized), NEW-format
  only finalize failed/incomplete when >=1h stale. scanner calls it at
  every full-read EOF.
- exec/patch enrichment now reaches op Extras order-independently: a
  finalizedOps lookup + an idempotent OpStarted re-emit carry exec_exit_code/
  exec_cwd/exec_duration_ms/exec_source onto the op row (OpFinalizedEvent has
  no Extras field), instead of degrading to a DBG log. Real order is
  exec_command_end before function_call_output in the majority.
- collab_agent_spawn_end now emits Op Kind=session Name=spawn
  ChildSessionNativeID=new_thread_id (was treated as unknown); collab_close_end/
  collab_waiting_end recognized. Spec corrected: the link is
  sender_thread_id->new_thread_id, not agent_ref.thread_id.
- Compaction dedup: one op from the data-bearing top-level compacted line;
  the adjacent event_msg.context_compacted (same compaction) is suppressed.
  Spec corrected: response_item.compaction/context_compaction do not occur in
  real data (forward-compat only).
- web_search_call carries no correlation id; pair positionally with the
  following web_search_end. image_generation has no real data (forward-compat).
- token_count with no open turn now emits a DBG log instead of silently
  dropping. Discovery enforces the YYYY/MM/DD shard depth. Softened a
  containment comment that overclaimed no-TOCTOU.

Regenerated b_old_turncontext / e_compaction / f_exec_truncated goldens to
the corrected behavior + real wire shapes; added i_collab_spawn /
j_replaced_turn / k_web_search fixtures, each line-checked against the spec.
Gates green: golangci(0)/gosec(0)/vet; go test -race ./... 13/13; codex
coverage 92.4%; FuzzParseLine 0 crashes; secret + AI-attribution scans clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant