@tnunamak/dalan 0.8.5 → 0.9.2

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.
@@ -17,7 +17,7 @@ import { formatStatusSummary } from '../src/status-summary.mjs';
17
17
  import { explainMetrics } from '../src/lifecycle.mjs';
18
18
  import { normalizeMeta, metaFields, deriveObjectives } from '../src/objectives.mjs';
19
19
  import { legacyFixLedgerPath } from '../src/legacy-names.mjs';
20
- import { buildInbox, formatInbox, parseWhen, decideWords } from '../src/inbox.mjs';
20
+ import { buildInbox, formatInbox, parseWhen, decideWords, readInboxPages } from '../src/inbox.mjs';
21
21
  import { decideDrained, drainedExitCodes, terminal } from '../src/drained.mjs';
22
22
  import { takeSlot, releaseSlot } from '../src/drained-slot.mjs';
23
23
  import { liveWaiter } from '../src/drained-owner.mjs';
@@ -41,6 +41,7 @@ import { terminalSafe, jsonTerminalSafe } from '../src/terminal-safe.mjs';
41
41
  import { loadOwnerWorkers, parseWorkers, submitTarget, updateWorkerRepoPolicy, writeGenericProfile, writeLegacyMarker, readWorkerRepoHistory, seedWorkerRepos, inspectGrantAudit, ensureWorkerRelationship, AUDIT_INTEGRITY_HINT } from '../src/workers.mjs';
42
42
  import { adminSocketPathError, adminSocketPath } from '../src/admin-socket.mjs';
43
43
  import { answerThroughJournal } from '../src/answer-journal.mjs';
44
+ import { SESSION_ID, readJsonPrivate, sessionPath } from '../integrations/t3/acp-kit/src/session-store.mjs';
44
45
  // An answer reply that takes longer than this counts as lost; the journaled envelope is sent again.
45
46
  const ANSWER_TIMEOUT_MS=30000;
46
47
 
@@ -92,7 +93,7 @@ function bridgeNotRunning(error) {
92
93
  if(selected) return Object.assign(error,{message:`cannot reach the bridge: no bridge is running for DALAN_HOME=${selected} (${cause})`,fix:[`start the bridge for this home the way you set it up (${docsUrl('docs/manual-setup.md','owner-and-requester-setup')}), then run this command again`]});
93
94
  return Object.assign(error,{message:`cannot reach the bridge: DALAN_HOME is not set and no bridge is running in ${home} (${cause})`,fix:[`export DALAN_HOME=DIR for the bridge home you made, or start a trial bridge with: ${cli} try`]});
94
95
  }
95
- function request(route, method = 'GET', payload, headers={}, timeoutMs=30000) {
96
+ function request(route, method = 'GET', payload, headers={}, timeoutMs=30000, wallDeadline=false) {
96
97
  return new Promise((resolve, reject) => {
97
98
  const bytes = payload ? JSON.stringify(payload) : '';
98
99
  const transportFailure=error=>reject(Object.assign(error.syscall==='connect'&&['ENOENT','ECONNREFUSED'].includes(error.code)?bridgeNotRunning(error):error,{kind:'transport'}));
@@ -110,7 +111,11 @@ function request(route, method = 'GET', payload, headers={}, timeoutMs=30000) {
110
111
  else resolve(value);
111
112
  });
112
113
  });
113
- if(timeoutMs>0) req.setTimeout(timeoutMs,()=>req.destroy(Object.assign(new Error(`admin request timed out after ${timeoutMs} ms`),{code:'ETIMEDOUT'})));
114
+ if(timeoutMs>0) {
115
+ const expire=()=>req.destroy(Object.assign(new Error(`admin request timed out after ${timeoutMs} ms`),{code:'ETIMEDOUT'}));
116
+ if(wallDeadline) { const deadline=setTimeout(expire,timeoutMs); req.once('close',()=>clearTimeout(deadline)); }
117
+ else req.setTimeout(timeoutMs,expire);
118
+ }
114
119
  req.on('error',transportFailure); req.end(bytes);
115
120
  });
116
121
  }
@@ -163,12 +168,18 @@ function receipt(id) {
163
168
  }
