Skip to content

Enforce Pinned Context caps (12 pins × 1500 chars) with override escape hatch #492

@michael-wojcik

Description

@michael-wojcik

Context

Project CLAUDE.md has been growing unbounded in the Pinned Context section. As of 2026-04-20 it hit 43.4k chars (warning threshold 40k), with 23 pins averaging 1,254 chars — total ~29k chars just in the pinned block. The soft ~1200 token budget warning comment in staleness.py has been ignored for weeks because it has no teeth.

A manual curation pass on 2026-04-20 reduced the section to 12 pins × ≤1500 chars (with one override). This issue tracks making the cap structural.

Proposed Enforcement Shape

  1. /PACT:pin-memory refuses add when:

    • current pin count == 12 (cap), OR
    • new pin body > 1500 chars

    ...unless the pin has a <!-- pin-size-override: {rationale} --> comment.

  2. Refusal returns a decision prompt: "Evict which existing pin? [numbered list of current pins] / Or split this pin? / Or archive to pact-memory only?"

  3. SessionStart staleness check gains a hard rule: ≥2 pins flagged STALE → block session start until orchestrator confirms archive/retain (current behavior just decorates with <!-- STALE: ... -->).

  4. Orchestrator instructions surface pin-slot count in context (e.g., "11/12 pin slots used, 340 chars remaining on largest pin"). Helps orchestrator self-calibrate before attempting add.

Override escape hatch

Some pins legitimately exceed 1500 chars because the verbatim text is load-bearing for LLM readers (agents need to read the exact string, not a paraphrase). The canonical `Task()` dispatch form is the current example. Override syntax:

```markdown

Canonical Task() dispatch is mirrored inline at every consumer site

...
```

Rule: override rationale is required, visible in markup, and surfaces in the pin-memory command audit.

Acceptance Criteria

  • `/PACT:pin-memory` enforces 12-pin cap + 1500-char per-pin cap at add-time
  • `pin-size-override` comment bypasses char cap (with required rationale)
  • Refusal returns eviction prompt listing current pins with sizes
  • Staleness hook blocks session start when ≥2 pins are marked stale
  • Orchestrator context surfaces `pin-slots-used/12` count
  • Existing 12-pin curation (2026-04-20) passes the new enforcement unchanged

Implementation Notes

Touches:

  • `pact-plugin/commands/pin-memory.md` — add-time gates
  • `pact-plugin/hooks/staleness.py` — hard block on ≥2 stale
  • `pact-plugin/hooks/shared/claude_md_manager.py` — override comment parser + slot-count surfacing
  • `pact-plugin/hooks/session_init.py` — inject pin-slot count into orchestrator context

Variety Assessment

Estimated variety: ~9 (hook_infrastructure + user-facing-protocol-changes). Per institutional calibration prior (+6 floor for this domain, evidenced by PR #454, #457, #477), plan for effective variety ~15 with 4-6 remediation cycles. Plan-mode recommended before orchestrate to avoid mid-implementation scope creep — particularly around the override comment syntax and eviction prompt UX.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions