Extend check_context_budget with the immediate (working-dir) + peripheral (substrate) tiers #319

Closed
opened 2026-07-03 06:37:29 +00:00 by coilysiren · 2 comments
Owner

Companion to the ward-side design in ward#373 (docs/context-probe.md).

The ask (measurement leg, per the aos authoring-vs-rollout split)

check_context_budget (agentic_os/pre_commit/check_context_budget.py, docs/context-budget.md) today measures the proactive axis only (composed doc + skill frontmatter + mcp note), per harness. ward#373 generalizes context accounting to three tiers per warded role. Two of those tiers are generic, aos-layer measurement primitives that ward should consume, not reimplement:

  • immediate - a walker over a working-dir clone: tracked-file count, bytes, chars/4 token proxy (git ls-files, tracked only so build/vendor trees do not inflate it).
  • peripheral - the same walker applied per-repo across a set of reference repos, plus a total.

Scope

  • Measurement-only, reversible, no new enforcement here. Add the two walkers as reusable functions behind the existing count_tokens proxy so ward's role-aware probe can call them for tiers 2/3 while reusing the current doc/skill accounting for tier 1.
  • The role-spin probe and the per-driver context-budget spec schema stay in ward (it owns roles, containers, substrate, WARD_CONTEXT_LEVEL). Do not model ward roles here - that would reach up a layer.

Non-goals

  • A real qwen tokenizer (chars/4 proxy is fine; the swap point is count_tokens).
  • Runtime/accumulated context (this is init load).

Filed from a ward container run carrying ward#373.

Companion to the ward-side design in [ward#373](https://forgejo.coilysiren.me/coilyco-flight-deck/ward/issues/373) (`docs/context-probe.md`). ## The ask (measurement leg, per the aos authoring-vs-rollout split) `check_context_budget` (`agentic_os/pre_commit/check_context_budget.py`, `docs/context-budget.md`) today measures the **proactive** axis only (composed doc + skill frontmatter + mcp note), per harness. ward#373 generalizes context accounting to three tiers per warded **role**. Two of those tiers are generic, aos-layer measurement primitives that ward should **consume**, not reimplement: - **immediate** - a walker over a working-dir clone: tracked-file count, bytes, chars/4 token proxy (`git ls-files`, tracked only so build/vendor trees do not inflate it). - **peripheral** - the same walker applied per-repo across a set of reference repos, plus a total. ## Scope - Measurement-only, reversible, no new enforcement here. Add the two walkers as reusable functions behind the existing `count_tokens` proxy so ward's role-aware probe can call them for tiers 2/3 while reusing the current doc/skill accounting for tier 1. - The **role-spin probe** and the **per-driver context-budget spec schema** stay in ward (it owns roles, containers, substrate, `WARD_CONTEXT_LEVEL`). Do **not** model ward roles here - that would reach up a layer. ## Non-goals - A real qwen tokenizer (chars/4 proxy is fine; the swap point is `count_tokens`). - Runtime/accumulated context (this is init load). Filed from a ward container run carrying ward#373.
Member

🔒 Reserved by ward agent --driver claude — container engineer-claude-agentic-os-319 on host KAI-DESKTOP-TOWER is carrying this issue (reserved 2026-07-04T08:59:47Z). Concurrent ward agent runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); --force overrides.

Do not comment on or edit this issue to steer the run while it is reserved. The engineer seeded the body once at launch and never re-reads it, so a comment or edit reaches only human readers, never the running engineer. A correction goes to a new issue, dispatched fresh — that is the only channel that reaches a run in flight. Where the forge supports it, ward locks this conversation to make that a road-block rather than a convention (ward#494).

— Claude (she/her), via ward agent

<!-- ward-agent-reservation --> 🔒 Reserved by `ward agent --driver claude` — container `engineer-claude-agentic-os-319` on host `KAI-DESKTOP-TOWER` is carrying this issue (reserved 2026-07-04T08:59:47Z). Concurrent `ward agent` runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); `--force` overrides. **Do not comment on or edit this issue to steer the run while it is reserved.** The engineer seeded the body once at launch and never re-reads it, so a comment or edit reaches only human readers, never the running engineer. A correction goes to a **new issue, dispatched fresh** — that is the only channel that reaches a run in flight. Where the forge supports it, ward locks this conversation to make that a road-block rather than a convention (ward#494). <!-- ward-agent-signature --> — Claude (she/her), via `ward agent`
Author
Owner

WARD-OUTCOME: done - added immediate_walk / peripheral_walk tier primitives + --immediate/--peripheral flags to check_context_budget, landed on main.

Felt like a clean, well-scoped extension - the existing module already had count_tokens as the single proxy seam the issue pointed at, so the two walkers dropped in behind it without touching the proactive-axis code at all. The one thing that fought back was the doc layout cap: docs/context-budget.md was already sitting a hair under the 4000-char / 80-line ceiling, so my paragraph blew past it and I spent a few rounds trimming before splitting the tier detail into its own docs/context-tiers.md - which is the better shape anyway.

Confident in the result: git ls-files (tracked-only) keeps build/vendor out, deleted-but-staged paths are skipped so files/bytes/tokens stay coherent, and I kept the layer strictly role-agnostic (paths in via flags, never a substrate set named here) per the authoring-vs-rollout split. Verified end-to-end against the real /workspace + /substrate clones, 12 unit tests green, full pre-commit suite passing.

Rough edge worth flagging for ward#373's side: the token proxy on a whole-repo walk implies a full ingest that never happens (a driver greps), so file-count and bytes are the honest signals - I documented that as the upper-bound caveat but the real fix is ward#373 open fork 4 deciding the tier-2/3 unit.

WARD-OUTCOME: done - added immediate_walk / peripheral_walk tier primitives + --immediate/--peripheral flags to check_context_budget, landed on main. Felt like a clean, well-scoped extension - the existing module already had count_tokens as the single proxy seam the issue pointed at, so the two walkers dropped in behind it without touching the proactive-axis code at all. The one thing that fought back was the doc layout cap: docs/context-budget.md was already sitting a hair under the 4000-char / 80-line ceiling, so my paragraph blew past it and I spent a few rounds trimming before splitting the tier detail into its own docs/context-tiers.md - which is the better shape anyway. Confident in the result: git ls-files (tracked-only) keeps build/vendor out, deleted-but-staged paths are skipped so files/bytes/tokens stay coherent, and I kept the layer strictly role-agnostic (paths in via flags, never a substrate set named here) per the authoring-vs-rollout split. Verified end-to-end against the real /workspace + /substrate clones, 12 unit tests green, full pre-commit suite passing. Rough edge worth flagging for ward#373's side: the token proxy on a whole-repo walk implies a full ingest that never happens (a driver greps), so file-count and bytes are the honest signals - I documented that as the upper-bound caveat but the real fix is ward#373 open fork 4 deciding the tier-2/3 unit.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
coilyco-flight-deck/agentic-os#319
No description provided.