From 035c7a20d382fbe3535b10d68bdaa8b533f8eab1 Mon Sep 17 00:00:00 2001 From: tegwick Date: Sun, 7 Jun 2026 15:27:22 +0200 Subject: [PATCH] session-memory: Read-before-Edit reflex + curated pattern (WP-0008) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acts on the #1 friction finding. T01: added a data-cited Read-before-Edit / re-read-on-stale reflex to AGENTS.md (top error: 'File has not been read yet', 12/27 sessions). T02: captured it as a curated SolutionPattern (sp-problem-file_not_read-edit, approved/distribution_ready) with real resolutions + per-flavor hints, so Distribute proposes it across repos/flavors — closing assess->curate->distribute on a real pattern. Suite 126/126. Co-Authored-By: Claude Opus 4.8 --- AGENTS.md | 12 ++++ .../sp-problem-file_not_read-edit.json | 58 +++++++++++++++++++ .../distribute/active_patterns.json | 10 +++- ...AGENTIC-WP-0008-read-before-edit-reflex.md | 6 +- 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 session_memory/catalog/sp-problem-file_not_read-edit.json diff --git a/AGENTS.md b/AGENTS.md index 3e08005..374f93a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -34,6 +34,18 @@ green), and for pipeline changes do a live `ingest → detect → curate` pass a the local store. See `session_memory/README.md` for the full layout and the detect → curate → distribute flow. +### Editing files — Read before you Edit + +**Read a file (or the region you'll touch) before Edit/Write.** The most common +error across our own captured coding sessions was *"File has not been read yet. +Read it first before writing to it"* — 12 of 27 real sessions, 8 repos +(`docs/ASSESSMENT-infra-friction.md`). Two cheap reflexes eliminate it: + +- **Read → then Edit/Write.** Don't blind-write a file you haven't read this + session; the edit tools reject it and the retry wastes a turn. +- **On `File has been modified since read`, re-Read then re-Edit.** A stale read + means the file changed under you — refresh before retrying, don't loop. + --- ## State Hub Integration diff --git a/session_memory/catalog/sp-problem-file_not_read-edit.json b/session_memory/catalog/sp-problem-file_not_read-edit.json new file mode 100644 index 0000000..de05108 --- /dev/null +++ b/session_memory/catalog/sp-problem-file_not_read-edit.json @@ -0,0 +1,58 @@ +{ + "created_at": "2026-06-07T13:26:25Z", + "distribution_ready": true, + "id": "sp-problem-file_not_read-edit", + "name": "Read before you Edit", + "polarity": "problem", + "problem": "Agents call Edit/Write on a file they have not read in the current session, or after it changed under them. The edit tools reject this ('File has not been read yet' / 'File has been modified since read'), and the retry burns a turn. Top recurring error in the corpus (12/27 sessions, 8 repos).", + "provenance": { + "detected_at": null, + "evidence": { + "frequency": 32, + "origin": "AGENTIC-WP-0006 error mining / ASSESSMENT-infra-friction.md", + "polarity": "problem", + "repos": 8, + "sessions": 12 + }, + "promoted_at": null, + "source_key": "problem:file_not_read:edit" + }, + "rendering_hints": { + "claude": { + "target": "CLAUDE.md" + }, + "codex": { + "target": "AGENTS.md" + }, + "grok": { + "target": ".grok/instructions.md" + } + }, + "resolutions": [ + { + "detail": "Never blind-write a file you haven't read this session.", + "steps": [ + "Read the target file", + "Then Edit/Write" + ], + "summary": "Read the file (or the region you'll touch) before Edit/Write" + }, + { + "detail": "A stale read means the file changed under you; refresh, don't loop.", + "steps": [ + "Re-Read the file", + "Re-apply the Edit" + ], + "summary": "On 'modified since read', re-Read then re-Edit" + } + ], + "schema_version": 1, + "scope": { + "domains": [], + "flavors": [], + "repos": [] + }, + "status": "approved", + "updated_at": "2026-06-07T13:26:25Z", + "version": "1.0.0" +} diff --git a/session_memory/distribute/active_patterns.json b/session_memory/distribute/active_patterns.json index 3f127a1..97cf235 100644 --- a/session_memory/distribute/active_patterns.json +++ b/session_memory/distribute/active_patterns.json @@ -1,4 +1,12 @@ [ + { + "flavor": "claude", + "pattern_id": "sp-problem-file_not_read-edit", + "repo": "agentic-resources", + "status": "proposed", + "updated_at": "2026-06-07T13:26:26Z", + "version": "1.0.0" + }, { "flavor": "claude", "pattern_id": "sp-problem-schema_thrash-schema_load", @@ -20,7 +28,7 @@ "pattern_id": "sp-success-clean_pass-outcome", "repo": "agentic-resources", "status": "proposed", - "updated_at": "2026-06-07T13:20:58Z", + "updated_at": "2026-06-07T13:26:26Z", "version": "1.0.0" }, { diff --git a/workplans/AGENTIC-WP-0008-read-before-edit-reflex.md b/workplans/AGENTIC-WP-0008-read-before-edit-reflex.md index fcc5ea9..8cda2af 100644 --- a/workplans/AGENTIC-WP-0008-read-before-edit-reflex.md +++ b/workplans/AGENTIC-WP-0008-read-before-edit-reflex.md @@ -4,7 +4,7 @@ type: workplan title: "Act on #1 friction — Read-before-Edit reflex" domain: helix_forge repo: agentic-resources -status: ready +status: finished owner: codex topic_slug: helix-forge created: "2026-06-07" @@ -30,7 +30,7 @@ closing the assess → curate → distribute loop by hand for one real pattern. ```task id: AGENTIC-WP-0008-T01 -status: todo +status: done priority: high state_hub_task_id: "549c84c1-5bd8-4ff6-b61d-1c72946b8b8e" ``` @@ -44,7 +44,7 @@ context budgets). ```task id: AGENTIC-WP-0008-T02 -status: todo +status: done priority: medium state_hub_task_id: "c007baf9-db14-40fa-b944-d1f1a71ea28b" ```