feat: add isolated historical replay calibration
This commit is contained in:
@@ -53,6 +53,26 @@ test('accepted proposal preserves evidence and creates immutable prediction', ()
|
||||
assert.deepEqual(JSON.parse(intelligence.prepare('SELECT evidence_article_ids FROM autonomy_predictions').get().evidence_article_ids), [7]);
|
||||
});
|
||||
|
||||
test('replay evidence cannot look beyond its information cutoff and remains non-executable', () => {
|
||||
const archive = new Database(':memory:');
|
||||
archive.exec('CREATE TABLE articles (id INTEGER PRIMARY KEY, pub_date_effective TEXT, pub_date TEXT, ingested_at TEXT)');
|
||||
archive.prepare("INSERT INTO articles VALUES (7, '2020-01-01T00:00:00Z', NULL, '2020-01-01T00:00:00Z')").run();
|
||||
const intelligence = new Database(':memory:');
|
||||
initAutonomySchema(intelligence);
|
||||
intelligence.prepare("INSERT INTO autonomy_instruments(symbol, broker, active, tradable) VALUES ('NVDA', 'test', 1, 1)").run();
|
||||
assert.throws(() => acceptProposal(intelligence, archive, {
|
||||
predictions: [{ instrument: 'NVDA', direction: 'positive', event_type: 'earnings', horizon_days: 10, evidence_article_ids: [7] }],
|
||||
}, { informationCutoff: '2019-12-31T00:00:00Z', origin: 'replay', replayRunId: 1 }), /missing evidence/);
|
||||
const proposal = intelligence.prepare("INSERT INTO autonomy_proposals(payload, information_cutoff, status) VALUES ('{}', datetime('now'), 'accepted')").run();
|
||||
const prediction = intelligence.prepare(`INSERT INTO autonomy_predictions
|
||||
(proposal_id, instrument, direction, event_type, horizon_days, information_cutoff, evidence_article_ids, strategy_version, origin)
|
||||
VALUES (?, 'NVDA', 'positive', 'test', 10, datetime('now'), '[7]', 'test', 'replay')`).run(proposal.lastInsertRowid);
|
||||
intelligence.prepare("INSERT INTO autonomy_decisions(prediction_id, action, rationale, strategy_version) VALUES (?, 'BUY', 'test', 'test')").run(prediction.lastInsertRowid);
|
||||
const executable = intelligence.prepare(`SELECT d.id FROM autonomy_decisions d JOIN autonomy_predictions p ON p.id=d.prediction_id
|
||||
WHERE d.action IN ('BUY','SELL') AND p.origin='live'`).all();
|
||||
assert.equal(executable.length, 0);
|
||||
});
|
||||
|
||||
test('calibration and policy abstain on insufficient evidence', () => {
|
||||
const calibration = calibrateOutcomes([
|
||||
{ excess_return: 0.02, direction_correct: 1 },
|
||||
|
||||
Reference in New Issue
Block a user