Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-25
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Design

## Decisions

- Wrap `run_stage_agent(folders, model=script.model())` inside `with time_machine.travel(NOW, tick=False):` inside `test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues` so `datetime.now(UTC)` matches the `now=NOW` argument already passed to `_prepare(...)`, while leaving `fake_github` fixture setup (`time.time() + 600.0`) outside the travel block.

## Rejected alternatives

- Passing a synthetic `now=` parameter into `run_stage_agent`: adds test-only parameters to production code; `AGENTS.md` Rule 2 and existing stage tests favor `time_machine.travel`.
- Bumping `NOW` to a future year: only delays the failure until that date arrives.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Proposal: #7181

## Why

`tests/roadmap/stage/test_roadmap_stage_github_snapshot.py::test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues` prepares `inputs` with `now=NOW` (`2026-11-25T09:00:00Z`), which sets `inputs.deadline` in the past once the real wall clock passes `13:00Z` on `2026-11-25`. `run_stage_agent` runs without freezing the clock, so `within_budget` raises `RoadmapTimeBudgetError` before any model call and leaves `script.tools_offered == []` on `origin/main`.

## What Changes

- Freeze the wall clock around `run_stage_agent` with `time_machine.travel(NOW, tick=False)` in `tests/roadmap/stage/test_roadmap_stage_github_snapshot.py::test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues`.

## Capabilities

- `stage-agent-phase`: Snapshot test determinism against frozen stage deadline time (#7181).

## Impact

- Unblocks `Tests & Coverage (shard 2 of 5)` on `origin/main` and open pull requests without altering production code.

## Feasibility

Verified directly against `origin/main` (`0b9c6983f`): running `test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues` after `13:00Z` fails consistently with `AssertionError: assert [] == [['edit_file', 'grep', 'list_files', 'read_file', 'shell', 'write_file']]`. Fix is a two-line `time_machine.travel` wrapper in the test.

## Existing Tool Considered

Uses the already-installed `time_machine` pytest dependency (`pyproject.toml`, already used across `tests/roadmap/stage/test_roadmap_stage_plan.py` and `test_roadmap_stage_verify_eval.py`). Cost to fix with `time_machine` is ~5k tokens and ~15 minutes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Purpose

Keep stage agent phase snapshot tests independent of the wall clock when testing prepared run folders whose deadlines were generated with a frozen `NOW`.

## ADDED Requirements

### Requirement: Stage snapshot tests match the prepared clock
`test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues` MUST run `run_stage_agent` under the same frozen `NOW` timestamp passed to `prepare_stage_job` so `within_budget` does not expire against real wall-clock time.

#### Scenario: Running after 13:00 UTC on 2026-11-25
- **WHEN** `prepare_stage_job` receives `now=NOW` and `run_stage_agent` runs under `time_machine.travel(NOW, tick=False)`
- **THEN** `run_stage_agent` invokes the model once and `script.tools_offered` equals `stock.tools_offered`
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tasks

## 1. Behavior

- [x] 1.1 Reproduce the wall-clock failure on `origin/main` with `pytest`
- Verification: `$ uv run pytest -n 0 tests/roadmap/stage/test_roadmap_stage_github_snapshot.py::test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues -q`
- [x] 1.2 Freeze `NOW` around `run_stage_agent` with `time_machine.travel(NOW, tick=False)` and verify all snapshot tests pass
- Verification: `$ uv run pytest -n 0 tests/roadmap/stage/test_roadmap_stage_github_snapshot.py -q`

## 2. Verification

- [x] 2.1 Archive the OpenSpec change and pass local CI gates
- Verification: `$ uv run devops ci --check --no-cache --skip test,outdated`
14 changes: 14 additions & 0 deletions openspec/specs/stage-agent-phase/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# stage-agent-phase Specification

## Purpose

Keep stage agent phase snapshot tests independent of the wall clock when testing prepared run folders whose deadlines were generated with a frozen `NOW`.

## Requirements

### Requirement: Stage snapshot tests match the prepared clock
`test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues` MUST run `run_stage_agent` under the same frozen `NOW` timestamp passed to `prepare_stage_job` so `within_budget` does not expire against real wall-clock time.

#### Scenario: Running after 13:00 UTC on 2026-11-25
- **WHEN** `prepare_stage_job` receives `now=NOW` and `run_stage_agent` runs under `time_machine.travel(NOW, tick=False)`
- **THEN** `run_stage_agent` invokes the model once and `script.tools_offered` equals `stock.tools_offered`
4 changes: 3 additions & 1 deletion tests/roadmap/stage/test_roadmap_stage_github_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import httpx2
import pytest
import time_machine
from pydantic_ai import Agent
from pydantic_ai.capabilities import LocalWorkspace
from pydantic_ai.messages import ModelRequest, UserPromptPart
Expand Down Expand Up @@ -359,7 +360,8 @@ def test_agent_phase_offers_stock_tools_only_without_read_issue_or_find_issues(
).run_sync("go")

script = ModelScript(say("done"))
run_stage_agent(folders, model=script.model())
with time_machine.travel(NOW, tick=False):
run_stage_agent(folders, model=script.model())

assert script.tools_offered == stock.tools_offered
offered_names = {name for call in script.tools_offered for name in call}
Expand Down