Skip to content

history-shadow.ts uses invalid \Z regex anchor, duplicating headers and collapsing separators #1500

Closed

Description

@tamirdresher

Summary

packages/squad-sdk/src/agents/history-shadow.ts builds section-boundary regular expressions with \Z at two call sites. JavaScript RegExp does not support \Z as an end-of-string anchor, so it is interpreted as a literal Z.

Impact

  • Appending to the terminal References section does not find the existing section and adds a second ## References header.
  • Appending to non-terminal sections finds the next header but collapses the blank-line separator before it.
  • The read/parse path contains the same invalid anchor and needs equivalent correction.

Evidence

  • packages/squad-sdk/src/agents/history-shadow.ts, write path near line 236
  • packages/squad-sdk/src/agents/history-shadow.ts, read/parse path near line 331
  • packages/squad-sdk/src/state/io/history-io.ts already documents and avoids this anchor through header-position splitting
  • Draft PR test(memory): characterization baselines for #1309 (research, not closing) #1499 characterizes the current behavior without changing production code

Suggested approach

Replace the invalid anchor with a JavaScript-correct end-of-string strategy, or reuse the header-position splitting approach already implemented in history-io.ts so both paths share one correct boundary implementation.

Acceptance criteria

  • Appending to terminal References inserts the entry under the existing header without duplicating it.
  • Appending to non-terminal sections preserves the blank line between sections.
  • The read/parse path handles terminal sections correctly.
  • Characterization tests in test(memory): characterization baselines for #1309 (research, not closing) #1499 are updated from current-bug expectations to corrected behavior when this fix lands.
  • Existing history-shadow and state I/O tests remain green.

Refs #1499 and #1309.

Activity

  1. added
    squadSquad triage inbox — Lead will assign to a member
    on Jul 18, 2026
  2. github-actions commented on Jul 18, 2026

    @github-actions
    Contributor

    📋 Assigned to Surgeon (Release Manager)

    Issue: #1500 — history-shadow.ts uses invalid \Z regex anchor, duplicating headers and collapsing separators

    Surgeon 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:
    Surgeon, work on issue #1500

  3. github-actions commented on Sep 10, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  4. github-actions commented on Sep 10, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  5. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  6. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  7. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  8. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  9. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: Procedures
    Reason: Matched module path "src/agents/" to primary owner "Procedures 🧠"
    Source: module-ownership

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  10. github-actions commented on Sep 13, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: architect
    Reason: No module, routing, or role keyword match — routed to Lead/Architect
    Source: lead-fallback

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  11. github-actions commented on Sep 24, 2026

    @github-actions
    Contributor

    📋 Assigned to sdk-runtime-dev (SDK Runtime Engineer)

    Issue: #1500 — history-shadow.ts uses invalid \Z regex anchor, duplicating headers and collapsing separators

    sdk-runtime-dev 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:
    sdk-runtime-dev, work on issue #1500

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

    priority:p2Next sprintsquadSquad triage inbox — Lead will assign to a membersquad:sdk-runtime-devAssigned to sdk-runtime-dev (SDK Runtime Engineer)type:bugSomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions