Files
ai-job-search/.claude/commands
3bf41149e0 fix(rank): move seen_jobs.json read/write off /rank's per-run cost (#395) (#425)
* fix(rank): move seen_jobs.json read/write off the state file's own critical path (#395)

/rank's Step 1 read the whole of seen_jobs.json into the conversation to
select candidates by eye, and Step 4 emitted it back to record scores.
That cost is paid on every run regardless of how many jobs are scored,
and it grows for the life of the workspace, since the file is
append-only and most stored entries are `skipped`.

tools/rank_state.py moves that traffic into code:

- `candidates` selects entries per Step 1's existing rules (status
  filter, tracker exclusion, focus filter, `--limit`/`--all` from #424)
  and projects only the fields a scoring agent needs.
- `sweep` runs rule 6's expiry pass over entries the run did not
  re-score - a stored-date comparison, no fetch, no agent - preserving
  its defensive parsing of non-ISO deadlines and its `--all`
  reversibility.
- `apply` writes scoring results back atomically and prints the
  ranked/vetoed/expired rows Step 5's report is built from, preserving
  Step 4's existing write-back rules exactly: the `location` ->
  `location_verdict` legacy migration, the deadline
  null-is-not-a-correction rule, verbatim strengths/gaps persistence,
  and idempotent re-scoring.

Step 1, Step 3's rule 6, and Step 4 now route through the tool instead
of describing a manual read/write. Nothing about scoring policy changes
- no new status, no new persisted field, no change to what counts as a
veto. The tracker stays read-only and every write is atomic (temp file
+ rename).

tests/test_rank_state.py (25 tests) covers the three subcommands
directly. The new spec-guard class in test_rank_command.py derives the
fields Step 4 must preserve from Step 2's own JSON schema block rather
than retyping them as a second list, so a future edit to that contract
is what the test reads instead of something that can drift from it.

* fix(rank): add CHANGELOG entry and remove the undefined $SCRATCHPAD reference

Two mechanical fixes from review:

- Step 4 named the results hand-off file via $SCRATCHPAD, a variable
  nothing in the repo defines - a reader following the spec literally
  has no path to substitute. Named the location in prose instead (a
  temporary file outside the repo tree, never committed) and replaced
  the shell-variable-looking path in the example command with an
  explicit placeholder.
- Added the [Unreleased] entry this change was missing; the one
  already in the diff belongs to #424.

* changelog: fold the #395 entry into the existing Fixed section

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013fqqLgQSnwgWkv98twQhHi

---------

Co-authored-by: nox <nox@Mac.home>
Co-authored-by: Mads Lorentzen <madslorentzen17@gmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 10:49:20 +02:00
..