Skip to content

fix(refs): refuse reads of refs a partial frame did not issue - #4698

Merged
thymikee merged 1 commit into
callstack:mainfrom
xiatiandeairen:fix/find-read-keeps-refs
Nov 18, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
xiatiandeairen:fix/find-read-keeps-refs

Conversation

@xiatiandeairen

@xiatiandeairen xiatiandeairen commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A read-only find, a settled diff or a replay divergence that prints a ref activates a partial ref frame over its own capture. A plain @ref from the earlier snapshot -i was then resolved by number against that newer tree. So get text @eN could silently read a different element, the #1076 class of bug.

get and wait now refuse a ref outside the current partial frame's issuance set. They use the existing ref_not_issued reason, and the hint names the partial publication instead of a UI change, as ADR 0014 requires for reads without retained evidence. Refs the partial result printed still resolve. 8 files.

This fixes the wrong-node part of #4686. Keeping earlier refs resolvable after a read-only find needs an ADR 0014 decision, which is left to the maintainers on the issue. The options are to stop publishing the get text ref, or to retain the prior complete frame for reads.

Refs #4686

Validation

Head adf612a2b on base aa600e980.

  • check:quick passed. packages/daemon and src/commands vitest: 5,277 tests pass. The new partial-frame test fails on base, where the stale read succeeds on the wrong node, and passes on head.
  • check:affected --run --head adf612a2b: format, lint, typecheck, layering, fallow, build and vitest-related passed. unit failed only in android-sdk-setup-action.test.ts, which fails the same way on base on this host because of a local SDK path. docs-links and docs-prose passed when run directly.
  • iOS 27.2 simulator, after snapshot -i:
    • find 'label="Speakers (4)"' get text then get text @e51: base returns "Dictate" (wrong node), head returns ref_not_issued.
    • Text find then get text @e2: base returns "Speakers (4)", head returns ref_not_issued.
    • The printed @e1 still reads "Speakers (4)".
  • Android and web were not run live. Ref consumers outside get and wait, such as snapshot -s @ref, are not covered.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

A read-only find that prints a ref activates a partial frame over its own
capture. A plain @ref from the earlier snapshot was then resolved by
number against that newer tree, so get text could silently read another
element (callstack#1076). get and wait now refuse such a ref with the existing
ref_not_issued reason and a hint that names the partial publication,
as ADR 0014 requires for reads without retained evidence. Refs the
partial result printed still resolve.

Refs callstack#4686
@thymikee

Copy link
Copy Markdown
Member

The PR is ready at adf612a: reads of refs that a partial frame did not issue are now refused before any backend call, and I found nothing that needs fixing first. CI is green with no failing checks,, and there are no conflicts. The iOS results come from the PR body. snapshot -s @ref scope admission and replay/batch handling of a refused get @ref were not traced. Nothing else needs to happen before merge.

Not blocking, and fine to take or leave: the read path rebuilds the ref_not_issued error that assertRefMutationAdmitted already builds (https://github.com/callstack/agent-device/blob/adf612a/packages/daemon/src/execution/session-snapshot.ts#L258), so one shared builder plus one shared scope predicate in ref-frame.ts would keep the next typed reason in one place, and get could do a single session lookup; wait @ref has no production-route test (https://github.com/callstack/agent-device/blob/adf612a/packages/daemon/src/execution/wait-runtime.ts#L148), and the two parametrized cases in the partial-frame read test run the same fixture because the fake find ignores the query; the help text or find/diff print refs (https://github.com/callstack/agent-device/blob/adf612a/src/commands/schema/cli-help.ts#L96) reads as if a plain diff ends earlier refs, which it does not, so naming the effect (a command that prints new refs, such as find, settled diff, audit or ambiguity candidates) would be clearer; and admitRefRead ignores the pin generation, so a stale @e4~s3 whose body is in the current partial set is still admitted, which matches existing behavior and needs no change here.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@thymikee
thymikee merged commit 894c80a into callstack:main Nov 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants