@tnunamak/dalan 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,12 +6,15 @@
6
6
  // Fresh claims and finish handoffs are told apart by `handoff`: a handoff claim has no wake and no listing of its own.
7
7
  // Remembered state is in memory and bounded; a restart forgets it, and the lines then carry nulls, never wrong numbers.
8
8
  export const SILENCE_MS=120000;
9
+ export const OFFER_STALL_MS=5*60_000;
10
+ const OFFER_ALERT_INTERVAL_MS=30*60_000;
11
+ const HANDOFF_BACKOFF_MS=5*60_000;
9
12
  const iso=ms=>new Date(ms).toISOString();
10
13
  const gap=(from,to)=>from==null||to==null?null:Math.round(to-from);
11
14
  export function createPhaseTrace({log:write,now=Date.now,max=5000}) {
12
15
  // Telemetry only: a failing log write (full disk, missing directory) must never change a tool result or a wake delivery.
13
16
  const log=entry=>{try{write(entry);}catch{}};
14
- const listed=new Map(),woke=new Map(),fresh=new Map(),active=new Map();
17
+ const listed=new Map(),woke=new Map(),fresh=new Map(),active=new Map(),offers=new Map(),lastOfferAlert=new Map(),handoffBackoff=new Map();
15
18
  const remember=(map,key,value)=>{map.set(key,value);while(map.size>max)map.delete(map.keys().next().value);};
16
19
  // Measurement only: how long a claim goes quiet between the holder's calls. A claim that ends by cancel or lease expiry
17
20
  // makes no call, so its last silence is read offline from the last mcp_outcome line against claim_phase.
@@ -24,7 +27,49 @@ export function createPhaseTrace({log:write,now=Date.now,max=5000}) {
24
27
  if(final) active.delete(requestId);
25
28
  else { claim.last=at;claim.calls++; }
26
29
  };
30
+ function endOffer(worker,reason) {
31
+ const offer=offers.get(worker);
32
+ if(!offer)return;
33
+ offers.delete(worker);
34
+ if(offer.alerted) log({kind:'claim_offer_ended',worker,call_id:offer.callId,reason,stall_ms:gap(offer.since,now())});
35
+ }
27
36
  return {
37
+ // Only a locally finished response carrying an acquisition recommendation starts this clock.
38
+ offered({worker,subject,callId,readyIds}) {
39
+ if(!readyIds.length) { endOffer(worker,'no_eligible_offer'); return; }
40
+ const previous=offers.get(worker);
41
+ if(previous?.subject===subject&&readyIds.some(id=>previous.readyIds.includes(id))) {
42
+ previous.readyIds=readyIds;
43
+ return;
44
+ }
45
+ endOffer(worker,'offer_changed');
46
+ remember(offers,worker,{subject,callId,readyIds,since:now(),alerted:false});
47
+ },
48
+ claimAttempt(worker) { endOffer(worker,'claim_attempt'); },
49
+ dueOfferStalls(stillOffered) {
50
+ const at=now(), due=[];
51
+ for(const [worker,offer] of offers) {
52
+ if(at-offer.since<OFFER_STALL_MS) continue;
53
+ const ready=stillOffered(worker,offer.subject,offer.readyIds);
54
+ if(ready===false) endOffer(worker,'no_eligible_offer');
55
+ if(ready!==true||offer.alertPending||offer.alerted||
56
+ at-(lastOfferAlert.get(worker)??-Infinity)<OFFER_ALERT_INTERVAL_MS) continue;
57
+ offer.alertPending=true;
58
+ due.push({worker,call_id:offer.callId,stall_ms:gap(offer.since,at)});
59
+ }
60
+ return due;
61
+ },
62
+ offerAlertResult(stall,delivered) {
63
+ const offer=offers.get(stall.worker);
64
+ if(offer?.callId===stall.call_id) {
65
+ offer.alertPending=false;
66
+ if(delivered) offer.alerted=true;
67
+ }
68
+ if(delivered) {
69
+ remember(lastOfferAlert,stall.worker,now());
70
+ log({kind:'claim_offer_stalled',...stall});
71
+ }
72
+ },
28
73
  // A list_pending call showed these rows: keep the first time each one was seen.
29
74
  listed(requestIds) {
30
75
  const at=now();
@@ -44,13 +89,24 @@ export function createPhaseTrace({log:write,now=Date.now,max=5000}) {
44
89
  listed.delete(requestId);woke.delete(requestId);
45
90
  // Send, answer and listing are separate stamps. A row listed before the answer came back (or before the send) has no known order: null, never a negative gap.
46
91
  const wakeToListed=wake&&wake.ackAt!=null&&seen!=null&&seen>=wake.ackAt?gap(wake.ackAt,seen):null;
47
- remember(fresh,requestId,{claimId,subject,at,handoff});
92
+ remember(fresh,requestId,{claimId,subject,worker,at,handoff});
48
93
  remember(active,requestId,{claimId,subject,claimedAt:at,last:at,calls:0});
49
94
  log({kind:'claim_phase',request_id:requestId,worker,claim_id:claimId,handoff,created_at:createdAt,
50
95
  wake_attempt_at:wake?iso(wake.attemptAt):null,first_listed_at:seen==null?null:iso(seen),claimed_at:iso(at),
51
96
  submit_to_wake_ms:gap(created,wake?.attemptAt),wake_ack_ms:wake&&wake.ackAt!=null?Math.round(wake.ackAt-wake.attemptAt):null,
52
97
  wake_to_listed_ms:wakeToListed,listed_to_claim_ms:gap(seen,at),submit_to_claim_ms:gap(created,at)});
53
98
  },
99
+ handoffBackingOff(worker) { return now()<(handoffBackoff.get(worker)??0); },
100
+ expired(requestId) {
101
+ const claim=fresh.get(requestId);
102
+ if(claim) {
103
+ fresh.delete(requestId);
104
+ if(claim.handoff) remember(handoffBackoff,claim.worker,now()+HANDOFF_BACKOFF_MS);
105
+ log({kind:'claim_expired_before_first_action',request_id:requestId,claim_id:claim.claimId,
106
+ worker:claim.worker,handoff:claim.handoff,claim_age_ms:gap(claim.at,now())});
107
+ }
108
+ active.delete(requestId);
109
+ },
54
110
  // The server provides a snapshot taken before the successful progress write.
55
111
  progress({requestId,claimId,claimedAt,first,note}) {
56
112
  if(!first) return;
@@ -63,6 +119,7 @@ export function createPhaseTrace({log:write,now=Date.now,max=5000}) {
63
119
  },
64
120
  // Any worker call that names a request. The first one by the claimant after a fresh claim is the first action.
65
121
  action({requestId,tool,subject}) {
122
+ if(tool==='claim') return; // Replaying the grant is not starting the job.
66
123
  silence({requestId,tool,subject});
67
124
  const claim=fresh.get(requestId);
68
125
  if(!claim||claim.subject!==subject) return;
@@ -37,7 +37,9 @@ export async function preflightPR(assignment, { now = Date.now, read = readPullR
37
37
  prInput(assignment, now());
38
38
  if (!remote || !['open', 'closed'].includes(remote.state) || typeof remote.draft !== 'boolean' || !fullSha.test(remote.head?.sha ?? '')) throw Object.assign(new Error('pr_head_unknown: incomplete GitHub observation'),{code:'DOT_BRIDGE_INFRASTRUCTURE'});
39
39
  if (remote.state !== 'open' || remote.merged === true) throw new Error('PR is no longer open');
40
- if (remote.head.sha !== input.head_sha) throw new Error('pr_head_mismatch: pinned revision moved');
40
+ if (remote.head.sha !== input.head_sha) throw Object.assign(new Error('pr_head_mismatch: pinned revision moved'), {
41
+ prHeadMismatch: { pinned: input.head_sha, observed: remote.head.sha },
42
+ });
41
43
  return { github_repo: input.github_repo, pr_number: input.pr_number, head_sha: remote.head.sha, draft: remote.draft, checked_at: new Date(now()).toISOString() };
42
44
  }
43
45
 
package/src/server.mjs CHANGED
@@ -239,14 +239,14 @@ const toolRegistry=createToolRegistry({store,now:()=>store.nowMs(),handlers:{
239
239
  return [requestId,claim.claim_id,claim.epoch,subject,connection];
240
240
  } catch(error) { throw assignmentRegistryRefusal(error); }
241
241
  },
242
- run({args,context:{worker,subject},grantScope}) {
242
+ run({args,context:{worker,subject},grantScope,recordOnRead}) {
243
243
  const requestId=id(args.request_id),claimId=id(args.claim_id,'claim_id');
244
244
  const offset=args.offset??0;
245
245
  if(offset%scopedSourceChunk!==0||(offset!==0&&!args.sha256)) throw new RegistryError('invalid_arguments','invalid scoped input offset');
246
246
  try {
247
- const {a,input,mirror}=workspace.context(requestId,claimId,subject,false,worker);
247
+ const {a,claim,input,mirror}=workspace.context(requestId,claimId,subject,false,worker);
248
248
  if(input.head_sha&&input.head_sha!==input.base_sha) throw new Error('scoped input requires the reviewed revision to match the base');
249
- const {manifest,blobs}=pinnedScopedSource(mirror,a.assignment);
249
+ const {manifest,blobs,refusedPaths}=pinnedScopedSource(mirror,a.assignment);
250
250
  if(grantScope && manifest.files.some(file=>!a.assignment.scope_paths.includes(file.path)))
251
251
  throw new Error('assignment grant requires exact scoped files');
252
252
  if(!manifest.files.length) throw new Error('no approved scoped input files');
@@ -264,6 +264,11 @@ const toolRegistry=createToolRegistry({store,now:()=>store.nowMs(),handlers:{
264
264
  const end=Math.min(offset+scopedSourceChunk,bytes.length);
265
265
  const result={sha256:hash,size:bytes.length,offset,next_offset:end===bytes.length?null:end,data_base64:bytes.subarray(offset,end).toString('base64')};
266
266
  if(JSON.stringify(redactOutput(result))!==JSON.stringify(result)) throw new Error('scoped input encoding refused');
267
+ const metadata={...manifest,size:bytes.length,...(refusedPaths.length?{refused_paths:refusedPaths}:{})};
268
+ recordOnRead(()=>store.recordScopedInputChunk(requestId,{
269
+ epoch:claim.epoch,worker,sha256:hash,metadata,chunk:offset/scopedSourceChunk,
270
+ chunkCount:Math.ceil(bytes.length/scopedSourceChunk),
271
+ }));
267
272
  return result;
268
273
  } catch(error) { throw assignmentRegistryRefusal(error); }
269
274
  },
@@ -794,6 +799,7 @@ function sweepSkipped() {
794
799
  function sweepStaleLeases() {
795
800
  const ids=store.sweepStaleLeases();
796
801
  if(ids.length) log({kind:'claims_lease_expired',count:ids.length,request_ids:ids.slice(0,20)});
802
+ for(const id of ids) phaseTrace.expired(id);
797
803
  return ids;
798
804
  }
799
805
  const destinations=createDestinations({store,ackLedger,notify:notifyAttachedWaiter,log,crashAt,exit:code=>process.exit(code)});
@@ -889,7 +895,13 @@ function logPendingReply(reply,{worker,subject},callId,batch={}) {
889
895
 
890
896
  // Put the next acquisition before job detail, including after progress and finish.
891
897
  // Derive it after the call (and any finish handoff) so it describes remaining capacity.
892
- function batchCapacityReply(name,reply,principal,callId) {
898
+ function batchRoom(subject,worker) {
899
+ const {free_lanes,ready,available,reservedId}=store.batchClaimRoom(subject,worker,redeliveryLimits.laneCapacity,claimCapacity);
900
+ const hint=store.claimHint(worker);
901
+ const hintFree=hint===null?Infinity:Math.max(Number(!!reservedId),hint-store.recentClaimCount(worker));
902
+ return {free_lanes,ready,available,hintFree,next:Math.min(available,ready.length,8,hintFree)};
903
+ }
904
+ function batchCapacityReply(name,reply,principal,callId,onOffer) {
893
905
  if(!['list_pending','claim','progress','finish'].includes(name)) return reply;
894
906
  const recordListing=name==='list_pending'&&!!callId;
895
907
  if(!batchClaimProfile) {
@@ -897,11 +909,8 @@ function batchCapacityReply(name,reply,principal,callId) {
897
909
  return reply;
898
910
  }
899
911
  const {worker,subject}=principal;
900
- const {free_lanes,ready,available,reservedId}=store.batchClaimRoom(subject,worker,redeliveryLimits.laneCapacity,claimCapacity);
912
+ const {free_lanes,ready,available,hintFree,next}=batchRoom(subject,worker);
901
913
  const ready_queued=ready.length;
902
- const hint=store.claimHint(worker);
903
- const hintFree=hint===null?Infinity:Math.max(Number(!!reservedId),hint-store.recentClaimCount(worker));
904
- const next=Math.min(available,ready_queued,8,hintFree);
905
914
  const [reason,next_action]=quiescing?['quiescing',restartQuiesceText]:
906
915
  store.paused()?['paused','Claims are paused; call list_pending again later.']:
907
916
  next>0?['ready',`claim with next=${next} now`]:
@@ -912,8 +921,9 @@ function batchCapacityReply(name,reply,principal,callId) {
912
921
  const response={next_action,free_lanes,ready_queued,...rest};
913
922
  if(recordListing) {
914
923
  const recommended=reason==='ready'?next:0;
915
- logPendingReply(response,principal,callId,{ready_queued,dispatch_reason:reason,recommended_claims:recommended,
916
- ready_head_ids:ready.slice(0,recommended).map(item=>item.request_id)});
924
+ const readyIds=ready.slice(0,recommended).map(item=>item.request_id);
925
+ logPendingReply(response,principal,callId,{ready_queued,dispatch_reason:reason,recommended_claims:recommended,ready_head_ids:readyIds});
926
+ if(readyIds.length) onOffer?.({worker,subject,callId,readyIds});
917
927
  }
918
928
  return response;
919
929
  }
@@ -985,7 +995,7 @@ async function runHandoff({principal,requestId,claimId,waitMs,maxJobs=1,idleLeas
985
995
  // Rows whose last handoff lapsed untouched are left for the worker's own list_pending: the same rows were handed ten times and never started.
986
996
  const pick=free=>(store.nextQueued(free,null,worker,{applyHint:false,handoffExclusions:tried}).next_queued??[]);
987
997
  for(;;) {
988
- if(signal?.aborted||store.paused()) return jobs.length?{jobs}:{};
998
+ if(signal?.aborted||store.paused()||(batchClaimProfile&&phaseTrace.handoffBackingOff(worker))) return jobs.length?{jobs}:{};
989
999
  const {free_lanes}=store.laneState(subject,worker,redeliveryLimits.laneCapacity,claimCapacity);
990
1000
  if(free_lanes<=0) return jobs.length?{jobs}:{};
991
1001
  if(store.hasQueuedFor([worker])) {
@@ -1004,6 +1014,7 @@ async function runHandoff({principal,requestId,claimId,waitMs,maxJobs=1,idleLeas
1004
1014
  fresh=pick(store.laneState(subject,worker,redeliveryLimits.laneCapacity,claimCapacity).free_lanes);
1005
1015
  continue;
1006
1016
  }
1017
+ if(batchClaimProfile&&phaseTrace.handoffBackingOff(worker)) return jobs.length?{jobs}:{};
1007
1018
  tried.add(fresh[0].request_id);
1008
1019
  const job=await claim(fresh[0].request_id,slot);
1009
1020
  if(job) { jobs.push(job); if(jobs.length>=maxJobs) return {jobs}; }
@@ -1241,7 +1252,10 @@ async function dispatchTool(name,a,principal,notifyMeta,signal,batchMode=null,re
1241
1252
  const t3=await import('./t3.mjs');
1242
1253
  const authorize=()=>{
1243
1254
  const threads=toolRegistry.t3Threads(name,principal);
1244
- if(name!=='t3_thread_list' && !threads.has(a.threadId)) throw new RegistryError('tool_unavailable','tool unavailable');
1255
+ if(name!=='t3_thread_list' && !threads.has(a.threadId)) {
1256
+ log(control.destinationDeniedEvent(name,principal.worker,audit.call_id));
1257
+ throw new RegistryError('tool_unavailable','tool unavailable');
1258
+ }
1245
1259
  return threads;
1246
1260
  };
1247
1261
  // Linearization point: this synchronous live-grant read follows the last await before
@@ -1353,7 +1367,17 @@ async function dispatchTool(name,a,principal,notifyMeta,signal,batchMode=null,re
1353
1367
  // A fresh claim, a claim after abandon and an expired-lease takeover are each a new admission. The Store
1354
1368
  // still validates claimant, subject, lease, cancellation and capacity atomically.
1355
1369
  const admission=!store.paused()&&(row.status==='queued'||row.status==='claimed'&&held&&!(held.claimant===claimant&&held.subject===subject)&&store.leaseExpired(held));
1356
- const preflight=admission?await preflightPR(row.assignment):null;
1370
+ let preflight=null;
1371
+ if(admission) {
1372
+ try {
1373
+ preflight=await preflightPR(row.assignment);
1374
+ if(preflight) store.clearPrClaimMismatch(requestId,preflight);
1375
+ }
1376
+ catch(error) {
1377
+ if(error.prHeadMismatch) store.recordPrClaimMismatch(requestId,error.prHeadMismatch);
1378
+ throw error;
1379
+ }
1380
+ }
1357
1381
  if(!retry) {
1358
1382
  assertRepoAllowed(worker,row.assignment);
1359
1383
  // Resolve an optional workspace grant after remote preflight but before claim acquisition. A broken
@@ -1526,7 +1550,7 @@ function publicErrorText(error,what) {
1526
1550
  log({kind:'request_error',what,error_id:errorId,detail:safeDiagnostic(error?.stack??error,4000)});
1527
1551
  return `Error executing ${what} (error id ${errorId}; details are in the request log)`;
1528
1552
  }
1529
- async function dispatch(message,principal,signal,callId) {
1553
+ async function dispatch(message,principal,signal,callId,onOffer) {
1530
1554
  const p=message.params??{};
1531
1555
  switch(message.method) {
1532
1556
  case 'server/discover': return {ttlMs:0,cacheScope:'private',supportedVersions:['2026-07-28'],capabilities:{tools:{},events:{}},_meta:{'io.modelcontextprotocol/serverInfo':serverInfo}};
@@ -1535,7 +1559,7 @@ async function dispatch(message,principal,signal,callId) {
1535
1559
  // Modern catalogs are process-wide. A worker's capability controls tools/call authority, not its cached schemas.
1536
1560
  // legacy-v46 keeps its pinned per-worker surface for compatibility.
1537
1561
  case 'tools/list': return {ttlMs:0,cacheScope:'private',tools:catalogProfile==='legacy-v46'?advertisedTools.filter(t=>!(t3Tools.has(t.name)||notifyTools.has(t.name))||hasCapability(workers,principal.worker,'t3')):advertisedTools};
1538
- case 'tools/call': { try { return {content:[{type:'text',text:JSON.stringify(redactOutput(batchCapacityReply(p.name,await tool(p.name,p.arguments??{},principal,notifyTools.has(p.name)?p._meta:undefined,signal),principal,callId)))}],isError:false}; } catch(e) { const error={content:[{type:'text',text:publicErrorText(e,`tool ${toolNames.has(p.name)?p.name:'unknown'}`)}],isError:true};if(oauth&&e.message==='insufficient_scope')error._meta={'mcp/www_authenticate':[[challenge(oauth,scopeFor(p.name)),'error="insufficient_scope"','error_description="Required scope is missing"'].join(', ')]};return error; } }
1562
+ case 'tools/call': { try { return {content:[{type:'text',text:JSON.stringify(redactOutput(batchCapacityReply(p.name,await tool(p.name,p.arguments??{},principal,notifyTools.has(p.name)?p._meta:undefined,signal),principal,callId,onOffer)))}],isError:false}; } catch(e) { const error={content:[{type:'text',text:publicErrorText(e,`tool ${toolNames.has(p.name)?p.name:'unknown'}`)}],isError:true};if(oauth&&e.message==='insufficient_scope')error._meta={'mcp/www_authenticate':[[challenge(oauth,scopeFor(p.name)),'error="insufficient_scope"','error_description="Required scope is missing"'].join(', ')]};return error; } }
1539
1563
  case 'events/list': return {events:[event]};
1540
1564
  case 'events/subscribe': if(oauth)needScope(principal,'dalan.read');return subscribe(p,principal);
1541
1565
  case 'events/unsubscribe': { if(oauth)needScope(principal,'dalan.read');if(!validEventParams(p)) throw new Error('invalid subscription'); store.unsubscribe(subId(p.delivery.url,principal.subject,principal.worker)); return {}; }
@@ -1577,11 +1601,12 @@ const publicServer=(as?createBuiltinHttpServer:http.createServer)(async(req,res)
1577
1601
  // Metadata only: bodies can carry webhook secrets and worker results.
1578
1602
  log({kind:'mcp_inbound',call_id:outcome.state.call_id,rpc_method:outcome.state.rpc_method,tool:outcome.state.tool,worker:principal.worker,ua:uaToken(req)});
1579
1603
  if(!Object.hasOwn(rpc,'id')) { res.writeHead(202); res.end(); return; }
1604
+ if(outcome.state.tool==='claim') phaseTrace.claimAttempt(principal.worker);
1580
1605
  outcome.state.phase='dispatch';
1581
1606
  const eventStream=readEnv('DALAN_TRIAL_SSE')==='1'&&req.method==='POST'&&acceptsMcpEventStream(req.headers.accept)?beginMcpEventStream(res):null;
1582
1607
  // A tool that waits (finish with finish_handoff) stops when the client leaves, so nothing is claimed for nobody.
1583
1608
  const clientGone=new AbortController();res.once('close',()=>clientGone.abort());if(res.destroyed)clientGone.abort();
1584
- try { json(res,200,{jsonrpc:'2.0',id:rpc.id,result:{resultType:'complete',...await dispatch(rpc,principal,clientGone.signal,outcome.state.call_id)}},eventStream); }
1609
+ try { json(res,200,{jsonrpc:'2.0',id:rpc.id,result:{resultType:'complete',...await dispatch(rpc,principal,clientGone.signal,outcome.state.call_id,offer=>res.once('finish',()=>phaseTrace.offered(offer)))}},eventStream); }
1585
1610
  catch(e) { json(res,200,rpcError(rpc.id,e.code||-32602,publicErrorText(e,'request'),e.data),eventStream); }
1586
1611
  // Response-byte accounting for the throttle and the break ledger; the response is already written, so a failure only logs.
1587
1612
  if(outcome.state.tool) try { store.recordResponseBytes(principal.subject,outcome.state.tool,outcome.state.response_bytes,principal.worker); } catch(e) { log({kind:'response_bytes_error',call_id:outcome.state.call_id,reason:e.message}); }
@@ -1792,6 +1817,8 @@ const adminServer=http.createServer(async(req,res)=>{
1792
1817
  // Read before recording consumption: the response then matches a peek read, which records no consumption.
1793
1818
  const got=maskedForOwner(withAvailableChecks(store.get(requestId)));
1794
1819
  Object.assign(got,repositoryReadScope(got.assignment));
1820
+ const manifests=store.scopedInputManifests(requestId);
1821
+ if(manifests.length) got.scoped_input_manifests=manifests;
1795
1822
  if(req.method==='GET'&&url.searchParams.get('admission')==='1'&&got.status==='queued') {
1796
1823
  const snapshot=store.admissionForQueuedRequest(requestId);
1797
1824
  if(snapshot) got.admission=snapshot;
@@ -2272,6 +2299,27 @@ const staleDays=(d=>Number.isFinite(d)&&d>0?d:7)(Number(readEnv('DALAN_DECISION_
2272
2299
  const sweepStale=()=>{try{const ids=store.sweepStaleDecisions(staleDays);if(ids.length)log({kind:'decisions_stale',count:ids.length,request_ids:ids.slice(0,20)});}catch(error){log({kind:'decisions_stale_error',reason:error.message});}};
2273
2300
  sweepStale(); setInterval(sweepStale,3600000).unref();
2274
2301
  setInterval(()=>checkAlerts(store,log).catch(e=>log({kind:'alert_error',reason:e.message})),60000).unref();
2302
+ setInterval(()=>{
2303
+ try {
2304
+ const due=phaseTrace.dueOfferStalls((worker,subject,ids)=>{
2305
+ const queued=store.db.prepare(`SELECT 1 FROM assignments WHERE status='queued'
2306
+ AND request_id IN (${ids.map(()=>'?').join(',')}) LIMIT 1`).get(...ids);
2307
+ if(!queued) return false;
2308
+ if(store.paused()||quiescing||store.holdingBreak(worker)||store.capacityHoldUntil(worker)) return null;
2309
+ const {ready,next}=batchRoom(subject,worker);
2310
+ return ready.slice(0,next).some(item=>ids.includes(item.request_id))?true:null;
2311
+ });
2312
+ for(const stall of due) {
2313
+ const {worker,call_id,stall_ms}=stall;
2314
+ void publishAlert('Dalan attention',`claim_offer_stalled: ${worker} received an offer and sent no claim for ${Math.floor(stall_ms/60000)} minutes. Check the worker conversation.`,log,
2315
+ {idempotencyKey:`claim-offer-stalled:${worker}:${call_id}`})
2316
+ .then(delivered=>phaseTrace.offerAlertResult(stall,delivered),error=>{
2317
+ phaseTrace.offerAlertResult(stall,false);
2318
+ log({kind:'claim_offer_alert_error',worker,reason:redactNote(error.message)});
2319
+ });
2320
+ }
2321
+ } catch(error) { log({kind:'claim_offer_alert_error',reason:redactNote(error.message)}); }
2322
+ },60000).unref();
2275
2323
  }
2276
2324
  const startWhenWindowCloses=()=>{ if(updateWindowOpen()) setTimeout(startWhenWindowCloses,250).unref(); else startBackground(); };
2277
2325
  startWhenWindowCloses();
@@ -312,7 +312,7 @@ export async function stopChild(child, { termTimeoutMs = 3000, killTimeoutMs = 5
312
312
  return await killWait || child.exitCode !== null || child.signalCode !== null || child.spawned === false;
313
313
  }
314
314
 
315
- async function requireCatalogGuard(repo, env, receipt, options) {
315
+ async function requireCatalogGuard(repo, env, receipt, options, stopProbe) {
316
316
  const child = (options.spawn ?? spawn)(receipt.node ?? process.execPath, [path.join(repo, 'src/server.mjs')], { cwd: repo, env, stdio: ['ignore', 'pipe', 'pipe'] });
317
317
  let stdout = '', stderr = '';
318
318
  let spawnError = null, closed = false;
@@ -331,7 +331,7 @@ async function requireCatalogGuard(repo, env, receipt, options) {
331
331
  if (!closed) fail('candidate did not enforce the service catalog pin before timeout');
332
332
  if (/MCP listening|admin socket/.test(stdout)) fail('candidate announced a listener before enforcing the service catalog pin');
333
333
  if (child.exitCode === 0 || !stderr.includes('service catalog guard mismatch')) fail('candidate did not reject the mismatched service catalog pin');
334
- } finally { await stopChild(child); }
334
+ } finally { await stopProbe(child); }
335
335
  }
336
336
 
337
337
  // Only fixed diagnostics authored by this module; never propagate socket or filesystem data.
@@ -347,11 +347,15 @@ const SAFE_CANDIDATE_PROBE_FAILURES = new Set([
347
347
  ]);
348
348
 
349
349
  export async function probeCandidate(home, receipt, repo, options = {}) {
350
- const scratchBase = path.join(os.homedir(), '.tmp');
350
+ const scratchBase = options.scratchBase ?? path.join(os.homedir(), '.tmp');
351
351
  fs.mkdirSync(scratchBase, { recursive: true, mode: 0o700 });
352
352
  const scratch = fs.mkdtempSync(path.join(scratchBase, 'dalan-candidate-'));
353
353
  fs.chmodSync(scratch, 0o700);
354
354
  let child;
355
+ let settled = true, succeeded = false;
356
+ const stopProbe = async candidate => {
357
+ if (!(await stopChild(candidate, options.stopBounds))) settled = false;
358
+ };
355
359
  try {
356
360
  prepareProbeConfig(home, scratch);
357
361
  const serviceEnv = await (options.serviceEnvironment?.(receipt) ?? effectiveServiceEnvironment(receipt, options));
@@ -366,8 +370,8 @@ export async function probeCandidate(home, receipt, repo, options = {}) {
366
370
  const pinFile = path.join(configDir, 'service-catalog.json');
367
371
  const version = JSON.parse(fs.readFileSync(path.join(repo, 'package.json'), 'utf8')).version;
368
372
  fs.writeFileSync(pinFile, JSON.stringify({ version, catalogs: {} }), { mode: 0o600, flag: 'wx' });
369
- try { await requireCatalogGuard(repo, env, receipt, options); }
370
- finally { fs.rmSync(pinFile, { force: true }); }
373
+ try { await requireCatalogGuard(repo, env, receipt, options, stopProbe); }
374
+ finally { if (settled) fs.rmSync(pinFile, { force: true }); }
371
375
  child = (options.spawn ?? spawn)(receipt.node ?? process.execPath, [path.join(repo, 'src/server.mjs')], { cwd: repo, env, stdio: ['ignore', 'ignore', 'ignore'] });
372
376
  let spawnError = null, closed = false;
373
377
  child.on('error', error => { spawnError = error; });
@@ -388,10 +392,17 @@ export async function probeCandidate(home, receipt, repo, options = {}) {
388
392
  if (!result) fail(lastSafeProbeFailure
389
393
  ? `candidate service did not pass its self-check: ${lastSafeProbeFailure}`
390
394
  : 'candidate service did not pass its self-check before timeout');
395
+ succeeded = true;
391
396
  return result;
392
397
  } finally {
393
- await stopChild(child);
394
- fs.rmSync(scratch, { recursive: true, force: true });
398
+ await stopProbe(child);
399
+ if (settled) fs.rmSync(scratch, { recursive: true, force: true });
400
+ else {
401
+ const warning = 'Candidate probe did not confirm child shutdown; temporary files were retained. Stop the remaining probe before removing its temporary files.';
402
+ if (succeeded) fail(warning);
403
+ // Preserve the original typed failure and do not print a private path.
404
+ console.warn(warning);
405
+ }
395
406
  }
396
407
  }
397
408
 
package/src/store.mjs CHANGED
@@ -1143,6 +1143,10 @@ export class Store {
1143
1143
  end_source TEXT, last_probe_at TEXT
1144
1144
  ); CREATE UNIQUE INDEX IF NOT EXISTS scoped_worker_breaks_one_open
1145
1145
  ON scoped_worker_breaks(worker) WHERE until IS NULL;`);
1146
+ this.db.exec(`CREATE TABLE IF NOT EXISTS pr_claim_blocks(
1147
+ request_id TEXT PRIMARY KEY REFERENCES assignments(request_id) ON DELETE CASCADE,
1148
+ pinned TEXT NOT NULL, observed TEXT NOT NULL, checked_at TEXT NOT NULL
1149
+ );`);
1146
1150
  this.db.exec(`CREATE TABLE IF NOT EXISTS work_messages(
1147
1151
  message_id TEXT PRIMARY KEY REFERENCES messages(message_id) ON DELETE CASCADE,
1148
1152
  request_id TEXT NOT NULL REFERENCES assignments(request_id) ON DELETE CASCADE,
@@ -1180,6 +1184,12 @@ export class Store {
1180
1184
  UNIQUE(worker,subject,started_at));`);
1181
1185
  if(!this.db.prepare("SELECT 1 FROM pragma_table_info('relationships') WHERE name='publish_grant'").get()) this.db.exec('ALTER TABLE relationships ADD COLUMN publish_grant TEXT');
1182
1186
  }
1187
+ this.db.exec(`CREATE TABLE IF NOT EXISTS scoped_input_receipts(
1188
+ request_id TEXT NOT NULL REFERENCES assignments(request_id) ON DELETE CASCADE,
1189
+ epoch INTEGER NOT NULL, sha256 TEXT NOT NULL, worker TEXT NOT NULL, metadata TEXT NOT NULL,
1190
+ served_chunks INTEGER NOT NULL, all_chunks INTEGER NOT NULL,
1191
+ PRIMARY KEY(request_id,epoch,sha256)
1192
+ ) WITHOUT ROWID;`);
1183
1193
  // Which spelling of the fix-loop source this database stores. Schemas created before the rename list the earlier
1184
1194
  // spelling in the CHECK constraint on assignments.source; newer schemas list only the neutral one.
1185
1195
  this.legacyFixNames=!!this.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='assignments' AND instr(sql,?)>0").get(`'${legacyFixLoopName}'`);
@@ -2735,6 +2745,28 @@ export class Store {
2735
2745
  if(!changed.changes) throw new Error('relationship_not_found');
2736
2746
  return this.db.prepare('SELECT * FROM relationships WHERE relationship_id=?').get(relationshipId);
2737
2747
  }
2748
+ recordScopedInputChunk(id, {epoch,worker,sha256,metadata,chunk,chunkCount}) {
2749
+ // At most 29 chunks fit the scoped source limit. An OR makes repeat and out-of-order reads idempotent.
2750
+ this.db.prepare(`INSERT INTO scoped_input_receipts(request_id,epoch,sha256,worker,metadata,served_chunks,all_chunks)
2751
+ VALUES(?,?,?,?,?,?,?) ON CONFLICT(request_id,epoch,sha256) DO UPDATE SET served_chunks=served_chunks | excluded.served_chunks
2752
+ WHERE (served_chunks & excluded.served_chunks)=0`)
2753
+ .run(id,epoch,sha256,worker,JSON.stringify(metadata),1<<chunk,(1<<chunkCount)-1);
2754
+ }
2755
+ scopedInputManifests(id) {
2756
+ return this.db.prepare(`SELECT epoch,worker,sha256,metadata,served_chunks=all_chunks AS complete
2757
+ FROM scoped_input_receipts WHERE request_id=? ORDER BY epoch,sha256`).all(id)
2758
+ .map(({epoch,worker,sha256,metadata,complete})=>({...JSON.parse(metadata),epoch,worker,sha256,all_chunks_served:!!complete}));
2759
+ }
2760
+ recordPrClaimMismatch(id,{pinned,observed}) {
2761
+ this.db.prepare(`INSERT INTO pr_claim_blocks(request_id,pinned,observed,checked_at)
2762
+ SELECT request_id,?,?,? FROM assignments WHERE request_id=? AND status='queued'
2763
+ ON CONFLICT(request_id) DO UPDATE SET observed=excluded.observed,checked_at=excluded.checked_at
2764
+ WHERE pr_claim_blocks.pinned=excluded.pinned`).run(pinned,observed,this.stamp(),id);
2765
+ }
2766
+ clearPrClaimMismatch(id,{head_sha,checked_at}) {
2767
+ this.db.prepare('DELETE FROM pr_claim_blocks WHERE request_id=? AND pinned=? AND checked_at<=?')
2768
+ .run(id,head_sha,checked_at);
2769
+ }
2738
2770
  recordPrPreflight(id,phase,assignment,evidence,replace=false) {
2739
2771
  assertPreflight(assignment,evidence,this.nowMs());
2740
2772
  if(evidence) this.db.prepare(`INSERT ${replace?'OR REPLACE ':''}INTO pr_preflights(request_id,phase,evidence) VALUES(?,?,?)`).run(id,phase,JSON.stringify(evidence));
@@ -3084,10 +3116,10 @@ export class Store {
3084
3116
  const reservedId=this.admissionReservation(worker)?.request_id;
3085
3117
  const reserveOrder=(a,b)=>Number(b.request_id===reservedId)-Number(a.request_id===reservedId);
3086
3118
  let filler=this.activeCallerReserve(worker)>0?this.fillerRoom(worker):Infinity;
3087
- const assignments=this.db.prepare(`SELECT request_id,payload,created_at,priority,review,caller_waiting,EXISTS(SELECT 1 FROM destination_blocks b WHERE b.request_id=assignments.request_id) blocked FROM assignments WHERE status='queued' AND NOT EXISTS(SELECT 1 FROM facade_withdrawals f WHERE f.request_id=assignments.request_id) AND ${live(this.nowMs())}${batch?' AND skipped_at IS NULL':''} ORDER BY ${LIST_ORDER}`).all().filter(a=>this.mayAct(worker,a.request_id)&&this.protocolListingLive(a.request_id)&&(!batch||!this.isProtocolJob(a.request_id)&&!this.pullQueue.row(a.request_id))).map(a=>({...a,blocked:!!a.blocked&&blocked(a.request_id)}))
3119
+ const assignments=this.db.prepare(`SELECT request_id,payload,created_at,priority,review,caller_waiting,EXISTS(SELECT 1 FROM destination_blocks b WHERE b.request_id=assignments.request_id) blocked, EXISTS(SELECT 1 FROM pr_claim_blocks b WHERE b.request_id=assignments.request_id) stale_pr FROM assignments WHERE status='queued' AND NOT EXISTS(SELECT 1 FROM facade_withdrawals f WHERE f.request_id=assignments.request_id) AND ${live(this.nowMs())}${batch?' AND skipped_at IS NULL':''} ORDER BY ${LIST_ORDER}`).all().filter(a=>this.mayAct(worker,a.request_id)&&this.protocolListingLive(a.request_id)&&(!batch||!this.isProtocolJob(a.request_id)&&!this.pullQueue.row(a.request_id))).map(a=>({...a,blocked:!!a.stale_pr||!!a.blocked&&blocked(a.request_id)}))
3088
3120
  .sort((a,b)=>Number(a.blocked)-Number(b.blocked)||reserveOrder(a,b))
3089
3121
  .filter(a=>handoffExclusions===null||!a.blocked&&a.request_id!==reservedId&&!handoffExclusions.has(a.request_id)&&!this.handoffLapsed(a.request_id,worker))
3090
- .filter(a=>a.caller_waiting===1||filler-- > 0).slice(0,50).map(a=>({kind:'assignment',request_id:a.request_id,title:JSON.parse(a.payload).brief.slice(0,160),created_at:a.created_at,...(a.blocked?{blocked:true}:triageFields(JSON.parse(a.payload),a))}));
3122
+ .filter(a=>a.caller_waiting===1||filler-- > 0).slice(0,50).map(a=>({kind:'assignment',request_id:a.request_id,title:JSON.parse(a.payload).brief.slice(0,160),created_at:a.created_at,...(a.blocked?{blocked:true,...(a.stale_pr?{block_reason:'pr_head_mismatch'}:{})}:triageFields(JSON.parse(a.payload),a))}));
3091
3123
  if(batch||handoffExclusions!==null) return assignments;
3092
3124
  const messages=this.listMessages(worker).map(({preview,...m})=>({kind:'message',request_id:m.message_id,title:preview,...m})).sort((a,b)=>a.created_at.localeCompare(b.created_at));
3093
3125
  const resumes=this.idleClaims(worker).filter(c=>this.protocolListingLive(c.request_id)).map(c=>({kind:'assignment',request_id:c.request_id,resume:true,idle_seconds:Math.floor(this.claimIdleMs(c)/1000),previous_epoch:c.epoch,
@@ -3250,6 +3282,7 @@ export class Store {
3250
3282
  if(active.length+(reserved&&reserved.request_id!==id?1:0)>=claimLimit) throw new Error('capacity_full');
3251
3283
  this.assertClaimGap(id,subject,worker,active);
3252
3284
  this.recordPrPreflight(id,'claim',JSON.parse(a.payload),preflight,!!old);
3285
+ if(preflight) this.clearPrClaimMismatch(id,preflight);
3253
3286
  if(takeover) { const why=Store.expirySummary(old); this.db.prepare("UPDATE claims SET state='abandoned',abandoned_at=?,abandon_reason=? WHERE request_id=?").run(this.stamp(),why,id); this.lifecycle(id,'abandoned','system',why,old); this.laneFreed(); }
3254
3287
  const claimId=`claim_${randomUUID()}`;
3255
3288
  const claimedAt=this.stamp(), seen=this.db.prepare('SELECT COALESCE(max(sequence),0) n FROM owner_notes WHERE request_id=?').get(id).n;
@@ -482,7 +482,7 @@ export function validateSubmission(assignment,{sensitiveScopeOverride=null,scanI
482
482
  // Shared facts keep the directory exclusion policy and the explicit path refusal aligned.
483
483
  const hardSensitive=file=>hardName(file)||(hasRouterSyntax(file)&&hardName(file.replace(/\[[^\]/]*\]\]?|\([^)/]*\)/g,'')));
484
484
  const policyEntry=file=>p.sensitive_paths.find(x=>file===x||file.startsWith(`${x}/`));
485
- const sensitiveReason=file=>hardSensitive(file)?'hard sensitive path (credential, key or signing material)':policyEntry(file)?'listed in the submission policy sensitive_paths':'name matches the credential, auth or signing lint';
485
+ const sensitiveReason=file=>hardSensitive(file)?'hard sensitive path (credential, key or signing material)':policyEntry(file)?'listed in the submission policy sensitive_paths':'refused: soft sensitive name';
486
486
  const sensitiveRefusal=file=>{
487
487
  const entry=policyEntry(file), base=file.split('/').at(-1);
488
488
  const rule=entry?'owner sensitive_paths entry '+entry:'soft sensitive name: '+(/auth/i.test(base)?'auth':/secret/i.test(base)?'secret':/credential/i.test(base)?'credential':/(?:^|[_.-])sign(?:ing|ature)?(?=[_.-]|$)/i.test(base)?'signing':'credential-style token name');
@@ -720,10 +720,10 @@ export function validateSubmission(assignment,{sensitiveScopeOverride=null,scanI
720
720
  for(const file of scan.files.filter(f=>within(f,scope)&&!scope.includes(f))) {
721
721
  if(priorOmittedPaths.has(file)) continue;
722
722
  if(withholdImplementation&&withheldRepoPath(file,p.sensitive_paths)) {
723
- dropped.push({path:file,reason:isSensitiveRepoPath(file,p.sensitive_paths)?sensitiveReason(file):'sensitive ancestor directory (withheld)'});continue;
723
+ dropped.push({path:file,reason:isSensitiveRepoPath(file,p.sensitive_paths)?sensitiveReason(file):'refused: sensitive ancestor directory'});continue;
724
724
  }
725
725
  if(rendered.execution_scope!=='implementation'&&softName(file)&&!hardSensitive(file)&&!policyEntry(file)&&file!==exception?.path) {
726
- dropped.push({path:file,reason:'soft sensitive name (dropped, not refused)'});continue;
726
+ dropped.push({path:file,reason:'refused: soft sensitive name'});continue;
727
727
  }
728
728
  try { inspectPath(file); }
729
729
  catch(error) {
@@ -744,6 +744,8 @@ export function validateSubmission(assignment,{sensitiveScopeOverride=null,scanI
744
744
  }
745
745
  }
746
746
  if(dropped.length) {
747
+ const refused=dropped.filter(({reason})=>reason.startsWith('refused:'));
748
+ if(refused.length) warn(`Sharing refused for ${refused.slice(0,5).map(({path,reason})=>`${path} (${reason.slice('refused: '.length)})`).join(', ')}${refused.length>5?', and '+(refused.length-5)+' more':''}`);
747
749
  try {
748
750
  narrowedScope=withholdImplementation?scope:narrowScope(scope,[...new Set([...scan.files,...scan.diffFiles])],dropped.map(d=>d.path));
749
751
  } catch(error) {
@@ -74,6 +74,10 @@ async function cwdForProject(a) {
74
74
  return project.workspaceRoot;
75
75
  }
76
76
 
77
+ export function destinationDeniedEvent(tool, worker, callId) {
78
+ return {kind:'t3_destination_denied',tool,worker,call_id:callId,reason:'no_live_destination_grant'};
79
+ }
80
+
77
81
  export async function runT3Tool(name, a) {
78
82
  switch(name) {
79
83
  case 't3_thread_list':
@@ -401,9 +401,9 @@ export function createToolRegistry({ store, now = store.nowMs, handlers = {}, au
401
401
  inProgress(current);
402
402
  }
403
403
  }
404
- let result;
404
+ let result, recordRead;
405
405
  try {
406
- result = await impl.run(call);
406
+ result = await impl.run({ ...call, recordOnRead: fn => { recordRead = fn; } });
407
407
  } catch (error) {
408
408
  if (error instanceof RegistryError) {
409
409
  // The handler refused before doing anything, so the key is free to use again.
@@ -417,6 +417,13 @@ export function createToolRegistry({ store, now = store.nowMs, handlers = {}, au
417
417
  // Replies containing current private data may not outlive the grant that permitted the read.
418
418
  if (impl?.requireCurrentRead) deny(latestAuthority());
419
419
  const capped = capResult(result);
420
+ // Record delivery evidence only after the final authority check and with the exact reply intact.
421
+ if (impl?.requireCurrentRead && recordRead) {
422
+ if (JSON.stringify(capped) !== JSON.stringify(result)) {
423
+ done('handler_failed', new RegistryError('handler_failed', 'live read reply was altered'));
424
+ }
425
+ recordRead();
426
+ }
420
427
  settle({ ok: true, result: capped });
421
428
  done('ok');
422
429
  return { ok: true, result: capped };
@@ -398,7 +398,10 @@ export async function runHosted({ options, env, out, input, signal, errorContext
398
398
 
399
399
  const trialOver = () => expired || (trialEndsAt !== null && clock.now() >= trialEndsAt);
400
400
  if (trialMs !== null) {
401
- const expiry = new Promise(resolve => { expireTimer = setTimeout(() => { expired = true; resolve(); }, Math.max(0, trialEndsAt - clock.now())); expireTimer.unref?.(); });
401
+ const expiry = new Promise(resolve => {
402
+ expireTimer = (clock.setTimeout ?? setTimeout)(() => { expired = true; resolve(); }, Math.max(0, trialEndsAt - clock.now()));
403
+ expireTimer?.unref?.();
404
+ });
402
405
  routeGone = Promise.race([routeGone, expiry]);
403
406
  }
404
407
  const trialLeft = () => trialEndsAt === null ? '' : ` Local shutdown limit: ${timeLeft(trialEndsAt - clock.now())}. The temporary link can stop earlier.`;
@@ -530,7 +533,7 @@ export async function runHosted({ options, env, out, input, signal, errorContext
530
533
  }
531
534
  };
532
535
  lines.close();
533
- clearTimeout(expireTimer);
536
+ if (expireTimer !== null) (clock.clearTimeout ?? clearTimeout)(expireTimer);
534
537
  await cleanup('identity watcher cleanup', () => identityWatcher?.stop());
535
538
  // Withdraw handoff, revoke the trial's app credentials, then close the retained route.
536
539
  let ignoredHandoffCleanup = false;
package/src/workspace.mjs CHANGED
@@ -522,7 +522,7 @@ export function pinnedScopedSource(mirror,assignment) {
522
522
  const tree=readGit(['ls-tree','-rlz','--full-tree',pin],16*1024*1024);
523
523
  if(tree.error||tree.status!==0) throw new Error('pinned source tree unavailable');
524
524
  const decoder=new TextDecoder('utf-8',{fatal:true,ignoreBOM:true});
525
- const entries=[],spellings=new Map();
525
+ const entries=[],spellings=new Map(),refusedPaths=[];
526
526
  let total=0,offset=0;
527
527
  while(offset<tree.stdout.length) {
528
528
  const end=tree.stdout.indexOf(0,offset);
@@ -536,7 +536,11 @@ export function pinnedScopedSource(mirror,assignment) {
536
536
  let file;
537
537
  try { file=relative(decoder.decode(entry.subarray(tab+1))); } catch { continue; }
538
538
  if(file.split('/').some(part=>/[:]|[. ]$/.test(part))||canonicalPath(file).split('/').some(part=>part==='.git'||part==='.gitmodules')||!inScope(file,scope)||
539
- withheldRepoPath(file,policy.paths)||secretContent.test(file)) continue;
539
+ secretContent.test(file)) continue;
540
+ if(withheldRepoPath(file,policy.paths)) {
541
+ if(scope?.paths?.includes(file)) refusedPaths.push({path:file,reason:'refused by scoped input file policy'});
542
+ continue;
543
+ }
540
544
  const parts=file.split('/');
541
545
  for(let i=1;i<=parts.length;i++) {
542
546
  const spelling=parts.slice(0,i).join('/'),key=canonicalPath(spelling);
@@ -550,7 +554,7 @@ export function pinnedScopedSource(mirror,assignment) {
550
554
  }
551
555
  const files=[],blobs=new Map();
552
556
  const manifest={schema_version:1,pin,scope_complete:false,files};
553
- if(!entries.length) return {manifest,blobs};
557
+ if(!entries.length) return {manifest,blobs,refusedPaths};
554
558
  const batch=readGit(['cat-file','--batch'],total+entries.length*96,entries.map(entry=>entry.oid).join('\n')+'\n');
555
559
  if(batch.error||batch.status!==0) throw new Error('pinned source blob unavailable');
556
560
  let cursor=0;
@@ -572,7 +576,7 @@ export function pinnedScopedSource(mirror,assignment) {
572
576
  // Claim completeness only for an exact file list. Directory scopes always
573
577
  // describe the approved subset without disclosing whether paths were withheld.
574
578
  manifest.scope_complete=Boolean(scope?.paths?.length&&!scope.excluded.size&&scope.paths.every(file=>blobs.has(file)));
575
- return {manifest,blobs};
579
+ return {manifest,blobs,refusedPaths};
576
580
  }
577
581
 
578
582
  // A list shown in the receipt: the first `shown` names, the true total, and a flag when the preview is shorter than the total.