Files
pad/internal
xarmian aaa581b105 refactor(bootstrap): extend dashboard caps to active_items/active_plans/by_role (TASK-1422) (#541)
* refactor(bootstrap): extend dashboard caps to active_items/active_plans/by_role/suggested_next (TASK-1422)

Implements IDEA-1421 (absorbed into PLAN-1410's v0.4 envelope). Extends
the BootstrapDashboard wrapper from TASK-1413 to cap four more
dashboard sub-arrays with parallel overflow counts, same shape and
semantics as the existing attention/recent_activity caps.

## Struct + caps

Four new int fields on BootstrapDashboard (all `,omitempty`):

  - active_items_overflow_count
  - active_plans_overflow_count
  - by_role_overflow_count
  - suggested_next_overflow_count

Four new cap constants alongside the existing two:

  - bootstrapActiveItemsCap   = 5
  - bootstrapActivePlansCap   = 5
  - bootstrapByRoleCap        = 5
  - bootstrapSuggestedNextCap = 5

capBootstrapDashboard extended with four parallel truncate-and-count
blocks — same shallow-copy mutation pattern, source pointer
untouched (the dashboard endpoint still returns its full-length
arrays per its own contract).

## Tests

TestCapBootstrapDashboard rewritten to cover all six caps under one
contract. `mk` now takes a `dashCounts` struct (Att/Rec/Items/Plans/
Role/Sugg) so each subtest exercises specific caps without populating
the others. Each of the four existing subtests (under-cap-no-overflow,
over-cap-truncates-and-counts-overflow, source-pointer-unchanged,
exact-cap-no-overflow) now asserts the new caps too. Added tiny
assertLen/assertOverflow helpers to keep the per-array assertion
noise from drowning the contract being tested.

bootstrapSectionBytes extended to surface the four new cap-effect
lines when triggered, table-driven so future caps drop in cleanly.

seedBootstrapSizeFixture updated to seed 6 in_progress tasks (was 5
open) so the new active_items cap fires visibly in the per-section
breakdown: "active_items capped: 5 shown, 1 overflow". The status
flip is deliberate — dashboard.active_items filters on
isActiveStatus(), which excludes initial/terminal statuses; open
tasks never appeared in the section.

## Budget

bootstrapSizeBudget 7 KiB → 9 KiB. Note that this is FIXTURE-side
growth, not shape-side regression: the fixture now seeds enough
active items to exercise the new cap (active_items section was 0
bytes when tasks were status=open). The cap itself is purely a
SAVINGS — on docapp it drops active_items from 7 → 5 entries with
overflow_count=2.

Budget history note in handlers_bootstrap_test.go updated with the
TASK-1422 line and an explicit "fixture-side, not shape-side"
explanation so future readers understand why the budget moved up.

## Out of scope

- Slim BootstrapRole projection — TASK-1423.
- Schema label + sort_order trim — TASK-1424.
- ToolSurfaceVersion 0.3 → 0.4 bump — TASK-1418 (final PR).

Parent: PLAN-1410. Resolves IDEA-1421 once merged.

* fix(bootstrap): drop unreachable suggested_next cap (TASK-1422 follow-up)

Address Codex P1 finding on PR #541: `suggested_next_overflow_count`
was unreachable in production responses because
`buildDashboardResponse` already truncates `SuggestedNext` to 3
upstream (see "Take top 3" comment in handlers_dashboard.go:854-858),
while my bootstrap cap was 5. The cap-and-overflow logic could only
have fired against synthetic test state, never against the real
dashboard pipeline.

Two responses to consider:

  1. Lower bootstrap's cap to a number smaller than 3 — defeats the
     upstream design choice (3 IS the intentional limit).
  2. Drop the bootstrap-side cap — clean, no dead surface.

Going with (2). If the upstream cap is ever raised or removed,
that's the moment to add a suggested_next_overflow_count back.

Removed:

  - SuggestedNextOverflowCount field on BootstrapDashboard
  - bootstrapSuggestedNextCap constant
  - The truncate-and-count block in capBootstrapDashboard
  - The suggested_next row in TestCapBootstrapDashboard's dashCounts
    helper and all five subtest assertions
  - The suggested_next entry in bootstrapSectionBytes's cap-line loop

The fixture still seeds tasks and a plan, so the no-cap path on
SuggestedNext is naturally exercised through TestBootstrapSizeBudget.
The godoc on BootstrapDashboard now explicitly calls out the
exclusion + the upstream-cap rationale so a future reader knows
why suggested_next is missing from the otherwise-uniform cap set.

Parent: PLAN-1410 / TASK-1422.

* docs(skill): align SKILL.md dashboard cap description with TASK-1422

Address Codex P3 finding on PR #541: the SKILL.md `Context Loading`
section described only the two original cap fields
(attention_overflow_count, recent_activity_overflow_count). After
TASK-1422 the bootstrap response carries three more
(active_items_overflow_count, active_plans_overflow_count,
by_role_overflow_count), and the agent needs to know to pull the
full set via `pad project dashboard` when any of them are > 0.

Updated the bullet to enumerate all five capped sub-arrays and
state the overflow-field pattern generically rather than per-field.
Same in-PR-sync pattern used for TASK-1413, TASK-1415, TASK-1416.

Parent: PLAN-1410 / TASK-1422.

* docs(bootstrap): fix three stale comments after dropping suggested_next cap (TASK-1422 follow-up)

Address Codex P3 finding on PR #541 round 3: three stale doc strings
referenced the old shape (with suggested_next) after the cap was
dropped in the prior commit. Updated:

1. handlers_bootstrap_test.go budget-history line for TASK-1422 —
   removed `suggested_next` from the cap list and added the
   "deliberately excluded — already capped to 3 upstream" rationale
   so future readers know why the otherwise-uniform cap set is
   missing one.

2. handlers_bootstrap.go BootstrapDashboard godoc — changed
   "two overflow counts" to "five overflow counts (one per capped
   sub-array)".

3. handlers_bootstrap.go capBootstrapDashboard godoc — changed
   "both caps are untriggered" to "all caps are untriggered".

Tidy-up only, no behavior change. Same skill-↔-code sync hygiene
that has been the running theme across PLAN-1410's review loops.

Parent: PLAN-1410 / TASK-1422.

* docs(bootstrap): update remaining stale call-site comment for capBootstrapDashboard (TASK-1422 follow-up)

Final stale-doc cleanup per Codex P3 on PR #541 round 4: the
BuildAgentBootstrap dashboard-wrapping call-site comment still
listed only attention + recent_activity. Updated to enumerate all
five capped sub-arrays for parity with the godoc on
BootstrapDashboard / capBootstrapDashboard.

Same hygiene as the previous commit; no behavior change.

Parent: PLAN-1410 / TASK-1422.
2026-05-13 17:10:56 -04:00
..
2026-03-26 01:52:36 +00:00