@@ -49,6 +49,12 @@ const {
4949 expireValidationForTests,
5050 cachePath,
5151} = await import ( "../../../src/altimate/workspace/state" )
52+ const { credentialDigest : manifestDigest } = await import ( "../../../src/altimate/workspace/state" )
53+ /** Accounts these fixtures belong to. A manifest with no account cannot be
54+ * attributed, so it is rejected rather than trusted — the same rule a real one
55+ * written by another user meets. */
56+ const ACME_ACCOUNT = manifestDigest ( "https://api.example.com" , "acme" , "key-a" )
57+ const OTHER_ACCOUNT = manifestDigest ( "https://api.example.com" , "other" , "key-b" )
5258const { resolveProjectIdentifier } = await import ( "../../../src/altimate/workspace/detect" )
5359const { resetPollMemoForTests, resetEnablementMemoForTests, pendingCount, memoryEnabledCache, memoryEnabledForPoller } =
5460 await import ( "../../../src/altimate/workspace/memory-sync" )
@@ -390,7 +396,7 @@ describe("what unlink leaves on disk", () => {
390396 writeFileSync ( path . join ( snapshot , "pub-x" , "SKILL.md" ) , "theirs now" )
391397 writeFileSync (
392398 path . join ( snapshot , ".manifest.json" ) ,
393- JSON . stringify ( { version : 1 , tenant : "acme" , apiUrl : "https://api.example.com" , datamateId : to , skills : { } } ) ,
399+ JSON . stringify ( { version : 2 , tenant : "acme" , apiUrl : "https://api.example.com" , account : ACME_ACCOUNT , datamateId : to , skills : { } } ) ,
394400 )
395401 return new Response ( null , { status : 204 } )
396402 }
@@ -555,7 +561,7 @@ describe("what unlink leaves on disk", () => {
555561 writeFileSync ( path . join ( snapshot , "pub-x" , "SKILL.md" ) , "theirs now" )
556562 writeFileSync (
557563 path . join ( snapshot , ".manifest.json" ) ,
558- JSON . stringify ( { version : 1 , tenant : "acme" , apiUrl : "https://api.example.com" , datamateId : 99 , skills : { } } ) ,
564+ JSON . stringify ( { version : 2 , tenant : "acme" , apiUrl : "https://api.example.com" , account : ACME_ACCOUNT , datamateId : 99 , skills : { } } ) ,
559565 )
560566 return new Response ( JSON . stringify ( { detail : "gone" } ) , {
561567 status : 404 ,
@@ -595,7 +601,7 @@ describe("what unlink leaves on disk", () => {
595601 writeFileSync ( path . join ( snapshot , "pub-x" , "SKILL.md" ) , "theirs now" )
596602 writeFileSync (
597603 path . join ( snapshot , ".manifest.json" ) ,
598- JSON . stringify ( { version : 1 , tenant : "other" , apiUrl : "https://api.example.com" , datamateId : 77 , skills : { } } ) ,
604+ JSON . stringify ( { version : 2 , tenant : "other" , apiUrl : "https://api.example.com" , account : OTHER_ACCOUNT , datamateId : 77 , skills : { } } ) ,
599605 )
600606 return new Response ( null , { status : 204 } )
601607 }
@@ -631,7 +637,7 @@ describe("what unlink leaves on disk", () => {
631637 writeFileSync ( path . join ( snapshot , "pub-x" , "SKILL.md" ) , "stale" )
632638 writeFileSync (
633639 path . join ( snapshot , ".manifest.json" ) ,
634- JSON . stringify ( { version : 1 , tenant : "other" , apiUrl : "https://api.example.com" , datamateId : 77 , skills : { } } ) ,
640+ JSON . stringify ( { version : 2 , tenant : "other" , apiUrl : "https://api.example.com" , account : OTHER_ACCOUNT , datamateId : 77 , skills : { } } ) ,
635641 )
636642
637643 const report = await unlink ( projectDir )
@@ -959,11 +965,37 @@ describe("what /workspace status may cost and claim (review round 2)", () => {
959965} )
960966
961967const manifestFor = ( datamateId : number ) =>
962- JSON . stringify ( { version : 1 , tenant : "acme" , apiUrl : "https://api.example.com" , datamateId, skills : { } } )
968+ JSON . stringify ( { version : 2 , tenant : "acme" , apiUrl : "https://api.example.com" , account : ACME_ACCOUNT , datamateId, skills : { } } )
963969const markerFor = ( datamateId : number , at : number ) =>
964- JSON . stringify ( { at, datamateId, tenant : "acme" , apiUrl : "https://api.example.com" } )
970+ JSON . stringify ( { at, datamateId, tenant : "acme" , apiUrl : "https://api.example.com" , account : ACME_ACCOUNT } )
965971
966972describe ( "the sidebar's skills-synced age" , ( ) => {
973+ test ( "a marker left by another account is not this one's sync" , async ( ) => {
974+ // Raised in review. The marker began carrying an account, but the age check
975+ // still compared only the workspace, tenant and host — so on a shared
976+ // tenant the second user was shown the first user's sync time for a
977+ // snapshot that is not theirs.
978+ await bind ( projectDir )
979+ const managed = path . join ( projectDir , ".altimate-code" , "skill" , "_workspace" )
980+ mkdirSync ( managed , { recursive : true } )
981+ writeFileSync ( path . join ( managed , ".manifest.json" ) , manifestFor ( 42 ) )
982+ writeFileSync (
983+ path . join ( managed , ".synced-at" ) ,
984+ JSON . stringify ( {
985+ at : Date . now ( ) - 5 * 60_000 ,
986+ datamateId : 42 ,
987+ tenant : "acme" ,
988+ apiUrl : "https://api.example.com" ,
989+ account : OTHER_ACCOUNT ,
990+ } ) ,
991+ )
992+
993+ const report = await status ( projectDir )
994+
995+ expect ( report . skillsSyncedAt ) . toBeNull ( )
996+ } )
997+
998+
967999 test ( "comes from the snapshot on disk, not a per-thread map" , async ( ) => {
9681000 // The per-message sync stamps its map in the server worker; the sidebar
9691001 // reads on the main thread, which has its own `globalThis` and so its own
0 commit comments