Skip to content

approvals: same-day rows differing only by scope dedupe to one id, and sync lets an older local copy win #3502

Closed as not planned

Description

@capy-ai

Found by the pass-4 red team on #3496 (GSTA-114 lane F) at 4d49667; the code is unchanged main (lib/approval-record.ts buildRow, appendRows, readRecord, syncRecord), so it is deferred here per docs/review-policy.md rule 1.

Problem. buildRow hashes source/date/ask/words/by into the row id but not scope, outcome, pending or recorded_at. A second gstack-approvals add on the same day with the same ask, words and by but a different scope gets the same id, and appendRows skips it as already present:

gstack-approvals add ... --scope 'autoplan gates: take the recommendations'   -> added a-dd420528e2b1
gstack-approvals add ... --scope 'all reviews other than autoplan'            -> added:[] skipped:1

So an owner's same-day narrowing or withdrawal is never stored. Separately, readRecord and syncRecord collapse same-id copies with local winning over the mirror: with an older local row and a newer same-id mirror row, the lookup first sees the mirror row, then after syncRecord overwrites the mirror the local (older) row wins. Any consumer that treats the newest row as authoritative (the standing-answer path that was split out of #3496 would have been one) reads a stale decision.

Fix. Include scope, outcome and pending in the id hash (or key rows by id plus recorded_at) so a different scope is a new row, and make readRecord/syncRecord keep the newest recorded_at per id rather than letting local win. Tests: CLI-level add grant then add same-day scope refusal and assert both rows exist; a sync test with a newer mirror copy that survives syncRecord.

This belongs with the structured standing-grant PR that replaces --owner-standing rec (cut from #3496), since that is the first consumer whose correctness depends on it.

Activity

  1. added
    S3
    on Oct 31, 2026
  2. capy-ai commented on Nov 1, 2026

    @capy-ai
    ContributorAuthor

    Thanks for filing this. Closing as won't-fix for now. A real narrowing or withdrawal comes with new words from the owner, and the words are already in the id hash, so it gets its own row. The case left (same ask, same words, same person, same day, different scope) has no consumer that depends on it today, and changing the hash means migrating existing ids so re-imports don't duplicate rows. As the issue says, the structured standing-grant PR is the right place for this if it's ever built.

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

    S3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions