Repository navigation
Description
Problem Description
Plan Check fails on the GitHub runner for every plan pull request, before it judges the plan. The job log of run 42257306607 (Plan Check, head 2dac29a of #3808, 2026-11-06 16:59) ends with:
✗ Could not check the plan: The tiktoken encoding is unavailable, so no exact token count exists. Install the encoding cache in the directory that TIKTOKEN_CACHE_DIR names: /tmp/data-gym-cache.
count_tokens in src/devops_cli/ai/context_budget.py loads the encoding from the cache directory. The runner job plan-check of .github/workflows/pr-title.yml sets up neither the cache nor a network path to fetch it, so the command exits 1.
Reproduction Steps
- Open a plan pull request (
docs(openspec): plan #<issue> <summary>) from the Service. - Read the
Plan Checkjob: step "Check the Plan".
Expected vs Actual Behavior
Expected: the job counts tokens and reports the problems of the plan, or none.
Actual: the job exits 1 with the tiktoken message. A person reads a red check that says nothing about the plan.
Environment Diagnostics
GitHub runner ubuntu-26.04, devops-cli 0.70.0, Python 3.14.
Proposed Solution & Architectural Design
- Find how the tests and the Service image provide the encoding cache (
tests/conftest.pysetsTIKTOKEN_CACHE_DIR; the Service image holds a cache). Give theplan-checkjob the same cache with a pinned, checksummed file or a cache step, as the other jobs get their data. - Add a check that fails if the job runs the command with no encoding cache, so the problem cannot return. Do not make the command skip the count when the cache is missing.
Existing Tool Considered
tiktoken already reads a cache directory, and actions/cache stores files between runs. The change adds no tool.
Proposed design
Problem statement
The Plan Check job fails before it judges a plan because the GitHub runner has no tiktoken encoding cache. The job must use the committed encoding fixtures and a check that prevents the cache setup from disappearing.
Acceptance criteria
Requirement: Plan Check prepares the encoding cache
The plan-check job SHALL fill TIKTOKEN_CACHE_DIR with the committed o200k_base and cl100k_base cache files before it runs devops roadmap plan-check.
Scenario: Clean runner
- WHEN the plan-check job starts on a runner with no tiktoken cache
- THEN the prepare step writes both cache files under their SHA-1 names into the directory that TIKTOKEN_CACHE_DIR names.
Requirement: Plan Check command uses the cache
The Check the Plan step MUST set TIKTOKEN_CACHE_DIR to the prepared cache directory.
Scenario: Workflow environment
- WHEN a test reads the plan-check job of .github/workflows/pr-title.yml
- THEN the test finds the same TIKTOKEN_CACHE_DIR value on the prepare step and on the Check the Plan step.
Requirement: Invariant test rejects a missing cache
An offline invariant test SHALL fail when the plan-check job lacks a cache preparation step or a TIKTOKEN_CACHE_DIR setting.
Scenario: Cache setup removed
- WHEN a test removes the cache preparation or the environment setting from a copy of .github/workflows/pr-title.yml
- THEN the invariant test fails and names the missing cache setup.
Requirement: Missing cache still stops the token count
The token count MUST keep raising TokenCountError when the encoding cache is absent.
Scenario: Empty cache directory
- WHEN a test calls count_tokens with TIKTOKEN_CACHE_DIR set to an empty directory
- THEN the call raises TokenCountError and does not return a character estimate.
Existing Tool Considered
No alternatives check has run. tiktoken reads a cache directory but does not download the encoding when the cache is absent. actions/cache stores files between runs but leaves a clean runner with no cache. The fix uses the committed encoding fixtures and adds no tool.
Key questions
- Where does the repository keep the tiktoken encoding files and how are their cache names made?: tests/conftest.py copies tests/fixtures/tiktoken/o200k_base.tiktoken and cl100k_base.tiktoken into the cache directory. It names each file with the SHA-1 of its OpenAI blob URL. The Docker images pre-populate the same cache. [sources: tests/conftest.py, tests/fixtures/tiktoken/o200k_base.tiktoken, tests/fixtures/tiktoken/cl100k_base.tiktoken]
- How should the plan-check job provide the tiktoken cache?: Copy the committed fixtures into RUNNER_TEMP/tiktoken-cache under their SHA-1 names and set TIKTOKEN_CACHE_DIR to that directory on the prepare step and the check step. (best practice) [sources: tests/conftest.py, .github/workflows/pr-title.yml]
- Chosen: Copy the committed fixtures. The files are pinned by the repository commit, need no network, and match the cache names in tests/conftest.py.
- Rejected: Restore with actions/cache. The first run on a clean runner has no cache to restore, so the job still fails.
- Rejected: Download the files from OpenAI. The download adds a network dependency and an unpinned remote input to the check.
- How should the repository prevent the cache setup from disappearing?: Add an offline invariant test that reads .github/workflows/pr-title.yml and fails when the plan-check job has no cache preparation step or no TIKTOKEN_CACHE_DIR on the Check the Plan step. (best practice) [sources: .github/workflows/pr-title.yml, tests/invariants/test_hermetic_floor.py, docs/adr/0004-ci-is-the-authoritative-gate.md]
- Chosen: Offline invariant test. The test fails in CI before a pull request merges, and it reads the workflow without a network.
- Rejected: Runtime guard only. A guard shows the failure only on a runner, after the pull request merges.
- Rejected: No new check. The same missing cache can return with no test failure.
- Should count_tokens skip the exact count when the cache is missing?: No. It must keep raising TokenCountError because the stage and the implement job need one exact measure. (best practice) [sources: src/devops_cli/ai/context_budget.py, tests/ai/test_context_budget.py]
- Chosen: Keep the TokenCountError. The stage and the implement job then use the same exact token measure.
- Rejected: Return a character estimate. Two paths could give different measures of the same text.
- Rejected: Skip the count with no error. The job would judge the plan with no token budget.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(ci)scope of the title gives the scope.Every plan pull request fails its check, blocking the review workflow.The failed run 42257306607 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.The check is the only automated gate for plan pull requests.The fix adds a cache step or pinned file to one CI job.Both concern the plan-check CI job, but #3103 creates the job while the candidate fixes its missing tiktoken cache.devops-cli-service commentedon Nov 6, 2026
Status set to Ready at 89daf41 (see proposed design in issue body).
devops-cli-service commentedon Nov 7, 2026
Released in v0.76.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.76.2
devops-cli-service commentedon Nov 7, 2026
Live since 2026-11-07 05:06 UTC