Skip to content

Commit 60ca30f

Browse files
committed
failure analysis.
Signed-off-by: Jose Alekhinne <jose@ctx.ist>
1 parent e8d5c60 commit 60ca30f

4 files changed

Lines changed: 448 additions & 4 deletions

File tree

.context/LEARNINGS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ DO NOT UPDATE FOR:
1717
<!-- INDEX:START -->
1818
| Date | Learning |
1919
|----|--------|
20+
| 2026-04-08 | fmt.Fprintf to strings.Builder silently discards errors |
21+
| 2026-04-08 | AST audit tests must cover unexported functions too |
2022
| 2026-04-06 | Agents ignore system-reminder content without explicit relay instructions |
2123
| 2026-04-04 | Format-verb strings are localizable text, not exempt from magic string checks |
2224
| 2026-04-04 | Agents add allowlist entries to make tests pass — guard every exemption |
@@ -109,6 +111,26 @@ DO NOT UPDATE FOR:
109111

110112
---
111113

114+
## [2026-04-08-074612] fmt.Fprintf to strings.Builder silently discards errors
115+
116+
**Context**: golangci-lint errcheck allows fmt.Fprintf to strings.Builder because Write never fails, but project convention says zero silent discard
117+
118+
**Lesson**: Linter coverage gaps exist where language guarantees mask conventions. AST tests fill the gap
119+
120+
**Application**: Created TestNoUncheckedFmtWrite to enforce fmt.Fprintf error handling. Use if _, err := fmt.Fprintf(...) with log.Warn on the error path
121+
122+
---
123+
124+
## [2026-04-08-074604] AST audit tests must cover unexported functions too
125+
126+
**Context**: TestDocCommentStructure only checked exported functions, so agent-written helpers in format.go had no godoc enforcement
127+
128+
**Lesson**: Convention enforcement tests must default to scanning all documented functions. Use explicit opt-outs (test files) not opt-ins (exported only)
129+
130+
**Application**: When adding AST audit tests, scan all functions. We fixed TestDocCommentStructure to drop the IsExported gate and fixed 84 violations
131+
132+
---
133+
112134
## [2026-04-06-204226] Agents ignore system-reminder content without explicit relay instructions
113135

114136
**Context**: Provenance line (Session: abc | Branch: main @ hash) was emitted by

.context/TASKS.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ TASK STATUS LABELS:
4242

4343
### Phase -2: Task completion nudge:
4444

45+
- [ ] Move 6 grandfathered cross-package MCP types to entity/ #session:cc97cb0d #branch:main #commit:e8d5c60a #added:2026-04-08-074620
46+
4547
- [ ] Design UserPromptSubmit hook that runs `make audit` at
4648
session start and surfaces failures as a consolidation-debt
4749
warning before the agent acts on stale assumptions.
@@ -91,18 +93,18 @@ TASK STATUS LABELS:
9193
non-atomic ownership, inverted logic, force-delete orphans,
9294
global state mutation.
9395

94-
- [ ] Design SKILL.md for ctx-architecture-failure-analysis:
96+
- [x] Design SKILL.md for ctx-architecture-failure-analysis:
9597
inputs (architecture artifacts), analysis phases, output
9698
format (DANGER-ZONES.md), quality checklist
9799
#added:2026-03-25-060000
98-
- [ ] Define the adversarial analysis framework: categories
100+
- [x] Define the adversarial analysis framework: categories
99101
of silent failure (concurrency, ordering, cache,
100102
amplification, ownership, error swallowing, global state)
101103
with heuristics for each #added:2026-03-25-060000
102-
- [ ] Implement skill with GitNexus integration: use impact
104+
- [x] Implement skill with GitNexus integration: use impact
103105
analysis for blast radius estimation, use context for
104106
shared-state detection #added:2026-03-25-060000
105-
- [ ] Add Gemini Search integration: cross-reference
107+
- [x] Add Gemini Search integration: cross-reference
106108
discovered patterns against known failure modes in similar
107109
systems. #added:2026-03-25-060000
108110

docs/reference/skills.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ opinionated behavior on top.
7070
| [`/ctx-loop`](#ctx-loop) | Generate autonomous loop script | user-invocable |
7171
| [`/ctx-worktree`](#ctx-worktree) | Manage git worktrees for parallel agents | user-invocable |
7272
| [`/ctx-architecture`](#ctx-architecture) | Build and maintain architecture maps | user-invocable |
73+
| [`/ctx-architecture-failure-analysis`](#ctx-architecture-failure-analysis) | Adversarial failure analysis for correctness bugs | user-invocable |
7374
| [`/ctx-remind`](#ctx-remind) | Manage session-scoped reminders | user-invocable |
7475
| [`/ctx-doctor`](#ctx-doctor) | Troubleshoot ctx behavior with health checks and event analysis | user-invocable |
7576
| [`/ctx-skill-audit`](#ctx-skill-audit) | Audit skills against Anthropic prompting best practices | user-invocable |
@@ -560,6 +561,39 @@ rather than re-analyzing everything.
560561

561562
---
562563

564+
### `/ctx-architecture-failure-analysis`
565+
566+
Adversarial failure analysis that generates falsifiable incident
567+
hypotheses against architecture artifacts. Hunts for correctness
568+
bugs that survive code review and tests: race conditions, ordering
569+
assumptions, cache staleness, error swallowing, ownership gaps,
570+
idempotency failures, state machine drift, and scaling cliffs.
571+
572+
Requires `/ctx-architecture` artifacts as input. Reads
573+
`ARCHITECTURE.md`, `DETAILED_DESIGN*.md`, and `map-tracking.json`,
574+
then systematically applies 9 failure categories to every mutation
575+
point. Each finding carries an evidence standard (code path,
576+
trigger, failure path, silence reason, code evidence), a confidence
577+
level, and an explicit risk score. A mandatory challenge phase
578+
attempts to disprove each finding before it is accepted.
579+
580+
Produces `.context/DANGER-ZONES.md` with ranked findings split
581+
into Critical (risk >= 7, silent/cascading) and Elevated tiers.
582+
583+
**Wraps**: reads architecture artifacts, source code; writes
584+
`DANGER-ZONES.md`. Optionally uses GitNexus for blast radius
585+
and Gemini Search for cross-referencing known failure patterns.
586+
587+
**Relationship**:
588+
589+
| Skill | Mode |
590+
|-------|------|
591+
| `/ctx-architecture` | Map what exists |
592+
| `/ctx-architecture-enrich` | Improve map fidelity |
593+
| `/ctx-architecture-failure-analysis` | Generate falsifiable incident hypotheses |
594+
595+
---
596+
563597
### `/ctx-remind`
564598

565599
Manage session-scoped reminders via natural language. Translates user

0 commit comments

Comments
 (0)