164
169
  // A row the ACP adapter (T3 worker provider) submitted has no CLI receipt: its owner token is HMAC(acp-secret, request id).
165
170
  // Deriving it lets the T3 parent get, download, accept and reject that row. The bridge still checks the token.
166
- function acpReceipt(id) {
171
+ function acpOwnerSecret() {
167
172
  const file=process.env.DOT_ACP_SECRET_FILE||defaultPath(home,'.config/dot-bridge/acp-secret');
168
- let secret;
169
- try { if((fs.statSync(file).mode&0o777)!==0o600) return null; secret=fs.readFileSync(file,'utf8').trim(); } catch { return null; }
170
- if(secret.length<32) return null;
171
- return {request_id:id,token:createHmac('sha256',secret).update(id).digest('hex'),acp:true};
173
+ try {
174
+ if((fs.statSync(file).mode&0o777)!==0o600) return null;
175
+ const secret=fs.readFileSync(file,'utf8').trim();
176
+ return secret.length>=32?secret:null;
177
+ } catch { return null; }
178
+ }
179
+ const acpOwnerToken=(secret,id)=>createHmac('sha256',secret).update(id).digest('hex');
180
+ function acpReceipt(id) {
181
+ const secret=acpOwnerSecret();
182
+ return secret?{request_id:id,token:acpOwnerToken(secret,id),acp:true}:null;
172
183
  }
173
184
  function writeReceipt(id, token, body, delivery, review=false, background=false, meta=null, producer=null, routing=null, destinationRevisions=null, revises=null, follows=null, callerWaiting=false) {
174
185
  fs.mkdirSync(receipts,{recursive:true,mode:0o700});
@@ -272,6 +283,35 @@ function producerReceipts(producer,cache) {
272
283
  }
273
284
  return [...cache.values()].filter(Boolean);
274
285
  }
286
+ // Native sessions are a local discovery index, never proof of owner authority.
287
+ function nativeInboxReceipts(producer) {
288
+ const dir=process.env.DOT_ACP_STATE_DIR||defaultPath(home,'.local/state/dot-bridge/acp');
289
+ let files;
290
+ try { files=fs.readdirSync(dir,{withFileTypes:true}); }
291
+ catch(error) { if(error.code==='ENOENT') return []; throw error; }
292
+ const secret=acpOwnerSecret();
293
+ if(!secret) return [];
294
+ const owned=new Map();
295
+ for(const file of files) {
296
+ const sessionId=file.name.slice(0,-5);
297
+ if(!file.isFile()||!file.name.endsWith('.json')||!SESSION_ID.test(sessionId)) continue;
298
+ let saved;
299
+ try { saved=readJsonPrivate(sessionPath(dir,sessionId)); }
300
+ catch(error) { if(['invalid_session_state','state_permissions'].includes(error.code)) continue; throw error; }
301
+ if(saved?.id!==sessionId) continue;
302
+ const completed=Array.isArray(saved.completed)?saved.completed:[];
303
+ for(const work of [saved.pending,...completed]) {
304
+ const id=work?.rid;
305
+ if(typeof id!=='string'||!/^[-\w]{8,128}$/.test(id)||owned.has(id)) continue;
306
+ if(producer!==null&&producer!==sessionId&&producer!==work.original_host_task_id) continue;
307
+ if(fs.existsSync(receiptPath(id))) continue;
308
+ owned.set(id,{id,token:acpOwnerToken(secret,id)});
309
+ }
310
+ }
311
+ return [...owned.values()];
312
+ }
313
+ const peekInboxPage=(items,timeoutMs)=>request('/owner-states','POST',{items},{},timeoutMs,true);
314
+
275
315
  // A failure worth retrying: the bridge restarting (transport) or unavailable (5xx).
276
316
  const transient=e=>e.kind==='transport'||e.http_status>=500;
277
317
  // /owner-states is explicitly non-consuming. A bridge lacking it might also
@@ -316,9 +356,17 @@ async function inbox() {
316
356
  if(missing.length) throw new Error(`no receipt on this host for ${missing.join(', ')}`);
317
357
  return markInboxRead(ids.map(x=>byId.get(x)));
318
358
  }
359
+ if(!markRead) {
360
+ const owned=new Map(nativeInboxReceipts(producer).map(r=>[r.id,r]));
361
+ for(const receipt of receiptsInScope) owned.set(receipt.id,receipt);
362
+ const read=await readInboxPages([...owned.values()],peekInboxPage);
363
+ if(read.legacy) throw new Error('this bridge predates dalan inbox; update and restart it');
364
+ if(read.error) throw read.error;
365
+ if(read.partial_read) process.exitCode=1;
366
+ return {...buildInbox(read.states,scopeAll?'all':producer,{cutoff}),...(read.partial_read?{partial_read:read.partial_read}:{})};
367
+ }
319
368
  const read=await ownerStates(receiptsInScope,legacy);
320
369
  if(legacy.on) throw new Error('this bridge predates dalan inbox; update and restart it');
321
- if(!markRead) return buildInbox(read.states,scopeAll?'all':producer,{cutoff});
322
370
  const due=buildInbox(read.states,all?'all':producer).items.filter(i=>i.group!=='question'&&i.group!=='undecided'&&Date.parse(i.updated_at)<beforeCutoff);
323
371
  const byId=new Map(receiptsInScope.map(r=>[r.id,r]));
324
372
  return markInboxRead(due.map(i=>byId.get(i.request_id)));
@@ -572,6 +620,10 @@ async function main() {
572
620
  // scope paths dropped) are applied and the submit retried once only with --allow-scope-prune (--fix-scope is its old spelling).
573
621
  // The refused first submit stored nothing, so the same request_id and receipt stay valid.
574
622
  if(!(error.kind==='http'&&error.http_status===400&&error.suggested_scope_paths)) throw error;
623
+ if(body.read_paths!==undefined||body.read_list!==undefined) {
624
+ error.fix=['Correct the explicit read paths and scope_paths together in the assignment.'];
625
+ throw error;
626
+ }
575
627
  const was=body.scope_paths||[], added=error.suggested_scope_paths.filter(p=>!was.includes(p)), removed=was.filter(p=>!error.suggested_scope_paths.includes(p));
576
628
  const change=`${added.length?`added ${added.join(', ')}`:''}${added.length&&removed.length?'; ':''}${removed.length?`removed ${removed.join(', ')}`:''}`;
577
629
  if(!args.includes('--allow-scope-prune')&&!args.includes('--fix-scope')) {
@@ -624,13 +676,25 @@ async function main() {
624
676
  case 'status': {
625
677
  refuseUnknownOptions('status',{flags:['--json','--explain']});
626
678
  result = await request('/status');
679
+ let recoveryLine='';
680
+ const native=nativeInboxReceipts(producerId());
681
+ if(native.length) {
682
+ const recovery=await readInboxPages(native,peekInboxPage,{budgetMs:500});
683
+ if(!recovery.legacy) {
684
+ const available=buildInbox(recovery.states,'native').counts.finished_unread;
685
+ result={...result,native_results_available:available,
686
+ ...(recovery.partial_read?{native_recovery_partial:recovery.partial_read}:{})};
687
+ if(available) recoveryLine=`\n${available} unread native result(s) available (dalan inbox --all).`;
688
+ if(recovery.partial_read) recoveryLine+='\nNative inbox scan incomplete (dalan inbox --all).';
689
+ }
690
+ }
627
691
  if (args.includes('--explain')) {
628
692
  let metrics = null;
629
693
  try { metrics = await request('/metrics'); if (!metrics?.window) metrics = null; } catch { /* an older bridge has no /metrics */ }
630
694
  const explanation = explainStatus(result) + '\n' + (metrics ? explainMetrics(metrics) : 'metrics=unavailable');
631
695
  if (json) result = { ...result, explanation, ...(metrics ? { metrics } : {}) };
632
- else { result = explanation; plainOutput = true; }
633
- } else if (!json) { result = formatStatusSummary(result, { home, url: bridgeOrigin(), trial: fs.existsSync(path.join(home, '.dalan-trial')), cli, envHome: process.env.DALAN_HOME }); plainOutput = true; }
696
+ else { result = explanation+recoveryLine; plainOutput = true; }
697
+ } else if (!json) { result = formatStatusSummary(result, { home, url: bridgeOrigin(), trial: fs.existsSync(path.join(home, '.dalan-trial')), cli, envHome: process.env.DALAN_HOME })+recoveryLine; plainOutput = true; }
634
698
  break;
635
699
  }
636
700
  case 'tool': {
@@ -657,7 +721,17 @@ async function main() {
657
721
  post:envelope=>request('/answer','POST',envelope,owner(),ANSWER_TIMEOUT_MS),
658
722
  readQuestion:async()=>(await request('/questions?id='+encodeURIComponent(id),'GET',null,owner())).questions.find(q=>q.question_id===questionId)});
659
723
  break; }
660
- case 'tell': { const worker=option('--worker'),rest=args.filter((a,i)=>a!=='--worker'&&args[i-1]!=='--worker');if(rest.some(a=>a.startsWith('-')&&a!=='--json')) throw new Error('tell accepts --worker NAME and --json');const text=rest.filter(a=>a!=='--json').join(' ');if(!text) throw new Error('tell requires text');result=await request('/tell','POST',{text,...(worker?{worker}:{})});break; }
724
+ case 'tell': {
725
+ const worker=option('--worker'), work=option('--work'), valued=new Set(['--worker','--work']);
726
+ if((args.includes('--worker')&&!worker)||(args.includes('--work')&&!work)) throw new Error('tell options require a value');
727
+ const rest=args.filter((arg,index)=>!valued.has(arg)&&!valued.has(args[index-1])&&arg!=='--json');
728
+ if(rest.some(arg=>arg.startsWith('-'))) throw new Error('tell accepts --worker NAME, --work ID and --json');
729
+ const text=rest.join(' ');
730
+ if(!text) throw new Error('tell requires text');
731
+ const headers=work?{'x-owner-capability':receipt(work).token}:{};
732
+ result=await request('/tell','POST',{text,...(worker?{worker}:{}),...(work?{request_id:work}:{})},headers);
733
+ break;
734
+ }
661
735
  case 'untell': { const worker=option('--worker'),rest=args.filter((a,i)=>a!=='--worker'&&args[i-1]!=='--worker'&&a!=='--json');if(rest.length!==1||rest[0].startsWith('-')) throw new Error('untell requires message ID (optional --worker NAME, --json)');result=await request('/untell','POST',{message_id:rest[0],...(worker?{worker}:{})});break; }
662
736
  case 'audit': { const since=option('--since'); result=await request('/audit'+(since?'?since='+encodeURIComponent(since):''),'GET',null,{'x-operator-key':operator()}); break; }
663
737
  case 'pause': { const reason=option('--reason'); if(!reason) throw new Error('pause requires --reason'); result=await request('/pause','POST',{reason},{'x-operator-key':operator()}); break; }
@@ -125,6 +125,7 @@ When a peer speaks A2A, Dalan maps A2A task, message and artifact to work, quest
125
125
  - Priority classes: `normal` (queue, with an estimate) and `background` (queue behind normal), as stored today (`CHECK(priority IN ('normal','background'))`). A start-or-refuse class would need a schema and admission change; v2 does not add one. The parent gets the admission answer within seconds and can cancel and route elsewhere.
126
126
  - A free lane or a first claim is not a start. Today `queueWaitEvidence` (`src/store.mjs#queueWaitEvidence`) measures to the first stored claim and uses lower bounds for work that expired unclaimed. v2 measures two latencies: **claimed** (first claim) and **started** (the worker's first substantive event on the work, such as a workspace read or a progress event). Censored samples (expired or cancelled before a claim or a start) are counted in their own group and never mixed into the percentiles.
127
127
  - Admission answer, computed before submit with a defined stale-answer policy: `start: "now"` only when Dalan has reserved a lane for this work and the worker's subscription is live at that moment. Otherwise `start: "queued"` with the facts: eligible ready work ahead (count and oldest age, same or higher class), measured claimed and started latencies (p50/p90, n, window, censored count), and the worker state (`live`, `break until T`, `no live subscription`). Below the existing minimum of 5 samples (`QUEUE_WINDOW.minSamples`, `src/store.mjs#QUEUE_WINDOW`) it says `insufficient_history` and gives no number. Lower bounds from work that expired unclaimed are reported as their own group; today they are mixed into the percentiles, which understates waits.
128
+ - A preview reports a forecast. A normal waiting caller can reserve capacity for its request as part of a successful submit when it is the eligible queue head. The reservation expires at `reserved_until` after at most 15 seconds, and a delayed native reply displays it as queued. Replaying a submit does not extend a reservation. Claiming the request consumes the hold. Its claim and first substantive worker event remain separate measurements.
128
129
  - Track record, with outcomes kept apart: `unable_to_run`, `checks_failed`, `check_passed`, `landed` (merged or applied by the owner), plus `refused_by_provider`, n and window. "No passing check" is never reported as one blocked number.
129
130
  - `status.dispatch` stays as a simple diagnostic beside this answer (section 2).
130
131
  - No delegated-agent product shows a reliable ETA (see the prior-art list). Dalan reports only measured values with their basis, so a caller can judge them.
@@ -249,6 +249,23 @@ The service checks subscription lapse, missing active subscriptions, repeated ca
249
249
 
250
250
  Optional self-check timers are deployment-specific, so review their endpoint, issuer, TLS and repository assumptions before enabling them. For token and subscription lifetime guidance, see [connection longevity](connection-longevity.md).
251
251
 
252
+ ## Scoped-file grants for one assignment
253
+
254
+ Use the operator-authenticated local admin endpoint `POST /tools/grant` with
255
+ `name: "fetch_scoped_input"`, the exact `worker`, and a `scope` containing
256
+ `request_id`, `claim_id`, and ISO `expires_at`. Choose an expiration at or before
257
+ the current claim deadline. The assignment must already be claimed, read-only,
258
+ and pinned to a GitHub revision with explicitly approved files. Directory
259
+ expansion is refused for assignment grants.
260
+
261
+ Each chunk still requires the original live claim, its authenticated worker
262
+ and connection, and the current repository and file policy. The grant ends
263
+ at its own expiry even if the claim is renewed. A new claim or a changed
264
+ assignment requires a fresh grant. Use the existing operator revoke operation
265
+ to remove the grant earlier. A grant for a single assignment supersedes a
266
+ worker-wide grant on this tool. Revoke it before deliberately adding a
267
+ worker-wide grant. Older versions cannot use the assignment grant.
268
+
252
269
  ## Upgrade and rollback
253
270
 
254
271
  The package version is `0.6.0`; the bridge database schema is version 66. Stop the service and every other writer before making a backup or replacing files; keep them stopped until the complete backup set is captured. Keep each backup set consistent: include `<home>/.local/share/dalan/bridge.db`, `delivery-acks.db`, `notify-sent.db`, `<config>/dalan/as.sqlite` when built-in authorization is used, the private `<config>/dalan` files, owner receipts in `<home>/.local/share/dalan/receipts`, and artifact ownership entries in `<home>/.local/share/dalan/artifact-index`. Preserve file permissions. Do not copy either `bridge.db.secrets/owner.sqlite` or `as-owner.sqlite` lock database; recreate them locally after restoring with the service stopped, as described above. If external OAuth is used, its issuer database is managed separately and is not part of this bridge backup.
@@ -20,6 +20,8 @@ DOT_ACP_SOCKET=/path/to/admin.sock # the bridge's admin socket; the default is
20
20
 
21
21
  Add one entry for each worker, so a ChatGPT worker and Muse (muse.ai), a hosted cloud agent, each appear as a model. These adapter settings keep the `DOT_ACP_*` names. Builds also need `DALAN_ACP_BUILD_OWNERS`: see [Builds through the T3 worker provider](#builds-through-the-t3-worker-provider).
22
22
 
23
+ If the adapter exits before returning the result, the owner can find unread native work in `dalan inbox --all` from the requester host. Use the same bridge home and private adapter configuration. When the adapter's private state lives outside that bridge home, set `DOT_ACP_STATE_DIR` and `DOT_ACP_SECRET_FILE` to the matching local paths on the owner CLI. `dalan inbox --producer ID` accepts the saved ACP session ID or the original host task ID when the host supplies it. The inbox and the native result count in `dalan status` are passive reads. The count describes results available to this CLI. It does not confirm whether T3 accepted a completion before the adapter stopped.
24
+
23
25
  A separate, opt-in feature lets a worker list, read and write T3 threads. It gives the worker write and control access to your T3 threads, so read [T3 tools](t3-reverse-control.md) before you enable it.
24
26
 
25
27
  <a id="t3-task-thread-delivery"></a>
@@ -44,6 +46,10 @@ After verifying the destination, submit with `dalan submit --worker NAME --execu
44
46
 
45
47
  To send a corrected version of earlier work, add `--revises REQUEST_ID` and a new `--revision` (the same value as the earlier job is refused). `dalan submit` reads the earlier job's owner capability from its local receipt, so run it where the earlier job was submitted. It does not cancel the earlier job. A queued or running earlier job gets an owner note that it is superseded. When it finishes, `dalan get` shows `revised_by`, and `dalan decide`/`accept`/`apply` refuse it with `stale_revision`; the report stays readable as evidence, and `dalan decide ID not_useful` still works. A job that finished before the correction arrived is unchanged, and the correction is queued as new work. `--revises` cannot be combined with `--eligible` or `--policy`.
46
48
 
49
+ ## Scoped reviews through the T3 worker provider
50
+
51
+ Start a scoped review with `[dalan-read] OWNER/REPO@FULL_SHA path/to/file another/file` after any decision, priority or requirements lines. Put the review question below it. Dalan reads from the authorized repository revision and reports the accepted paths on admission and recovery. To change the revision or path list, start a new task.
52
+
47
53
  ## Builds through the T3 worker provider
48
54
 
49
55
  Builds never publish a branch for you. A refusal tells you whether to commit tracked edits or, if you are authorized to publish the revision, gives the exact ref to push before delegating again. The worker cannot open a file just because the brief names a path on your computer; paste only the text you are authorized to share.
@@ -37,14 +37,32 @@ function stripTrailingT3Blocks(text) {
37
37
 
38
38
  // runtimeInstructions.ts supplies this as a separate final text block, not part of the user's text. Check its generated
39
39
  // shape and recognizable copy before dropping it; never cut at an embedded tag.
40
+ const RUNTIME_INFO = /^<runtime_info>In case you're asked: you are running in T3 Code through the [^<>\n]+ harness[^<>\n]*\. No need to mention this otherwise\. You can embed (images and videos|images, video, and audio) in your response using Markdown with absolute file paths\.<\/runtime_info>$/;
41
+ const PR_LINKING = /^<pull_request_linking>\nWhen the t3-code MCP server exposes link_pull_request, you must use it to register every pull request [\s\S]+call unwatch_pull_request first so the thread returns to their inbox\.\n<\/pull_request_linking>$/;
42
+ const CURRENT_RUNTIME_INFO = /^<runtime_info>In case you're asked: you are running in T3 Code through the [^<>\r\n]+ harness(?:(?:, as | with )[^<>\r\n]+)?\. No need to mention this otherwise\. You can embed images, video, and audio(?: in your response)? using Markdown image syntax with absolute file paths\. (?:Link any other file you produce using its absolute path|Link every other file you cite or produce by its absolute path, as in \[http\.ts:42\]\(\/abs\/path\/http\.ts:42\),) so the user can open it in T3 Code's files viewer\.<\/runtime_info>$/;
43
+ // The newer footer uses literal placeholders in its example and adds a second line.
44
+ const CURRENT_PR_LINKING = /^<pull_request_linking>\n?Link each PR you create, take over, or push to:(?:[^<>\r\n]|<full URL>|<SHA>|<state>)* Before handback, call unwatch_pull_request on any PR you watch\.(?: When pull_request_\* tools are listed,[^<>\r\n]* pull_request_create links for you\.\nIf available, call link_issue for each issue you take on or file, even via CLI; skip issues you only read\.)?\n?<\/pull_request_linking>$/;
40
45
  export function isT3RuntimeBlock(text) {
41
- return /^<runtime_info>In case you're asked: you are running in T3 Code through the [^<>\n]+ harness[^<>\n]*\. No need to mention this otherwise\. You can embed images and videos in your response using Markdown with absolute file paths\.<\/runtime_info>\n\n<pull_request_linking>\nWhen the t3-code MCP server exposes link_pull_request, you must use it to register every pull request [\s\S]+call unwatch_pull_request first so the thread returns to their inbox\.\n<\/pull_request_linking>$/.test(text);
46
+ const split = text.indexOf('\n\n');
47
+ const finalInfo = split < 0 ? text : text.slice(0, split);
48
+ const info = RUNTIME_INFO.exec(finalInfo);
49
+ if (CURRENT_RUNTIME_INFO.test(finalInfo)) {
50
+ return split < 0 || CURRENT_PR_LINKING.test(text.slice(split + 2));
51
+ }
52
+ if (!info) return false;
53
+ if (split >= 0) return PR_LINKING.test(text.slice(split + 2));
54
+ // Newer T3 delegation can send runtime_info as its own full final block.
55
+ return info[1] === 'images, video, and audio';
42
56
  }
43
57
 
44
58
  // The user's text from a prompt's content blocks. One user block is never discarded, even if it looks like the runtime block.
45
59
  export function promptText(blocks) {
46
60
  const texts = blocks.filter(b => b.type === 'text').map(b => b.text);
47
- if (texts.length > 1 && isT3RuntimeBlock(texts.at(-1))) texts.pop();
61
+ if (texts.length > 2 && CURRENT_RUNTIME_INFO.test(texts.at(-2)) && CURRENT_PR_LINKING.test(texts.at(-1))) {
62
+ texts.splice(-2);
63
+ } else if (texts.length > 1 && isT3RuntimeBlock(texts.at(-1))) {
64
+ texts.pop();
65
+ }
48
66
  return unwrapUserRequest(texts.join('\n'));
49
67
  }
50
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tnunamak/dalan",
3
- "version": "0.8.5",
3
+ "version": "0.9.2",
4
4
  "description": "An MCP job bridge for bounded agent work, durable progress, results, and owner review.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,10 +1,10 @@
1
1
  # Adapter qualification
2
2
 
3
- A worker profile may name an `adapter`: `mcp` or `protocol-v0`. Omission means unqualified. This field is independent of the `t3` authority grant and of Gozar tunnel routes.
3
+ A worker profile may name an `adapter`: `mcp`, `protocol-v0`, or `registry-questions-v1`. Omission means unqualified. This field is independent of the `t3` authority grant and of Gozar tunnel routes.
4
4
 
5
5
  Records follow [the adapter schema](../contracts/adapter-qualification.schema.json), copied from the handoff schema with adapter naming. `yes` with a passing observation maps to `verified`; `no` with a passing observation maps to `unsupported`; everything else maps to `unknown`. Unknown capabilities never satisfy a submission requirement.
6
6
 
7
- `protocol-v0` qualifies identified question/answer/consume behavior through the local real-server fixture. Its declaration applies only with the `protocol-v0` catalog profile. `mcp` makes no verified capability claims. Neither record qualifies a hosted model, native session continuity, activation, or a worker sandbox. The source pin identifies the baseline exercised by the probe, rather than a live provider version.
7
+ `protocol-v0` qualifies identified question/answer/consume behavior through the local real-server fixture and applies only with the `protocol-v0` catalog profile. `registry-questions-v1` qualifies the keyed question path in the authenticated `batch-claim-v1` fixture. Admission requires current write grants for both `ask_question` and `consume_answer`. Its catalog fingerprint covers the granted registry tools returned to the fixture worker. `mcp` makes no verified capability claims. The records cover local fixtures. Hosted models, native session continuity, activation, and worker sandboxes remain unqualified. The source pins identify the probe baselines.
8
8
 
9
9
  Run `node scripts/qualification-gate-test.mjs` to validate the records, compare them with the runtime capability table, and rerun their observations. The gate refuses missing observations, failed probes, mismatched values, duplicate or missing capability names, and unbound evidence. Run `node scripts/adapter-qualification-test.mjs` to exercise actual `/submit` admission and inspect SQLite after refusals. `node scripts/pull-catalog-hash-test.mjs` pins the unchanged worker catalog for all profiles with T3 tools on and off.
10
10
 
@@ -0,0 +1,126 @@
1
+ {
2
+ "schema_version": 1,
3
+ "record_kind": "draft_internal_qualification_record_not_wire_protocol",
4
+ "adapter_id": "registry-questions-v1",
5
+ "observed_on": "2026-12-04",
6
+ "pins": {
7
+ "dalan_commit": "f9faa4805a4fa6d9f1831acad33559ebe9bff9a1",
8
+ "requester_ref": "private admin HTTP",
9
+ "worker_host_ref": "local authenticated batch-claim-v1 registry fixture",
10
+ "protocol": "batch-claim-v1",
11
+ "sdk": null,
12
+ "catalog_fingerprint": "57b24428f36fbf0a4d41afa186f64873a4fa17c6118281f683813f83cf769ddd"
13
+ },
14
+ "roles": [
15
+ "worker"
16
+ ],
17
+ "continuity": "unknown",
18
+ "activation": "unknown",
19
+ "capabilities": [
20
+ {
21
+ "name": "private_loopback",
22
+ "declared": "unknown",
23
+ "observed": "not_tested",
24
+ "required": false
25
+ },
26
+ {
27
+ "name": "host_loopback_denied",
28
+ "declared": "unknown",
29
+ "observed": "not_tested",
30
+ "required": false
31
+ },
32
+ {
33
+ "name": "lan_denied",
34
+ "declared": "unknown",
35
+ "observed": "not_tested",
36
+ "required": false
37
+ },
38
+ {
39
+ "name": "unix_sockets_denied",
40
+ "declared": "unknown",
41
+ "observed": "not_tested",
42
+ "required": false
43
+ },
44
+ {
45
+ "name": "credential_services_denied",
46
+ "declared": "unknown",
47
+ "observed": "not_tested",
48
+ "required": false
49
+ },
50
+ {
51
+ "name": "closed_inherited_fds",
52
+ "declared": "unknown",
53
+ "observed": "not_tested",
54
+ "required": false
55
+ },
56
+ {
57
+ "name": "read_scope_enforced",
58
+ "declared": "unknown",
59
+ "observed": "not_tested",
60
+ "required": false
61
+ },
62
+ {
63
+ "name": "write_scope_enforced",
64
+ "declared": "unknown",
65
+ "observed": "not_tested",
66
+ "required": false
67
+ },
68
+ {
69
+ "name": "full_tree_cancel_verified",
70
+ "declared": "unknown",
71
+ "observed": "not_tested",
72
+ "required": false
73
+ },
74
+ {
75
+ "name": "offline_transition_revokes_connections",
76
+ "declared": "unknown",
77
+ "observed": "not_tested",
78
+ "required": false
79
+ },
80
+ {
81
+ "name": "artifact_export_no_follow",
82
+ "declared": "unknown",
83
+ "observed": "not_tested",
84
+ "required": false
85
+ },
86
+ {
87
+ "name": "runner_observed_evidence",
88
+ "declared": "unknown",
89
+ "observed": "not_tested",
90
+ "required": false
91
+ },
92
+ {
93
+ "name": "native_darwin_execution",
94
+ "declared": "unknown",
95
+ "observed": "not_tested",
96
+ "required": false
97
+ },
98
+ {
99
+ "name": "immutable_input_snapshot",
100
+ "declared": "unknown",
101
+ "observed": "not_tested",
102
+ "required": false
103
+ },
104
+ {
105
+ "name": "identified_questions",
106
+ "declared": "yes",
107
+ "observed": "passed",
108
+ "required": false,
109
+ "evidence_refs": [
110
+ "scripts/adapter-qualification-test.mjs"
111
+ ]
112
+ }
113
+ ],
114
+ "qualification": {
115
+ "state": "passed_for_declared_scope",
116
+ "evidence_level": "actual_store_integration",
117
+ "run_refs": [
118
+ "scripts/adapter-qualification-test.mjs"
119
+ ]
120
+ },
121
+ "limits": [
122
+ "Applies only to batch-claim-v1 with current write grants for ask_question and consume_answer.",
123
+ "No live hosted-worker qualification or native session continuity or activation guarantee.",
124
+ "Sandbox capabilities remain unknown. Host execution keeps its separate backend admission."
125
+ ]
126
+ }