5.1 KiB
Tasks: Project Map Prompt Injection
Status
| Field | Value |
|---|---|
| Phase | Tasks |
| Based on | Design |
| Next | Apply |
Delivery slices
Slice 1: Injection policy scaffold and config surface
Scope: mode/config scaffolding, pre-init hint behavior, canonical helper boundaries Review goal: establish the policy control surface without yet wiring the full runtime pipeline
Tasks:
- Add a shared prompt-injection policy helper/module
- Add config support for injection mode, context-budget percent, and absolute cap using additive flat JSON keys compatible with existing
.pi-project-map.jsonloading - Decide and document how existing
contextBudgetinteracts with the new injection-budget knobs - Implement pre-init startup-hint behavior with no synthetic artifact injection
- Define canonical marker/block construction for injected root-pair content
- Add/update tests for config loading and pre-init hint behavior
Slice 2: Root-pair preload and budgeted expansion
Scope: post-init preload, budget calculation, artifact selection under cap Review goal: make automatic injection materially real after init
Tasks:
- Implement guaranteed root-pair preload after init
- Implement effective-budget calculation using percent + absolute cap with smaller-wins semantics
- Implement active-model context-window discovery and explicit absolute-cap fallback when metadata is unavailable
- Implement deterministic budgeted expansion beyond the root pair
- Keep retrieval explicitly out of this injection path
- Add/update tests for root-pair guarantee, context-window fallback, and budget-capped expansion
Slice 3: Reinjection avoidance and relevant-turn checks
Scope: outgoing-context scanning, relevant-turn triggers, compaction/artifact invalidation Review goal: avoid wasteful reinjection while preserving strong guidance
Tasks:
- Implement canonical marker scanning over
event.messages - Add fallback inspection of final provider payload when needed
- Implement relevant-turn reinjection triggers for
strongmode - Reinject after compaction and after root-pair artifact changes
- Add/update integration tests for dedupe, reinjection suppression, and reinjection after invalidation
- Include synthetic event-sequence coverage for edit-intent, architecture-sensitive reasoning, compaction, and artifact-change heuristics
Slice 4: Mode semantics, visibility, and strict-path behavior
Scope: off/advisory/strong/strict semantics, mixed visibility, strict bypass behavior Review goal: make the mode ladder operational and reviewable
Tasks:
- Implement mode-specific behavior for
off,advisory,strong, andstrict - Define and enforce the spec meaning of a missing
protocol pathduring sensitive actions - Keep startup hints user-visible and artifact injection agent-visible by default
- Implement strict-mode explicit bypass-justification behavior for sensitive edits/architectural claims
- Add/update integration tests for visibility, protocol-path detection, and mode differences
- Verify that
strongremains the default behavior
Slice 5: Documentation and runtime alignment
Scope: docs, runtime guidance text, implementation notes Review goal: align user-facing/runtime-facing guidance with the frozen spec
Tasks:
- Update runtime guidance strings to reflect init-hint behavior, root-pair preload, trust boundary, and mode ladder
- Update docs/skill guidance for the prompt-injection policy
- Keep retrieval guidance separate from these docs or clearly reference it as separate
- Document the opinionated default budget and configurability
- Summarize integration-test expectations and known risks
Acceptance checklist
- Before init, only a lightweight
project_map_inithint is injected - No synthetic map/index artifact content is injected before init
- After init, root
.pi-map.index.mdand root.pi-map.mdare always guaranteed before budgeted expansion - Expansion uses a hybrid cap with both relative and absolute knobs, smaller effective budget wins
- Default budget is 15% of active context window, capped at 100k tokens
- Reinjection avoidance is based on canonical marker scanning in actual outgoing context
strongchecks only relevant turns, not every trivial turn- Modes
off,advisory,strong, andstrictare implemented with the agreed semantics - Mixed visibility behavior is preserved
- Retrieval behavior remains separate from this spec’s implementation scope
- Extensive integration tests validate context scanning and reinjection behavior
npm run typecheckpassesnpm testpassesnpm run lintpasses (N/A: repo has no ESLint config; pre-existing repository gap, not a change regression)
Review workload note
This change mixes runtime hook behavior, prompt budgeting, context dedupe, visibility policy, and strict-mode enforcement. Keep delivery narrow and test-heavy. Avoid collapsing this into one oversized implementation slice.