Add quiescent canonical recovery sessions without rewriting requests

This commit is contained in:
2026-11-08 01:41:23 +08:00
parent 0c7fae6e32
commit a0417b4811
11 changed files with 276 additions and 20 deletions
+13
View File
@@ -98,3 +98,16 @@ test('shared service transport binds the immutable AI admission version header',
for(const value of [0,-1,1.5,NaN,Number.MAX_SAFE_INTEGER+1])await assert.rejects(()=>transport({method:'POST',path:'fixture',expectedVersion:value}),/invalid_server_version/);
assert.equal(calls.length,1);
});
test('recovery reader requires a complete canonical model for its bound project and forwards cancellation',async()=>{
const controller=new AbortController(),calls=[];
const{port}=setup(async request=>{calls.push(request);return{status:200,body:{model:chunk()}};});
const loaded=await port.read(controller.signal);assert.equal(loaded.document.projectId,root);assert.equal(loaded.versions.get(child),7);
assert.equal(calls[0].method,'GET');assert.equal(calls[0].signal,controller.signal);assert.equal(calls[0].body,undefined);assert.equal(calls[0].requestId,undefined);
for(const[response,error]of[
[{status:200,body:{model:chunk(false)}},/incomplete_initial_model/],
[{status:409,body:{error:'canonical_migration_required',document_format_version:1,root_id:root,source_versions:{[root]:1}}},/canonical_migration_required/],
[{status:200,body:{model:{documentFormatVersion:1,projectId:child,canvases:[{id:child,parent:null}],elements:[],tombstones:{},versions:{[child]:1},complete:true,removedCanvasIds:[]}}},/project_mismatch/],
[{status:403,body:{error:'forbidden'}},/forbidden/],
]){const{port:invalid}=setup(async()=>response);await assert.rejects(invalid.read(controller.signal),error);}
});