Skip to content

Commit 9c20afc

Browse files
committed
fix: honest runtime-ref registry cells for label recovery
The disambiguation cell no longer claims refs identify exactly one node by construction — trailing-label recovery is a first-match lookup without the ranking, now an intentional waiver whose outcome the label-fallback disclosure surfaces per-response. resolutionDisclosure.via points at tryResolveRefNode (now exported), the resolver producing both exact and label-fallback, with direct unit coverage of both outcomes.
1 parent 1c280da commit 9c20afc

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎src/commands/interaction/runtime/resolution.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { test } from 'vitest';
33
import type { BackendSnapshotOptions } from '../../../backend.ts';
44
import { ref, selector } from '../../index.ts';
55
import { resolveActionableTouchResolution } from '../../../core/interaction-targeting.ts';
6+
import { tryResolveRefNode } from './resolution.ts';
67
import { makeSnapshotState } from '../../../__tests__/test-utils/index.ts';
78
import type { Point } from '../../../kernel/snapshot.ts';
89
import {
@@ -441,3 +442,21 @@ test('runtime ref interactions refresh the snapshot when a stored ref has no usa
441442
assert.equal(result.kind, 'ref');
442443
assert.equal(result.node?.rect?.width, 100);
443444
});
445+
446+
test('tryResolveRefNode discloses exact for a resolved ref and label-fallback for label recovery', () => {
447+
const nodes = selectorSnapshot().nodes;
448+
449+
const exact = tryResolveRefNode(nodes, '@e1', { fallbackLabel: '' });
450+
assert.equal(exact?.node.label, 'Continue');
451+
assert.deepEqual(exact?.resolution, { source: 'ref', phase: 'pre-action', kind: 'exact' });
452+
453+
const recovered = tryResolveRefNode(nodes, '@e9', { fallbackLabel: 'Continue' });
454+
assert.equal(recovered?.node.label, 'Continue');
455+
assert.deepEqual(recovered?.resolution, {
456+
source: 'ref',
457+
phase: 'pre-action',
458+
kind: 'label-fallback',
459+
});
460+
461+
assert.equal(tryResolveRefNode(nodes, '@e9', { fallbackLabel: '' }), null);
462+
});

‎src/commands/interaction/runtime/resolution.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ async function resolveSnapshotForRef(
490490
return { ...capture, resolved: refreshed };
491491
}
492492

493-
function tryResolveRefNode(
493+
/** The runtime-ref resolver: `exact` for a resolved `@ref`, `label-fallback` for trailing-label recovery. */
494+
export function tryResolveRefNode(
494495
nodes: SnapshotState['nodes'],
495496
refInput: string,
496497
options: {

‎src/contracts/interaction-guarantees.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,19 @@ export const INTERACTION_DISPATCH_PATHS: Record<InteractionPathId, InteractionPa
199199
guarantees: {
200200
...RUNTIME_TREE_SHARED_GUARANTEES,
201201
disambiguation: {
202-
kind: 'inapplicable',
203-
reason: 'Refs identify exactly one node by construction.',
202+
kind: 'waived',
203+
reason:
204+
'Intentional: a resolved @ref names exactly one node, but the replay trailing-label recovery resolves a stale @ref by FIRST label match without the visible/deepest/smallest ranking; that outcome is disclosed per-response as resolutionDisclosure label-fallback rather than silently claiming exactness.',
204205
},
205206
errorTaxonomy: {
206207
kind: 'runtime',
207208
via: 'src/daemon/selectors-resolve.ts#STALE_REF_HINT',
208209
},
209-
// ADR 0012 decision 2: a successful @ref lookup is exact. The replay
210-
// trailing-label recovery is explicitly disclosed as label-fallback,
211-
// rather than claiming exact ref provenance.
210+
// ADR 0012 decision 2: tryResolveRefNode produces both outcomes — exact
211+
// for a resolved @ref, label-fallback for trailing-label recovery.
212212
resolutionDisclosure: {
213213
kind: 'runtime',
214-
via: 'src/commands/interaction/runtime/resolution.ts#EXACT_REF_RESOLUTION',
214+
via: 'src/commands/interaction/runtime/resolution.ts#tryResolveRefNode',
215215
},
216216
},
217217
},

0 commit comments

Comments
 (0)