Skip to content

Commit 6811361

Browse files
committed
docs: add Stories 8.6-8.11 to PRD - agent-first gap analysis
6 new stories for Epic 8 AI Context Optimization: - 8.6: Session Handoff Protocol (rule change) - 8.7: Self-Assessed Token Counting (rule change) - 8.8: Entry Verbosity Control (template + rule) - 8.9: Cross-File Navigation Hints (rule convention) - 8.10: Stale Context Detection (rule clause) - 8.11: Archival Summary Index (rule + template) All implementable via rule/template changes only - zero new dependencies. Files: project/specs/prd.md, logs/CHANGELOG.md
1 parent ac958e2 commit 6811361

File tree

2 files changed

+148
-1
lines changed

2 files changed

+148
-1
lines changed

logs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121

2222
### Added
2323

24+
- Stories 8.6-8.11: Agent-first gap analysis - 6 new stories for Epic 8: Session Handoff Protocol, Self-Assessed Token Counting, Entry Verbosity Control, Cross-File Navigation Hints, Stale Context Detection, Archival Summary Index. All implementable via rule/template changes only - zero new dependencies. Files: `project/specs/prd.md`. Commit: `4c97104`
2425
- Epic 8: AI Context Optimization (NEW) - Replaced old Epic 8 with 5 mission-aligned stories: Smart Context Summarization (<500 tokens), Token Budget Dashboard, AI-Optimized Document Templates, Intelligent Archival Triggers, Context Relevance Scoring. All features directly help AI agents not get lost and not waste tokens. Files: `project/specs/prd.md`. Commit: `b9a9a38`
2526
- Project navigation guide for autonomous agents - Created `project/README.md` explaining directory structure, source of truth hierarchy, and what files to reference. Files: `project/README.md`. Commit: `9ebb777`
2627

project/specs/prd.md

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Not applicable - this is a static documentation/template repository with no runt
147147

148148
### Epic 8: AI Context Optimization 🧠 NEW - MISSION CRITICAL
149149
**Goal:** Build features that directly help AI agents not get lost and not waste tokens - smart summarization, token monitoring, AI-optimized formatting.
150-
**Status:** NEW - Refocused on core mission after code-police review identified 60% mission drift.
150+
**Status:** EXPANDED - Stories 8.1-8.5 (original), Stories 8.6-8.11 (agent-first gaps: handoff, token self-assessment, verbosity, navigation, staleness, archival index). All new stories are rule/template changes only - zero new dependencies.
151151

152152
### Epic 12: Security & Secrets Detection 🔒 P0
153153
**Goal:** Prevent AI agents from leaking secrets (passwords, API keys, PII) into logs. AI must learn what NOT to document.
@@ -1248,6 +1248,152 @@ The PRD and epics are comprehensive, properly structured, and ready for architec
12481248
- Consider auto-tagging based on file paths mentioned
12491249
- Keep tagging lightweight - don't add token overhead
12501250

1251+
### Story 8.6: Session Handoff Protocol
1252+
1253+
**As an** AI coding assistant ending a session,
1254+
**I want** a standard way to write a handoff note for the next session,
1255+
**so that** the next agent can pick up exactly where I left off without re-reading full logs.
1256+
1257+
#### Acceptance Criteria
1258+
1. Rule includes "🔚 SESSION END" section mirroring existing "🔄 SESSION START"
1259+
2. Agent writes handoff note before session ends containing: what was done, what's in progress, what's next
1260+
3. Handoff stored in `## Last Session` section of DEVLOG.md (above Daily Log)
1261+
4. Handoff format is compact: 3 bullet points max (Done, In Progress, Next)
1262+
5. Handoff overwrites previous handoff (only latest session matters)
1263+
6. SESSION START rule updated to read handoff first
1264+
7. Handoff includes branch name and last commit hash
1265+
8. Token budget: <150 tokens per handoff
1266+
9. No external tools required - agent writes directly to markdown
1267+
10. Validation warns if handoff section is missing or >150 tokens
1268+
1269+
#### Technical Notes
1270+
- Modify `product/ai-rules/augment/log-file-maintenance.md` and claude-code equivalent
1271+
- Add `## Last Session` section template to DEVLOG_template.md
1272+
- Implementation: rule change + template change only, no scripts
1273+
1274+
### Story 8.7: Self-Assessed Token Counting
1275+
1276+
**As an** AI coding assistant writing log entries,
1277+
**I want** a simple heuristic to estimate token usage without running scripts,
1278+
**so that** I can self-regulate entry length and stay within budget.
1279+
1280+
#### Acceptance Criteria
1281+
1. Rule includes token estimation heuristic: "~4 characters = 1 token"
1282+
2. Rule includes quick-reference table: 1 line ≈ 20 tokens, 1 paragraph ≈ 80 tokens
1283+
3. Agent estimates token count before writing entries
1284+
4. Agent checks estimated file size against budget thresholds from rule
1285+
5. If estimated over budget, agent triggers archival before adding new entry
1286+
6. No Python scripts or external tools required for estimation
1287+
7. Heuristic accurate within ±20% for English markdown text
1288+
8. Rule includes example: "This 80-char line ≈ 20 tokens"
1289+
9. Token budgets embedded in rule (CHANGELOG <10k, DEVLOG <15k, Combined <25k)
1290+
10. Validation scripts remain available for precise counting but are not required
1291+
1292+
#### Technical Notes
1293+
- Add "📊 TOKEN SELF-ASSESSMENT" section to log-file-maintenance rule
1294+
- Heuristic: `token_estimate = character_count / 4`
1295+
- Keep budgets in sync with profile definitions
1296+
- Implementation: rule change only
1297+
1298+
### Story 8.8: Entry Verbosity Control
1299+
1300+
**As an** AI coding assistant writing DEVLOG entries,
1301+
**I want** a compact entry format option,
1302+
**so that** routine entries don't consume 150-250 tokens when 50-80 would suffice.
1303+
1304+
#### Acceptance Criteria
1305+
1. Rule defines two DEVLOG entry formats: Standard (narrative) and Compact (3-line)
1306+
2. Compact format: `What → Why → Files` on 3 lines
1307+
3. Standard format reserved for: major decisions, incidents, milestones
1308+
4. Compact format used for: routine changes, minor fixes, session summaries
1309+
5. Compact entry target: 50-80 tokens (vs 150-250 for standard)
1310+
6. DEVLOG template updated with compact format example
1311+
7. Rule provides decision guide: "If it needs an ADR, use standard. Otherwise, compact."
1312+
8. Both formats maintain human readability
1313+
9. Token savings: 50-100 tokens per entry for routine work
1314+
10. Validation accepts both formats without warnings
1315+
1316+
#### Technical Notes
1317+
- Update `product/templates/DEVLOG_template.md` with compact format section
1318+
- Update log-file-maintenance rule with format selection guidance
1319+
- Compact format example:
1320+
```
1321+
### 2026-02-06: Fixed auth token refresh
1322+
Token refresh failed silently on expired sessions. Added retry logic with exponential backoff.
1323+
Files: `src/auth.js`, `src/retry.js`
1324+
```
1325+
- Implementation: template change + rule change
1326+
1327+
### Story 8.9: Cross-File Navigation Hints
1328+
1329+
**As an** AI coding assistant reading a CHANGELOG entry,
1330+
**I want** a pointer to the related DEVLOG entry that explains *why*,
1331+
**so that** I can navigate between files without guessing by date.
1332+
1333+
#### Acceptance Criteria
1334+
1. Rule convention: CHANGELOG entries with DEVLOG decisions include `→ DEVLOG {date}`
1335+
2. Rule convention: DEVLOG entries referencing specific changes include `→ CHANGELOG {version}`
1336+
3. Navigation hints added at end of entry line (inline, not separate line)
1337+
4. Token cost: ~8 tokens per hint
1338+
5. Hints are optional - only added when cross-reference exists
1339+
6. Hints use consistent format across all log files
1340+
7. Agent adds hints automatically when writing related entries
1341+
8. Validation warns on orphan decisions (DEVLOG decision with no CHANGELOG link)
1342+
9. Hints work in both rendered and raw markdown
1343+
10. No new files or tools required
1344+
1345+
#### Technical Notes
1346+
- Add "🔗 CROSS-REFERENCES" convention to log-file-maintenance rule
1347+
- Format: `→ DEVLOG 2026-02-06` or `→ CHANGELOG v0.3.0`
1348+
- Implementation: rule convention only
1349+
1350+
### Story 8.10: Stale Context Detection
1351+
1352+
**As an** AI coding assistant starting a session,
1353+
**I want** to know if the Current Context section is outdated,
1354+
**so that** I don't make decisions based on stale information.
1355+
1356+
#### Acceptance Criteria
1357+
1. Rule clause: "At session start, check `Last Updated` date in Current Context"
1358+
2. If Current Context is >7 days old, agent MUST update it before other work
1359+
3. Agent compares `Last Updated` to current date (no external tools needed)
1360+
4. Update includes: version, phase, objectives, recent changes since last update
1361+
5. Staleness check added to SESSION START section of rule
1362+
6. Agent reports staleness to user: "Current Context is X days old. Updating."
1363+
7. Updated context includes new `Last Updated` date
1364+
8. Token budget for context update: <800 tokens (existing budget)
1365+
9. No scripts or external dependencies required
1366+
10. Validation warns if `Last Updated` is >14 days old
1367+
1368+
#### Technical Notes
1369+
- Add staleness check to "🔄 SESSION START" section of log-file-maintenance rule
1370+
- Simple date comparison: agent reads date, compares to today
1371+
- Implementation: rule clause only
1372+
1373+
### Story 8.11: Archival Summary Index
1374+
1375+
**As an** AI coding assistant looking for an old decision or entry,
1376+
**I want** a summary of what each archive file contains,
1377+
**so that** I can find the right archive without reading all of them.
1378+
1379+
#### Acceptance Criteria
1380+
1. Rule: when archiving, agent adds summary line to Archive section
1381+
2. Summary format: `- [filename](path) - Brief description of contents`
1382+
3. Summary includes: key topics, decisions, epics covered in that archive
1383+
4. Summary target: ~10 tokens per archive file
1384+
5. Archive section in DEVLOG and CHANGELOG templates updated with example
1385+
6. Agent can scan summaries to find relevant archive without opening files
1386+
7. Summary written at time of archival (not retroactively)
1387+
8. Validation warns if archive files exist without summary entries
1388+
9. No new files or tools required
1389+
10. Summaries maintained in the active log file's Archive section
1390+
1391+
#### Technical Notes
1392+
- Update Archive section guidance in log-file-maintenance rule
1393+
- Update DEVLOG_template.md and CHANGELOG_template.md Archive sections
1394+
- Example: `- [DEVLOG-2026-01.md](archive/DEVLOG-2026-01.md) - Epic 7 reliability, JWT decision, rate limiting incident`
1395+
- Implementation: rule change + template change
1396+
12511397
---
12521398

12531399
## Rejected Ideas (Mission Drift)

0 commit comments

Comments
 (0)