Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ Inspect a node:
npx kalaris-myriad show MYR-D051-T041
```

Route a natural-language request to one bounded task without claiming scientific completion:

```bash
node examples/task-router.js "variant-aware off-target assessment"
```

The example returns the selected node's objective, required evidence, and qualified-review
boundary as structured JSON.

Export a domain:

```bash
Expand Down
46 changes: 46 additions & 0 deletions examples/task-router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node
import { execFileSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const cli = path.join(root, 'bin', 'kalaris-myriad.js');
function main() {
const request = process.argv.slice(2).join(' ').trim();

if (!request) {
console.error('Usage: node examples/task-router.js <biotech request>');
process.exitCode = 1;
return;
}

const candidates = JSON.parse(execFileSync(process.execPath, [
cli, 'search', request, '--limit', '1', '--json'
], { cwd: root, encoding: 'utf8' }));

if (candidates.length === 0) {
console.log(JSON.stringify({ status: 'no-route', request, task: null }, null, 2));
process.exitCode = 0;
return;
}

const task = candidates[0];
console.log(JSON.stringify({
status: 'routed',
request,
task: {
id: task.id,
routing_name: task.routing.name,
objective: task.objective,
expected_evidence: task.execution_contract.required_completion_evidence,
review_boundary: {
mode: task.execution_contract.mode,
human_review_required: task.execution_contract.human_review_required,
no_call_when: task.execution_contract.no_call_when,
scientific_validation_claim: task.maturity.scientific_validation_claim
}
}
}, null, 2));
}

main();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"schemas/",
"docs/",
"explorer/",
"examples/",
"README.md",
"CREDITS.md",
"NOTICE.md",
Expand Down
31 changes: 31 additions & 0 deletions tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fileURLToPath } from 'node:url';

const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const cli = path.join(root, 'bin', 'kalaris-myriad.js');
const router = path.join(root, 'examples', 'task-router.js');
function run(args) {
const r = spawnSync(process.execPath, [cli, ...args], { cwd: root, encoding: 'utf8' });
assert.equal(r.status, 0, r.stderr || r.stdout);
Expand Down Expand Up @@ -37,3 +38,33 @@ test('CLI validator passes', () => {
assert.equal(data.status, 'PASS');
assert.equal(data.task_count, 10000);
});

test('task router returns a bounded route without claiming completion', () => {
const result = spawnSync(process.execPath, [router, 'variant', 'off-target'], {
cwd: root,
encoding: 'utf8'
});
assert.equal(result.status, 0, result.stderr || result.stdout);
const data = JSON.parse(result.stdout);
assert.equal(data.status, 'routed');
assert.match(data.task.id, /^MYR-/);
assert.equal(data.task.review_boundary.mode, 'computational-advisory');
assert.equal(data.task.review_boundary.human_review_required, true);
assert.equal(data.task.review_boundary.scientific_validation_claim, 'none');
assert.ok(data.task.expected_evidence.length > 0);
assert.equal('completed' in data, false);
});

test('task router emits complete JSON when no route matches', () => {
const request = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
const result = spawnSync(process.execPath, [router, request], {
cwd: root,
encoding: 'utf8'
});
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.deepEqual(JSON.parse(result.stdout), {
status: 'no-route',
request,
task: null
});
});