Skip to content

Simplify: dedup actor label, reuse JSON policy, StrEnum-ify usage window#211

Merged
alexkroman merged 2 commits into
mainfrom
claude/exciting-cori-hnn859
Jun 17, 2026
Merged

Simplify: dedup actor label, reuse JSON policy, StrEnum-ify usage window#211
alexkroman merged 2 commits into
mainfrom
claude/exciting-cori-hnn859

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Quality cleanups from a codebase-wide /simplify review (behavior-preserving):

  • audit: collapse _actor_label's redundant actor_type == "system" branch
    (both arms produced identical output since actor_type already defaults to
    "system").
  • auth/flow: route the --json login note through jsonshape.dumps so it
    shares the CLI's single default=str serialization policy instead of a raw
    json.dumps.
  • account: promote usage --window's hand-validated value set to a
    choices.UsageWindow StrEnum, matching every other choice flag — Typer now
    renders [day|week|month] in --help, validates, and tab-completes for free,
    dropping the bespoke validation block.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01ASaeJJ9LvPiSjcsEqywxwu

Quality cleanups from a codebase-wide /simplify review (behavior-preserving):

- audit: collapse `_actor_label`'s redundant `actor_type == "system"` branch
  (both arms produced identical output since actor_type already defaults to
  "system").
- auth/flow: route the `--json` login note through `jsonshape.dumps` so it
  shares the CLI's single `default=str` serialization policy instead of a raw
  `json.dumps`.
- account: promote `usage --window`'s hand-validated value set to a
  `choices.UsageWindow` StrEnum, matching every other choice flag — Typer now
  renders [day|week|month] in --help, validates, and tab-completes for free,
  dropping the bespoke validation block.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASaeJJ9LvPiSjcsEqywxwu
@alexkroman alexkroman enabled auto-merge June 17, 2026 03:36
The `--llm` map render and `--llm-reduce` orchestration were implemented three
times — in commands/transcripts.py and app/transcribe/{run,batch}.py — each a
copy of the same policy (the `transform` record shape, the per-block reduce
header, the empty-input guard that skips the billable Gateway call, and the
additive `{"type": "reduce", …}` NDJSON schema). The copies were already drifting
and any change to the shapes had to be made in three places.

Promote the delivery policy to a new app-layer module, app/transform.py:
- render_transform_steps (moved out of app/transcribe/run.py)
- emit_transform — the per-transcript map result render (NDJSON-per-id in batch,
  else the transcribe JSON/human render)
- emit_reduce — the reduce chain over labeled (id, text) contributions, with the
  shared header/empty-guard/NDJSON policy; callers pass only the block label and
  the empty-input noun so the exact wording is preserved.

transcripts.py and batch.py now delegate to these; batch._gather_reduce_inputs
returns (source, text) tuples and lets emit_reduce own the header and the
nothing-to-reduce policy. Behavior is unchanged (same output, same messages).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASaeJJ9LvPiSjcsEqywxwu
@alexkroman alexkroman added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit 631603e Jun 17, 2026
19 checks passed
@alexkroman alexkroman deleted the claude/exciting-cori-hnn859 branch June 17, 2026 03:44
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.

2 participants