@@ -26,8 +26,6 @@ test("a persona target with a live sibling resolves to the live instance", () =>
2626 directManagedAgent : undefined ,
2727 isArchived : ( pubkey ) => pubkey === ARCHIVED_PK ,
2828 personaInstances : [ archived , live ] ,
29- preferDirectManagedAgent : false ,
30- preserveRequestedInstance : false ,
3129 pubkey : undefined ,
3230 } ) ;
3331
@@ -42,8 +40,6 @@ test("a persona target with all instances archived resolves to undefined", () =>
4240 directManagedAgent : undefined ,
4341 isArchived : ( ) => true ,
4442 personaInstances : [ first , second ] ,
45- preferDirectManagedAgent : false ,
46- preserveRequestedInstance : false ,
4743 pubkey : undefined ,
4844 } ) ;
4945
@@ -58,8 +54,6 @@ test("an explicit archived pubkey stays exact even when a live sibling exists",
5854 directManagedAgent : archivedDirect ,
5955 isArchived : ( pubkey ) => pubkey === ARCHIVED_PK ,
6056 personaInstances : [ archivedDirect , live ] ,
61- preferDirectManagedAgent : false ,
62- preserveRequestedInstance : false ,
6357 pubkey : ARCHIVED_PK ,
6458 } ) ;
6559
@@ -75,48 +69,42 @@ test("an explicit archived pubkey with no managed record resolves to undefined s
7569 directManagedAgent : undefined ,
7670 isArchived : ( pubkey ) => pubkey === HISTORICAL_PK ,
7771 personaInstances : [ ] ,
78- preferDirectManagedAgent : false ,
79- preserveRequestedInstance : false ,
8072 pubkey : HISTORICAL_PK ,
8173 } ) ;
8274
8375 assert . equal ( resolved , undefined ) ;
8476} ) ;
8577
86- test ( "a preserved requested instance pins the exact record over canonicalization" , ( ) => {
78+ test ( "an explicit stopped instance pins the exact record over canonicalization" , ( ) => {
8779 const requested = agent ( { pubkey : HISTORICAL_PK , status : "stopped" } ) ;
8880 const live = agent ( { pubkey : LIVE_PK , status : "running" } ) ;
8981
9082 const resolved = resolveCanonicalManagedAgent ( {
9183 directManagedAgent : requested ,
9284 isArchived : NONE_ARCHIVED ,
9385 personaInstances : [ requested , live ] ,
94- preferDirectManagedAgent : false ,
95- preserveRequestedInstance : true ,
9686 pubkey : HISTORICAL_PK ,
9787 } ) ;
9888
9989 assert . equal ( resolved , requested ) ;
10090} ) ;
10191
102- test ( "a non-archived historical pubkey canonicalizes to the live persona instance " , ( ) => {
103- // Rule 5: #5788 canonicalization is retained for non-archived navigation .
92+ test ( "a non-archived historical pubkey stays exact, like archived and active keys " , ( ) => {
93+ // History is authored by a key, not its current persona representative .
10494 const requested = agent ( { pubkey : HISTORICAL_PK , status : "stopped" } ) ;
10595 const live = agent ( { pubkey : LIVE_PK , status : "running" } ) ;
10696
10797 const resolved = resolveCanonicalManagedAgent ( {
10898 directManagedAgent : requested ,
10999 isArchived : NONE_ARCHIVED ,
110100 personaInstances : [ requested , live ] ,
111- preferDirectManagedAgent : false ,
112- preserveRequestedInstance : false ,
113101 pubkey : HISTORICAL_PK ,
114102 } ) ;
115103
116- assert . equal ( resolved , live ) ;
104+ assert . equal ( resolved , requested ) ;
117105} ) ;
118106
119- test ( "preferDirectManagedAgent keeps a directly opened active instance exact" , ( ) => {
107+ test ( "explicit navigation keeps a directly opened active instance exact" , ( ) => {
120108 // The panel's own default: an access edit must target the clicked instance,
121109 // not an alphabetically-earlier active sibling.
122110 const sibling = agent ( { name : "Alpha" , pubkey : LIVE_PK , status : "running" } ) ;
@@ -130,28 +118,37 @@ test("preferDirectManagedAgent keeps a directly opened active instance exact", (
130118 directManagedAgent : clicked ,
131119 isArchived : NONE_ARCHIVED ,
132120 personaInstances : [ sibling , clicked ] ,
133- preferDirectManagedAgent : true ,
134- preserveRequestedInstance : false ,
135121 pubkey : HISTORICAL_PK ,
136122 } ) ;
137123
138124 assert . equal ( resolved , clicked ) ;
139125} ) ;
140126
141- test ( "an explicit archived pubkey stays exact even with preferDirectManagedAgent" , ( ) => {
142- // Rule 2 wins over the direct-preference redirect: a deliberately opened
143- // archived instance must not be redirected away from its unarchive control.
127+ test ( "an explicit archived pubkey stays exact with a running sibling" , ( ) => {
128+ // Archive state does not change what identity an explicit target names.
144129 const archivedDirect = agent ( { pubkey : ARCHIVED_PK , status : "stopped" } ) ;
145130 const live = agent ( { pubkey : LIVE_PK , status : "running" } ) ;
146131
147132 const resolved = resolveCanonicalManagedAgent ( {
148133 directManagedAgent : archivedDirect ,
149134 isArchived : ( pubkey ) => pubkey === ARCHIVED_PK ,
150135 personaInstances : [ archivedDirect , live ] ,
151- preferDirectManagedAgent : true ,
152- preserveRequestedInstance : false ,
153136 pubkey : ARCHIVED_PK ,
154137 } ) ;
155138
156139 assert . equal ( resolved , archivedDirect ) ;
157140} ) ;
141+
142+ for ( const instances of [ [ ] , [ agent ( { status : "running" } ) ] ] ) {
143+ test ( `relay-only A never resolves to local sibling B (${ instances . length } siblings)` , ( ) => {
144+ assert . equal (
145+ resolveCanonicalManagedAgent ( {
146+ directManagedAgent : undefined ,
147+ isArchived : NONE_ARCHIVED ,
148+ personaInstances : instances ,
149+ pubkey : HISTORICAL_PK ,
150+ } ) ,
151+ undefined ,
152+ ) ;
153+ } ) ;
154+ }
0 commit comments