Skip to content

Recover task file-context metadata backups before returning an empty context #2177

Open

Description

@edelauna

The JSON persistence caller audit identified a metadata read-recovery gap.

Source: src/core/context-tracking/FileContextTracker.ts.

saveTaskMetadata uses safeWriteJson. getTaskMetadata checks the canonical file and returns an empty files_in_context list if that file is absent. It does not recover an orphaned committed backup. A later save can replace recovered metadata with an empty or incomplete snapshot.

Proposed scope:

  • Use the shared read-recovery protocol before selecting the empty default.
  • Preserve the legitimate missing-metadata behavior.
  • Do not treat failed backup recovery as evidence that no metadata exists.
  • Keep failures observable without discarding committed metadata.

Acceptance:

  • A metadata read restores the committed file-context list from an orphaned backup.
  • A genuinely absent file returns the existing empty default.
  • A failed restore preserves the backup.
  • Unavailable reads cannot cause a later save to discard committed entries silently.

Evidence: source inspection. Add focused FileContextTracker tests.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions