Files
pad/internal
xarmian 638a456f98 refactor(bootstrap): dedup recent_activity, drop convention slug, cap dashboard arrays (TASK-1413) (#536)
* refactor(bootstrap): dedup recent_activity, drop convention slug, cap dashboard arrays (TASK-1413)

Three bundled handler-level cleanups against PLAN-1410's bootstrap
shape. Total fixture savings: 8,992 → 6,355 bytes (-2,637 b / -29%).

1. Drop duplicate top-level `recent_activity`

   AgentBootstrap.RecentActivity was bit-for-bit identical to
   AgentBootstrap.Dashboard.RecentActivity. Removed:

     - AgentBootstrap.RecentActivity field
     - capRecentActivity() helper
     - recentActivityWindow constant
     - the time import (no longer used)

   Fixture savings: -1,751 bytes.

2. Drop `slug` from AgentBootstrapConvention

   Agents address convention items by ref (CONVE-N); slug was dead
   weight. Removed the field + the population line in
   collectAlwaysOnConventions.

   Fixture savings: -78 bytes.

3. Cap dashboard.attention + dashboard.recent_activity to 5 in bootstrap

   New BootstrapDashboard wrapper embeds *DashboardResponse (so the
   wire shape stays compatible — same field names, same nesting) and
   adds two overflow counts:

     - attention_overflow_count       (omitempty when zero)
     - recent_activity_overflow_count (omitempty when zero)

   The cap is applied via capBootstrapDashboard which shallow-copies
   the DashboardResponse before truncating the slices, so callers
   downstream of buildDashboardResponse (the dashboard endpoint
   itself, the web UI) see their original full-length arrays
   unchanged. `pad project dashboard` contract is preserved verbatim.

   Fixture savings: -789 bytes (recent_activity capped 9 → 5;
   attention untouched, fixture has 0 attention items).

Coverage:

  - TestCapBootstrapDashboard (4 subtests): under-cap-no-overflow,
    over-cap-truncates-and-counts-overflow, source-pointer-unchanged,
    exact-cap-no-overflow. Locks in the cap contract independent of
    the full bootstrap pipeline.
  - TestBootstrapEmptyArraysNotNull updated: the top-level
    recent_activity key was removed from the required-keys list,
    with a separate assertion that guards against it reappearing.
  - TestBootstrapEmptyWorkspace updated: removed the b.RecentActivity
    nil-check; added a (defensive) check that dashboard's nested
    recent_activity is non-nil when dashboard is present.
  - bootstrapSectionBytes now surfaces the cap effect ("attention
    capped: 5 shown, 4 overflow") when triggered, so the trim's
    value is legible from CI output.

bootstrapSizeBudget tightened 11 KiB → 8 KiB to lock in the win.
Budget-history comment updated.

Out of scope (handled by later PLAN-1410 PRs):

  - Skill-file trim (TASK-1414/1415/1416)
  - Final measurement (TASK-1417)
  - ToolSurfaceVersion 0.3 → 0.4 (TASK-1418, after all shape
    changes land)

Parent: PLAN-1410.

* docs(skill): align SKILL.md bootstrap shape with PLAN-1410 / TASK-1413

The skill's `Context Loading` section described the old wire shape:

  - `dashboard {...}` — active items, attention, suggested next, recent activity
  - `recent_activity [...]` — capped to the last 24h

After TASK-1413 the top-level `recent_activity` field is gone (it was
a bit-for-bit duplicate of `dashboard.recent_activity`), and the
remaining `dashboard.recent_activity` is capped by COUNT (top 5) not
by TIME (24h window). The two cap fields (attention_overflow_count
and recent_activity_overflow_count) tell the agent how much was
trimmed so it can decide whether to follow up with a full
`pad project dashboard` query.

Per the Codex P2 finding on PR #536: documenting the new contract
in this PR keeps skill ↔ wire-shape strictly synchronized (no
window where the docs are wrong about the shape this PR ships).

Parent: PLAN-1410 / TASK-1413.
2026-05-13 15:29:59 -04:00
..
2026-03-26 01:52:36 +00:00