@@ -2,7 +2,6 @@ import { test } from 'vitest';
22import assert from 'node:assert/strict' ;
33import { AppError } from '../../kernel/errors.ts' ;
44import {
5- classifyTargetBindingMatch ,
65 formatTargetAnnotationCommentLine ,
76 matchesAncestryPrefix ,
87 matchesLocalIdentity ,
@@ -365,143 +364,3 @@ test('parser accepts an explicit empty-string role (writer-legal for typeless no
365364 assert . equal ( parsed . role , '' ) ;
366365 assert . deepEqual ( parsed . ancestry , [ { role : '' } ] ) ;
367366} ) ;
368-
369- // ---------------------------------------------------------------------------
370- // Classification core (decision 3 "Replay-time verification" paths 2-6):
371- // this is the exact function the writer's record-time self-check calls, and
372- // what a future replay-enforcement step will reuse — so duplicate/unverifiable
373- // evidence is exercised directly and generically here.
374- // ---------------------------------------------------------------------------
375-
376- test ( 'classifyTargetBindingMatch path 2: matchCount 0 is unverifiable (selector-miss)' , ( ) => {
377- const result = classifyTargetBindingMatch ( {
378- winnerRef : 'e1' ,
379- matchedRefs : [ ] ,
380- identitySetRefs : [ ] ,
381- siblingMatchRefs : [ ] ,
382- regionMemberRefs : undefined ,
383- viewportCandidateRef : undefined ,
384- } ) ;
385- assert . deepEqual ( result , { path : 2 , outcome : 'unverifiable' , reason : 'selector-miss' } ) ;
386- } ) ;
387-
388- test ( 'classifyTargetBindingMatch path 3: empty identity set is unverifiable' , ( ) => {
389- const result = classifyTargetBindingMatch ( {
390- winnerRef : 'e1' ,
391- matchedRefs : [ 'e1' ] ,
392- identitySetRefs : [ ] ,
393- siblingMatchRefs : [ ] ,
394- regionMemberRefs : undefined ,
395- viewportCandidateRef : undefined ,
396- } ) ;
397- assert . deepEqual ( result , { path : 3 , outcome : 'unverifiable' , reason : 'identity-set-empty' } ) ;
398- } ) ;
399-
400- test ( 'classifyTargetBindingMatch path 4: unique identity-set member equal to winner is verified' , ( ) => {
401- const result = classifyTargetBindingMatch ( {
402- winnerRef : 'e1' ,
403- matchedRefs : [ 'e1' ] ,
404- identitySetRefs : [ 'e1' ] ,
405- siblingMatchRefs : [ 'e1' ] ,
406- regionMemberRefs : undefined ,
407- viewportCandidateRef : undefined ,
408- } ) ;
409- assert . deepEqual ( result , { path : 4 , outcome : 'verified' } ) ;
410- } ) ;
411-
412- test ( 'classifyTargetBindingMatch path 5: unique identity-set member that is NOT the winner (unique-but-wrong rebind)' , ( ) => {
413- const result = classifyTargetBindingMatch ( {
414- winnerRef : 'e1' ,
415- matchedRefs : [ 'e1' ] ,
416- identitySetRefs : [ 'e9' ] ,
417- siblingMatchRefs : [ ] ,
418- regionMemberRefs : undefined ,
419- viewportCandidateRef : undefined ,
420- } ) ;
421- assert . deepEqual ( result , { path : 5 , outcome : 'unverifiable' , reason : 'unique-but-wrong' } ) ;
422- } ) ;
423-
424- test ( 'classifyTargetBindingMatch path 6: duplicate identity resolved by a unique sibling match' , ( ) => {
425- const verified = classifyTargetBindingMatch ( {
426- winnerRef : 'e1' ,
427- matchedRefs : [ 'e1' , 'e2' ] ,
428- identitySetRefs : [ 'e1' , 'e2' ] ,
429- siblingMatchRefs : [ 'e1' ] ,
430- regionMemberRefs : undefined ,
431- viewportCandidateRef : undefined ,
432- } ) ;
433- assert . deepEqual ( verified , { path : 6 , outcome : 'verified' } ) ;
434- } ) ;
435-
436- test ( 'classifyTargetBindingMatch path 6: same child index recurring under different parents falls through sibling, resolved by region-scoped viewportOrder' , ( ) => {
437- const result = classifyTargetBindingMatch ( {
438- winnerRef : 'e1' ,
439- matchedRefs : [ 'e1' , 'e2' ] ,
440- identitySetRefs : [ 'e1' , 'e2' ] ,
441- // Both members are "child 0" under different parents — sibling alone
442- // does not isolate.
443- siblingMatchRefs : [ 'e1' , 'e2' ] ,
444- regionMemberRefs : [ 'e2' , 'e1' ] ,
445- viewportCandidateRef : 'e1' ,
446- } ) ;
447- assert . deepEqual ( result , { path : 6 , outcome : 'verified' } ) ;
448- } ) ;
449-
450- test ( 'classifyTargetBindingMatch path 6: a scroll region that no longer exists falls through to unverifiable, never a silent pick' , ( ) => {
451- const result = classifyTargetBindingMatch ( {
452- winnerRef : 'e1' ,
453- matchedRefs : [ 'e1' , 'e2' ] ,
454- identitySetRefs : [ 'e1' , 'e2' ] ,
455- siblingMatchRefs : [ 'e1' , 'e2' ] ,
456- regionMemberRefs : undefined , // region unavailable
457- viewportCandidateRef : undefined ,
458- } ) ;
459- assert . deepEqual ( result , { path : 6 , outcome : 'unverifiable' , reason : 'no-signal-isolation' } ) ;
460- } ) ;
461-
462- test ( 'classifyTargetBindingMatch path 6: an out-of-range recorded viewportOrder falls through to unverifiable' , ( ) => {
463- const result = classifyTargetBindingMatch ( {
464- winnerRef : 'e1' ,
465- matchedRefs : [ 'e1' , 'e2' ] ,
466- identitySetRefs : [ 'e1' , 'e2' ] ,
467- siblingMatchRefs : [ 'e1' , 'e2' ] ,
468- regionMemberRefs : [ 'e1' , 'e2' ] ,
469- viewportCandidateRef : undefined , // ordinal was out of range
470- } ) ;
471- assert . deepEqual ( result , { path : 6 , outcome : 'unverifiable' , reason : 'no-signal-isolation' } ) ;
472- } ) ;
473-
474- test ( 'classifyTargetBindingMatch path 6: a signal isolating a DIFFERENT node than the winner is the paths-4/5 comparison class, not fall-through' , ( ) => {
475- // Decision 3 path 6.i/6.ii: when a signal denotes exactly one member,
476- // "compare with W as in paths 4/5" — an isolated-but-different member is
477- // the same class as path 5's unique-but-wrong rebind (a future
478- // identity-mismatch), distinct from true no-isolation fall-through (a
479- // future identity-unverifiable with candidates).
480- const viaViewportOrder = classifyTargetBindingMatch ( {
481- winnerRef : 'e1' ,
482- matchedRefs : [ 'e1' , 'e2' ] ,
483- identitySetRefs : [ 'e1' , 'e2' ] ,
484- siblingMatchRefs : [ 'e1' , 'e2' ] ,
485- regionMemberRefs : [ 'e1' , 'e2' ] ,
486- viewportCandidateRef : 'e2' ,
487- } ) ;
488- assert . deepEqual ( viaViewportOrder , {
489- path : 6 ,
490- outcome : 'unverifiable' ,
491- reason : 'signal-isolated-wrong' ,
492- } ) ;
493-
494- const viaSibling = classifyTargetBindingMatch ( {
495- winnerRef : 'e1' ,
496- matchedRefs : [ 'e1' , 'e2' ] ,
497- identitySetRefs : [ 'e1' , 'e2' ] ,
498- siblingMatchRefs : [ 'e2' ] , // sibling isolates e2, not the winner
499- regionMemberRefs : [ 'e1' , 'e2' ] ,
500- viewportCandidateRef : 'e1' ,
501- } ) ;
502- assert . deepEqual ( viaSibling , {
503- path : 6 ,
504- outcome : 'unverifiable' ,
505- reason : 'signal-isolated-wrong' ,
506- } ) ;
507- } ) ;
0 commit comments