@genobank/biofs 3.20.6 → 3.20.8

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.
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ /**
3
+ * biofs imaging register | register-status
4
+ *
5
+ * Staged 3D registration of N CT timepoints into one reference frame, with a quality
6
+ * gate, dispatched through biofs-node to the GPU executor. For every non-reference
7
+ * timepoint the executor aligns coarse to fine: a rigid fit to the vertebrae segmented
8
+ * consistently in both scans, rigid refinement on the vertebral column, then a piecewise
9
+ * deformable stage in which the lungs, the viscera that move with the diaphragm (heart and
10
+ * abdominal organs) and the rest of the body are registered separately, so organs can slide
11
+ * against the rib cage. Each stage is
12
+ * measured: surface distance of the whole spine, of each lung, of the liver and of the
13
+ * spleen, per-structure Dice from TotalSegmentator masks,
14
+ * vertebral landmark error, Jacobian folding, bone rigidity, and, with three or more
15
+ * timepoints, agreement of A->B->C with A->C. The gate verdict (PASS, PASS_WITH_WARNINGS,
16
+ * FAIL) is computed against thresholds written into the result, so a later lesion or
17
+ * organ comparison knows how far the alignment can be trusted.
18
+ *
19
+ * biofs-node checks that every study belongs to the signer and picks each series by
20
+ * comparability with the reference (axial, original, soft-tissue kernel, closest
21
+ * thickness, same kernel family), recording why. Pass --series to override.
22
+ *
23
+ * Flow:
24
+ * POST /api_biofs_node/submit_imaging_register {signature, timepoints, reference, anatomy, protocol_mode}
25
+ * GET /api_biofs_node/imaging_register_status?register_job_id=... (owner signature in a header)
26
+ */
27
+ var __importDefault = (this && this.__importDefault) || function (mod) {
28
+ return (mod && mod.__esModule) ? mod : { "default": mod };
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.imagingRegisterCommand = imagingRegisterCommand;
32
+ exports.imagingRegisterStatusCommand = imagingRegisterStatusCommand;
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ const ora_1 = __importDefault(require("ora"));
35
+ const axios_1 = __importDefault(require("axios"));
36
+ const credentials_1 = require("../../lib/auth/credentials");
37
+ const logger_1 = require("../../lib/utils/logger");
38
+ const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
39
+ || `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
40
+ /** Parse repeated `label=value` options in the order given. */
41
+ function parsePairs(values, what) {
42
+ return (values || []).map((v) => {
43
+ const i = v.indexOf('=');
44
+ if (i <= 0 || i === v.length - 1)
45
+ throw new Error(`${what} must be label=value (got "${v}")`);
46
+ return { label: v.slice(0, i).trim(), value: v.slice(i + 1).trim() };
47
+ });
48
+ }
49
+ function printRow(row) {
50
+ console.log(chalk_1.default.bold(`register job ${row.register_job_id}: ${row.status}`));
51
+ for (const t of row.timepoints || []) {
52
+ const sel = t.selection || {};
53
+ console.log(` ${t.label.padEnd(10)} ${t.study_date || '????????'} ${(sel.description || '').padEnd(26).slice(0, 26)} ${sel.kernel || ''} ${sel.thickness_mm ?? ''} mm`
54
+ + (t.label === row.reference ? chalk_1.default.cyan(' (reference)') : ''));
55
+ }
56
+ const r = row.result;
57
+ if (!r)
58
+ return;
59
+ if (r.error) {
60
+ console.log(chalk_1.default.red(` error: ${r.error}`));
61
+ return;
62
+ }
63
+ const verdict = r.gate?.verdict || '?';
64
+ const color = verdict === 'PASS' ? chalk_1.default.green : verdict === 'FAIL' ? chalk_1.default.red : chalk_1.default.yellow;
65
+ console.log(` gate: ${color(verdict)} protocol: ${r.protocol_mode} transitivity Dice: ${r.transitivity ?? '-'}`);
66
+ for (const p of r.pairs || []) {
67
+ const d = p.deformable || {};
68
+ const pc = p.verdict === 'PASS' ? chalk_1.default.green : p.verdict === 'FAIL' ? chalk_1.default.red : chalk_1.default.yellow;
69
+ console.log(` ${p.pair.padEnd(18)} ${pc(p.verdict.padEnd(18))} spine ${d.spine_assd_mm ?? '-'} mm (HD95 ${d.spine_hd95_mm ?? '-'}) `
70
+ + `lungs Dice ${d.lung_dice_min ?? '-'}, HD95 ${d.lung_hd95_max_mm ?? '-'} mm liver/spleen HD95 ${d.abdominal_organ_hd95_max_mm ?? '-'} mm `
71
+ + `heart ${d.heart_dice ?? '-'} folds ${d.jacobian_fold_fraction ?? '-'}`);
72
+ for (const h of p.hard_failures || [])
73
+ console.log(chalk_1.default.red(` fail: ${h}`));
74
+ for (const w of p.warnings || [])
75
+ console.log(chalk_1.default.yellow(` warn: ${w}`));
76
+ }
77
+ if (r.gate?.note)
78
+ console.log(chalk_1.default.yellow(` ${r.gate.note}`));
79
+ if (row.output_biocid)
80
+ console.log(chalk_1.default.gray(` biocid: ${row.output_biocid}`));
81
+ }
82
+ async function fetchStatus(jobId, signature) {
83
+ const resp = await axios_1.default.get(`${BIOFS_NODE_BASE}/imaging_register_status`, {
84
+ params: { register_job_id: jobId },
85
+ headers: { 'x-biofs-signature': signature },
86
+ timeout: 30000, validateStatus: (s) => s < 500,
87
+ });
88
+ return { status: resp.status, data: resp.data };
89
+ }
90
+ async function waitFor(jobId, signature, quiet) {
91
+ const spin = quiet ? null : (0, ora_1.default)(`waiting for register job ${jobId} on the GPU executor ...`).start();
92
+ // A wrong id or a job of another wallet fails at once; after the job has answered once, a dropped
93
+ // connection or an error reply (the node also answers 403 when it briefly cannot recover the signer)
94
+ // is retried for about 10 minutes before the wait gives up.
95
+ const first = await fetchStatus(jobId, signature);
96
+ if (first.status >= 400) {
97
+ spin?.fail(`imaging_register_status ${first.status}: ${first.data?.error || 'unknown'}`);
98
+ return null;
99
+ }
100
+ if (first.data.status === 'done' || first.data.status === 'error') {
101
+ if (first.data.status === 'done')
102
+ spin?.succeed(`register job done: gate ${first.data.result?.gate?.verdict}`);
103
+ else
104
+ spin?.fail(`register job error: ${first.data.error || first.data.result?.error || 'unknown'}`);
105
+ return first.data;
106
+ }
107
+ const deadline = Date.now() + 3 * 60 * 60000; // 3 h ceiling
108
+ let failures = 0;
109
+ while (Date.now() < deadline) {
110
+ await new Promise((r) => setTimeout(r, 20000));
111
+ let status = 0;
112
+ let data = {};
113
+ let problem = '';
114
+ try {
115
+ ({ status, data } = await fetchStatus(jobId, signature));
116
+ if (status >= 400)
117
+ problem = `imaging_register_status ${status}: ${data?.error || 'unknown'}`;
118
+ }
119
+ catch (e) {
120
+ problem = `imaging_register_status unreachable: ${e?.message || e}`;
121
+ }
122
+ if (problem) {
123
+ if (++failures >= 30) {
124
+ spin?.fail(problem);
125
+ return null;
126
+ }
127
+ if (spin)
128
+ spin.text = `register job ${jobId}: ${problem}, retrying`;
129
+ continue;
130
+ }
131
+ failures = 0;
132
+ if (data.status === 'done' || data.status === 'error') {
133
+ if (data.status === 'done')
134
+ spin?.succeed(`register job done: gate ${data.result?.gate?.verdict}`);
135
+ else
136
+ spin?.fail(`register job error: ${data.error || data.result?.error || 'unknown'}`);
137
+ return data;
138
+ }
139
+ if (spin)
140
+ spin.text = `register job ${jobId}: ${data.status}`;
141
+ }
142
+ spin?.warn('wait timeout; the job may still be running. Check with: biofs imaging register-status ' + jobId);
143
+ return null;
144
+ }
145
+ async function imagingRegisterCommand(options = {}) {
146
+ const spinner = options.quiet || options.json ? null : (0, ora_1.default)('biofs imaging register → biofs-node').start();
147
+ try {
148
+ const tps = parsePairs(options.tp, '--tp');
149
+ if (tps.length < 2) {
150
+ spinner?.fail('give at least two timepoints: --tp <label>=<StudyInstanceUID or dicom biocid> (in time order)');
151
+ process.exit(1);
152
+ }
153
+ const series = new Map(parsePairs(options.series, '--series').map((s) => [s.label, s.value]));
154
+ for (const l of series.keys())
155
+ if (!tps.some((t) => t.label === l))
156
+ throw new Error(`--series ${l}=... names no --tp label`);
157
+ const credentials = await (0, credentials_1.getCredentials)();
158
+ if (!credentials) {
159
+ spinner?.fail('Not authenticated. Run: biofs login');
160
+ process.exit(1);
161
+ }
162
+ const body = {
163
+ wallet: credentials.wallet_address,
164
+ signature: credentials.user_signature,
165
+ anatomy: options.anatomy || 'chest',
166
+ reference: options.reference || tps[0].label,
167
+ protocol_mode: options.protocolMode || 'auto',
168
+ timepoints: tps.map((t) => ({ label: t.label, study: t.value, ...(series.get(t.label) ? { series: series.get(t.label) } : {}) })),
169
+ };
170
+ const resp = await axios_1.default.post(`${BIOFS_NODE_BASE}/submit_imaging_register`, body, { timeout: 120000, validateStatus: (s) => s < 500 });
171
+ if (resp.status >= 400) {
172
+ spinner?.fail(`submit_imaging_register ${resp.status}: ${resp.data?.error || 'unknown'}`);
173
+ if (options.json)
174
+ console.log(JSON.stringify(resp.data, null, 2));
175
+ return null;
176
+ }
177
+ const sub = resp.data;
178
+ spinner?.succeed(`register_job_id=${sub.register_job_id} (${(sub.timepoints || []).length} timepoints, reference ${sub.reference})`);
179
+ if (!options.json && !options.quiet) {
180
+ for (const t of sub.timepoints || []) {
181
+ const why = (t.selection?.rationale || []).join('; ');
182
+ console.log(chalk_1.default.gray(` ${t.label}: ${t.selection?.description} (${t.selection?.kernel}, ${t.selection?.thickness_mm} mm): ${why}`));
183
+ }
184
+ }
185
+ if (!options.wait) {
186
+ if (options.json)
187
+ console.log(JSON.stringify(sub, null, 2));
188
+ else if (!options.quiet)
189
+ console.log(chalk_1.default.cyan(` follow with: biofs imaging register-status ${sub.register_job_id} --wait`));
190
+ return sub.register_job_id;
191
+ }
192
+ const row = await waitFor(sub.register_job_id, credentials.user_signature, options.quiet || options.json);
193
+ if (row) {
194
+ if (options.json)
195
+ console.log(JSON.stringify(row, null, 2));
196
+ else if (!options.quiet)
197
+ printRow(row);
198
+ }
199
+ return sub.register_job_id;
200
+ }
201
+ catch (err) {
202
+ const msg = err?.response?.data?.error || err?.message || String(err);
203
+ spinner?.fail(`imaging register failed: ${msg}`);
204
+ logger_1.Logger.error(`imaging register failed: ${msg}`);
205
+ return null;
206
+ }
207
+ }
208
+ async function imagingRegisterStatusCommand(jobId, options = {}) {
209
+ try {
210
+ const credentials = await (0, credentials_1.getCredentials)();
211
+ if (!credentials) {
212
+ console.error('Not authenticated. Run: biofs login');
213
+ process.exit(1);
214
+ }
215
+ let row;
216
+ if (options.wait)
217
+ row = await waitFor(jobId, credentials.user_signature, options.quiet || options.json);
218
+ else {
219
+ const { status, data } = await fetchStatus(jobId, credentials.user_signature);
220
+ if (status >= 400) {
221
+ console.error(chalk_1.default.red(`imaging_register_status ${status}: ${data?.error || 'unknown'}`));
222
+ return null;
223
+ }
224
+ row = data;
225
+ }
226
+ if (row) {
227
+ if (options.json)
228
+ console.log(JSON.stringify(row, null, 2));
229
+ else if (!options.quiet)
230
+ printRow(row);
231
+ }
232
+ return row;
233
+ }
234
+ catch (err) {
235
+ const msg = err?.response?.data?.error || err?.message || String(err);
236
+ logger_1.Logger.error(`imaging register-status failed: ${msg}`);
237
+ return null;
238
+ }
239
+ }
240
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/commands/imaging/register.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;AAgIH,wDA8CC;AAED,oEAkBC;AAhMD,kDAA0B;AAC1B,8CAAsB;AACtB,kDAA0B;AAC1B,4DAA4D;AAC5D,mDAAgD;AAmBhD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc;OAC7C,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,sBAAsB,iBAAiB,CAAC;AAkBhF,+DAA+D;AAC/D,SAAS,UAAU,CAAC,MAA4B,EAAE,IAAY;IAC5D,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,8BAA8B,CAAC,IAAI,CAAC,CAAC;QAC9F,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CA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CAAC;gBAAC,OAAO,IAAI,CAAC;YAAC,CAAC;YACxI,GAAG,GAAG,IAAI,CAAC;QACb,CAAC;QACD,IAAI,GAAG,EAAE,CAAC;YAAC,IAAI,OAAO,CAAC,IAAI;gBAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;iBAAM,IAAI,CAAC,OAAO,CAAC,KAAK;gBAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;QACjH,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,IAAI,GAAG,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;QACtE,eAAM,CAAC,KAAK,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/index.js CHANGED
@@ -91,6 +91,7 @@ const characterize_1 = require("./commands/imaging/characterize");
91
91
  const enrich_1 = require("./commands/imaging/enrich");
92
92
  const compare_1 = require("./commands/imaging/compare");
93
93
  const reconcile_1 = require("./commands/imaging/reconcile");
94
+ const register_2 = require("./commands/imaging/register");
94
95
  const submit_3 = require("./commands/methyl/submit");
95
96
  const exec_1 = require("./commands/methyl/exec");
96
97
  const submit_4 = require("./commands/align-shard/submit");
@@ -149,6 +150,7 @@ const resolve_1 = require("./commands/resolve");
149
150
  const variants_1 = require("./commands/variants");
150
151
  const query_1 = require("./commands/query");
151
152
  const erase_1 = require("./commands/erase");
153
+ const erase_trial_1 = require("./commands/erase-trial");
152
154
  const fourier_score_1 = require("./commands/fourier-score");
153
155
  const rrm_consensus_1 = require("./commands/rrm-consensus");
154
156
  const psm_consensus_1 = require("./commands/psm-consensus");
@@ -184,7 +186,7 @@ const cohort_pipeline_1 = require("./commands/cohort-pipeline");
184
186
  const dedup_1 = require("./commands/dedup");
185
187
  const claim_1 = require("./commands/claim");
186
188
  const fingerprint_1 = require("./commands/fingerprint");
187
- const register_2 = require("./commands/researcher/register");
189
+ const register_3 = require("./commands/researcher/register");
188
190
  const status_9 = require("./commands/researcher/status");
189
191
  const passport_1 = require("./commands/researcher/passport");
190
192
  const errorReporter_1 = require("./utils/errorReporter");
@@ -1347,6 +1349,45 @@ imagingCmd
1347
1349
  process.exit(1);
1348
1350
  }
1349
1351
  });
1352
+ // imaging register — staged 3D registration of N CT timepoints into one reference
1353
+ // frame with a quality gate (rigid on bone -> affine -> SyN, QC per stage, transitivity),
1354
+ // on the GPU executor via biofs-node.
1355
+ const collect = (v, prev) => prev.concat([v]);
1356
+ imagingCmd
1357
+ .command('register')
1358
+ .description('Register CT timepoints into one reference frame with a quality gate (GPU via biofs-node)')
1359
+ .requiredOption('--tp <label=study>', 'timepoint as label=StudyInstanceUID or label=dicom biocid, in time order (repeat)', collect, [])
1360
+ .option('--series <label=series>', 'override the series biofs-node picks for one timepoint (repeat)', collect, [])
1361
+ .option('--reference <label>', 'timepoint whose frame the others are registered into (default: the first)')
1362
+ .option('--anatomy <name>', 'chest | abdomen', 'chest')
1363
+ .option('--protocol-mode <mode>', 'auto | same | cross (auto compares the acquisitions)', 'auto')
1364
+ .option('--wait', 'Wait for the GPU job and print the gate')
1365
+ .option('--quiet', 'Suppress progress output')
1366
+ .option('--json', 'Output as JSON')
1367
+ .action(async (options) => {
1368
+ try {
1369
+ await (0, register_2.imagingRegisterCommand)(options);
1370
+ }
1371
+ catch (error) {
1372
+ logger_1.Logger.error(`imaging register failed: ${error}`);
1373
+ process.exit(1);
1374
+ }
1375
+ });
1376
+ imagingCmd
1377
+ .command('register-status <registerJobId>')
1378
+ .description('Status and quality gate of an imaging register job')
1379
+ .option('--wait', 'Wait until the job finishes')
1380
+ .option('--quiet', 'Suppress progress output')
1381
+ .option('--json', 'Output as JSON')
1382
+ .action(async (registerJobId, options) => {
1383
+ try {
1384
+ await (0, register_2.imagingRegisterStatusCommand)(registerJobId, options);
1385
+ }
1386
+ catch (error) {
1387
+ logger_1.Logger.error(`imaging register-status failed: ${error}`);
1388
+ process.exit(1);
1389
+ }
1390
+ });
1350
1391
  // Workspace commands — the shared intra-LLM case workspace (append-only,
1351
1392
  // hash-chained log that Claude Code + Grok Build co-edit via biofs-node).
1352
1393
  const workspaceCmd = program
@@ -3064,7 +3105,7 @@ researcherCmd
3064
3105
  .option('--provider <provider>', 'Force a specific provider (orcid, google, linkedin, twitter, apple, metamask)')
3065
3106
  .action(async (options) => {
3066
3107
  try {
3067
- await (0, register_2.researcherRegisterCommand)(options);
3108
+ await (0, register_3.researcherRegisterCommand)(options);
3068
3109
  }
3069
3110
  catch (error) {
3070
3111
  logger_1.Logger.error(`Researcher registration failed: ${error}`);
@@ -3757,6 +3798,32 @@ program
3757
3798
  process.exit(1);
3758
3799
  }
3759
3800
  });
3801
+ // erase-trial — exercise GDPR Art. 17 erasure end to end on a synthetic biosample
3802
+ const eraseTrial = program
3803
+ .command('erase-trial')
3804
+ .description('Exercise biofs erase end to end on a SYNTHETIC biosample (no real biodata): build, grant, read, erase, re-check');
3805
+ eraseTrial
3806
+ .command('run')
3807
+ .description('Build a synthetic serial, grant it, read it, erase it, and record what remains')
3808
+ .option('--json', 'Output the full report as JSON')
3809
+ .action(async (options) => { await (0, erase_trial_1.eraseTrialRunCommand)(options); });
3810
+ eraseTrial
3811
+ .command('grantee')
3812
+ .description('Grant a synthetic biosample to a throwaway grantee wallet, revoke it, and record who is refused while the data remain available (nothing is erased)')
3813
+ .option('--json', 'Output the full report as JSON')
3814
+ .action(async (options) => { await (0, erase_trial_1.eraseTrialGranteeCommand)(options); });
3815
+ eraseTrial
3816
+ .command('inspect <serial>')
3817
+ .description('Report what still exists for an erase-trial serial')
3818
+ .action(async (serial, options) => { await (0, erase_trial_1.eraseTrialNodeCommand)('inspect', serial, options); });
3819
+ eraseTrial
3820
+ .command('cleanup <serial>')
3821
+ .description('Remove what erase left behind for an erase-trial serial (synthetic rows and generations only)')
3822
+ .action(async (serial, options) => { await (0, erase_trial_1.eraseTrialNodeCommand)('cleanup', serial, options); });
3823
+ eraseTrial
3824
+ .command('read <serial>')
3825
+ .description('One gated read of an erase-trial object as the signer, recording the gate decision (403 refused; 500 with storage not-found = admitted, bytes gone)')
3826
+ .action(async (serial, options) => { await (0, erase_trial_1.eraseTrialReadCommand)(serial, options); });
3760
3827
  program
3761
3828
  .command('query <target> [sql]')
3762
3829
  .description('Consent-gated read-only SQL over a queryable-biodata sqlite (biocid or biosample); the sqlite never leaves prod, only rows transit')