Skip to content

0006 Remember picked jobs as hashes in the Actions cache

Superseded

Since Phase 2 of the demo, the daily run emails each tester and keeps each tester's memory in D1, as HMAC-SHA256 hashes made with a secret key (ADR 0012). The Actions cache isn't used anymore. seen_jobs.py still works for running the ranker on your computer.

Context

The daily list must never show the same job twice. The collector looks back two days, so most jobs appear in two runs in a row. The ranker needs to know which jobs it has already picked.

ADR 0004 left this open: the daily run keeps nothing, and a new ADR must choose storage before the email step. The same constraints apply:

  • The repository is public. Its logs, run summaries, and anything committed are public.
  • The source terms forbid republishing jobs (Job sources). No titles, links, or other job data may be stored anywhere others can read.

The ranker doesn't need any job data to recognize a job it has picked. A SHA-256 hash of the job ID is enough. A hash can't be turned back into the job ID, and it's the same every time for the same job.

Options considered

Option For Against
Hashes in the GitHub Actions cache No token or secret to manage. Nothing is committed. GitHub removes old entries on its own. Anyone who can open a pull request can read the cache. GitHub removes an entry that isn't used for 7 days, so the memory can be lost.
Hash list committed to the repository Never lost, and changes are visible A bot would push to main every day, bypassing review. Git history keeps every hash forever, so the 60-day limit wouldn't really delete anything.
Hash list in a secret gist Survives longer than the cache A secret gist is only unlisted: anyone with the link can read it. Needs a personal access token that can change every gist on the account, stored as a repository secret. Gist history also keeps every hash.

Decision

Keep the memory in the GitHub Actions cache, and store only hashes.

  • What's stored: one JSON file with the SHA-256 hash of each picked job's ID and the date it was first picked. No titles, links, companies, or other job data.
  • How long: 60 days. Each time the ranker loads the file, it drops hashes older than that. The collector only looks back two days, so 60 days is far more than needed, and the file stays small: at 10 picks a day, about 600 hashes.
  • When: the daily workflow restores the newest memory before collecting, the ranker skips jobs whose hash is already stored and adds today's picks, and the workflow saves the memory after ranking succeeds.
  • How the cache is updated: a saved cache can't be changed. Each run saves a new cache under its own key, seen-jobs-<run ID>-<attempt>. The next run restores the newest one that starts with seen-jobs-. GitHub removes the old ones after 7 days without use.

GitHub's dependency caching reference describes these rules, including who can read a cache.

If the cache is lost

The memory can disappear: the workflow doesn't run for 7 days, GitHub evicts it to make room, or someone deletes it. The ranker then starts with an empty memory. Jobs that are still in the collector's two-day window may be picked again, so the list has a few repeats for a day or two. That's acceptable. A lost memory never stops a run.

Consequences

  • Nothing that could republish a job leaves the runner, and the run summary still shows counts only.
  • The hashes aren't secret. Job IDs are public, so anyone could hash today's postings and check which ones were picked. That reveals which public jobs matched a public profile, not any job data. When profiles become private (Milestone 2), this needs a keyed hash with a secret key, or private storage.
  • No tokens or secrets are needed, and nothing is committed.
  • With many users, each user needs their own memory. One way is to hash the profile name together with the job ID.
  • The same job posted on both boards has two IDs. If the collector keeps a different copy on another day, the job can repeat.
  • The job file itself is still not kept, as ADR 0004 decided.