refactor(session-cache): rename staleness_minutes to staleness_seconds #94

Merged
alee merged 1 commits from feat/staleness-seconds into main 2026-09-18 04:50:29 +00:00
Owner

Rename session_cache.staleness_minutes → session_cache.staleness_seconds

Change the unit of session_cache.staleness from minutes to seconds so it can express finer-grained (sub-minute) staleness windows. This is a straight rename, not an additive/compat knob — no deprecated alias, matching the project's convention of updating every consumer in the same change (see how the old quota flat-keys shape was removed).

New bounds

Before (minutes) After (seconds)
floor 1 5
ceiling 120 7200 (unchanged in absolute terms)
default 20 1200 (same effective default)

Validator reasoning (preserved, adapted to seconds)

  • Floor: deliberately > 0 because 0 would make session_cache.get() miss every turn while put() still writes and the classifier-failure cascade's stale_read ignores staleness and replays regardless. The reasoning is unit-independent — a 5-second floor keeps that protection.
  • Ceiling: an unbounded window is a cache that never expires. 7200s is still >> 840s (the longest measured real session: 107 consecutive turns / 14 min from 2026-09-16). 7200/1200 = 6x default, 7200/840 ≈ 8.57x longest run — same ratios as before.

Files changed (13, all in one commit)

  1. src/config.py — STALENESS_MINUTES_MIN/MAX → STALENESS_SECONDS_MIN/MAX (5/7200); staleness_minutes: int = 20 → staleness_seconds: int = 1200; validator and error message updated
  2. src/dispatcher.py — dropped the * 60 conversion (field is native seconds now)
  3. src/admin.py — _INT_KNOBS key/path/constants, _CONFIG_ALLOWLIST, _CONFIG_GET_ORDER, _runtime_state, error message template
  4. admin/frontend/controls.html — note keys, tooltip text, NUMBER_BOUNDS min/max/step
  5. config/config.yaml — staleness_seconds: 1200
  6. tests/test_admin_runtime.py, tests/test_admin_frontend.py, tests/test_admin_knob_coverage.py, tests/test_admin_config.py — every old key/bound reference
  7. docs/admin-portal.md, docs/evaluation.md, README.md — prose and values
  8. tests/test_chat_completions.py — stale TTL comment

Not touched

  • config/config.local.yaml — gitignored, holds live production overrides, will be migrated separately after merge
  • plans/session-classification-cache-ttl.md, plans/classifier-input-scope-check.md — historical planning docs left as record

Verification

Full test suite passes: 2139 passed (94s).

## Rename `session_cache.staleness_minutes` → `session_cache.staleness_seconds` Change the unit of `session_cache.staleness` from minutes to seconds so it can express finer-grained (sub-minute) staleness windows. This is a **straight rename, not an additive/compat knob** — no deprecated alias, matching the project's convention of updating every consumer in the same change (see how the old quota flat-keys shape was removed). ### New bounds | | Before (minutes) | After (seconds) | |---|---|---| | floor | 1 | **5** | | ceiling | 120 | **7200** (unchanged in absolute terms) | | default | 20 | **1200** (same effective default) | ### Validator reasoning (preserved, adapted to seconds) - **Floor**: deliberately > 0 because 0 would make `session_cache.get()` miss every turn while `put()` still writes and the classifier-failure cascade's `stale_read` ignores staleness and replays regardless. The reasoning is unit-independent — a 5-second floor keeps that protection. - **Ceiling**: an unbounded window is a cache that never expires. 7200s is still >> 840s (the longest measured real session: 107 consecutive turns / 14 min from 2026-09-16). 7200/1200 = 6x default, 7200/840 ≈ 8.57x longest run — same ratios as before. ### Files changed (13, all in one commit) 1. **`src/config.py`** — `STALENESS_MINUTES_MIN/MAX` → `STALENESS_SECONDS_MIN/MAX` (5/7200); `staleness_minutes: int = 20` → `staleness_seconds: int = 1200`; validator and error message updated 2. **`src/dispatcher.py`** — dropped the `* 60` conversion (field is native seconds now) 3. **`src/admin.py`** — `_INT_KNOBS` key/path/constants, `_CONFIG_ALLOWLIST`, `_CONFIG_GET_ORDER`, `_runtime_state`, error message template 4. **`admin/frontend/controls.html`** — note keys, tooltip text, `NUMBER_BOUNDS` min/max/step 5. **`config/config.yaml`** — `staleness_seconds: 1200` 6. **`tests/test_admin_runtime.py`**, **`tests/test_admin_frontend.py`**, **`tests/test_admin_knob_coverage.py`**, **`tests/test_admin_config.py`** — every old key/bound reference 7. **`docs/admin-portal.md`**, **`docs/evaluation.md`**, **`README.md`** — prose and values 8. **`tests/test_chat_completions.py`** — stale TTL comment ### Not touched - **`config/config.local.yaml`** — gitignored, holds live production overrides, will be migrated separately after merge - **`plans/session-classification-cache-ttl.md`**, **`plans/classifier-input-scope-check.md`** — historical planning docs left as record ### Verification Full test suite passes: **2139 passed** (94s).
alee added 1 commit 2026-09-18 04:45:49 +00:00
Change the unit of session_cache.staleness from minutes to seconds so it
can express finer-grained (sub-minute) staleness windows. This is a
straight rename, not an additive/compat knob — no deprecated alias, per
the project's convention of updating every consumer in the same change.

New bounds: floor 5 seconds (was 1 minute), ceiling 7200 seconds (was
120 minutes). Default: 1200 seconds (was 20 minutes). The validator's
reasoning is unit-independent and carries over: the floor is deliberately
> 0 because 0 would make session_cache.get() miss every turn while
put() still writes and the classifier-failure cascade's stale_read
ignores staleness; the ceiling reasoning (unbounded window = never-expiring
cache, 7200s still >> 840s real max run) also carries over in seconds.

Every consumer updated in the same commit:
- src/config.py: STALENESS_MINUTES_MIN/MAX -> STALENESS_SECONDS_MIN/MAX
= 5/7200, staleness_minutes -> staleness_seconds: 1200, validator updated
- src/dispatcher.py: drop the * 60 conversion (field is native seconds)
- src/admin.py: _INT_KNOBS key/path/constants, _CONFIG_ALLOWLIST,
  _CONFIG_GET_ORDER, _runtime_state, error message template
- admin/frontend/controls.html: note keys, tooltip, NUMBER_BOUNDS
- config/config.yaml: staleness_seconds: 1200
- tests: test_admin_runtime/config/frontend/knob_coverage, plus stale
  comment in test_chat_completions
- docs: admin-portal.md, evaluation.md, README.md

config.local.yaml is gitignored and will be migrated separately.
alee merged commit e6e196315f into main 2026-09-18 04:50:29 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alee/6krrt#94