Skip to content

Bug: history-shadow.ts has read-modify-write race condition (data loss) #479

Closed

Description

@diberry

@bradygaster — Found during SquadState PRD research.

Bug

\\history-shadow.ts\\ uses a read-modify-write pattern (\
eadFile → regex insert → writeFile\) with no locking. Two concurrent agents appending to the same \\history.md\\ will cause last-write-wins data loss.

How to reproduce

  1. Two agents write to the same agent's history.md simultaneously
  2. Agent A reads history.md (version 1)
  3. Agent B reads history.md (version 1)
  4. Agent A writes history.md (version 2 — includes A's changes)
  5. Agent B writes history.md (version 2 — includes B's changes but NOT A's)
  6. Agent A's changes are silently lost

Impact

This is a data loss bug in production today, not a theoretical concern. It affects any scenario where multiple agents or Scribe update the same history file concurrently.

Found by

Kaylee's edge case analysis during SquadState PRD research (19 edge cases audited, this was #1 highest risk).

Recommended fix

The planned SquadState abstraction will fix this by making write atomicity a contract requirement. Short-term mitigation: use the inbox/drop-box pattern for history writes (same as decisions), or add file locking.

cc @diberry

Activity

  1. added a commit that references this issue on Mar 20, 2026
    266efa4
  2. bradygaster commented on Mar 22, 2026

    @bradygaster
    Collaborator

    ⚠️ Flight triage: Data loss in history-shadow.ts read-modify-write pattern is production-critical. Routing: EECOM (core runtime) + RETRO (concurrency safety). Mitigation path: StorageProvider abstraction (#481) enforces atomic writes.

  3. github-actions commented on Mar 22, 2026

    @github-actions
    Contributor

    📋 Assigned to EECOM (Core Dev)

    Issue: #479 — Bug: history-shadow.ts has read-modify-write race condition (data loss)

    EECOM will pick this up in the next Copilot session.

    For Copilot coding agent: If enabled, this issue will be worked automatically.
    Otherwise, start a Copilot session and say:
    EECOM, work on issue #479

  4. github-actions commented on Mar 22, 2026

    @github-actions
    Contributor

    🏗️ Squad Triage — Flight (Lead)

    Issue: #479 — Bug: history-shadow.ts has read-modify-write race condition (data loss)
    Assigned to: FIDO (Quality Owner)
    Reason: Issue relates to testing/quality work

    @copilot evaluation: 🔴 Not suitable — issue involves work outside the coding agent's capability profile.

    Team roster:

    • Flight (Lead) → label: squad:flight
    • Procedures (Prompt Engineer) → label: squad:procedures
    • EECOM (Core Dev) → label: squad:eecom
    • FIDO (Quality Owner) → label: squad:fido
    • PAO (DevRel) → label: squad:pao
    • CAPCOM (SDK Expert) → label: squad:capcom
    • CONTROL (TypeScript Engineer) → label: squad:control
    • Surgeon (Release Manager) → label: squad:surgeon
    • Booster (CI/CD Engineer) → label: squad:booster
    • GNC (Node.js Runtime) → label: squad:gnc
    • Network (Distribution) → label: squad:network
    • RETRO (Security) → label: squad:retro
    • INCO (CLI UX & Visual Design) → label: squad:inco
    • GUIDO (VS Code Extension) → label: squad:guido
    • Telemetry (Aspire & Observability) → label: squad:telemetry
    • VOX (REPL & Interactive Shell) → label: squad:vox
    • DSKY (TUI Engineer) → label: squad:dsky
    • Sims (E2E Test Engineer) → label: squad:sims
    • Handbook (SDK Usability) → label: squad:handbook
    • Ralph (Work Monitor) → label: squad:ralph
    • @copilot (Coding Agent) → label: squad:copilot

    To reassign, remove the current squad:* label and add the correct one.

  5. github-actions commented on Mar 22, 2026

    @github-actions
    Contributor

    📋 Assigned to RETRO (Security)

    Issue: #479 — Bug: history-shadow.ts has read-modify-write race condition (data loss)

    RETRO will pick this up in the next Copilot session.

    For Copilot coding agent: If enabled, this issue will be worked automatically.
    Otherwise, start a Copilot session and say:
    RETRO, work on issue #479

  6. added a commit that references this issue on Mar 22, 2026
    ea7f4d9
  7. added 2 commits that reference this issue on Mar 22, 2026
    dfa513a
    7c00ab7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggo:needs-researchNeeds investigationnext-upPriority queue — next issues to worksquadSquad triage inbox — Lead will assign to a member

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions