feat: let the coordinator see the relationship graph
The graph has been built for months and fed nothing but a dashboard. Nothing in the autonomy pipeline has ever read an edge: not the coordinator, not calibration, not execution. Its only downstream consumer, trade_signals, last produced anything in April. It was roughly 70% of the llm bill and informed no prediction, decision or order. Relationships are the one piece of context a per-event coordinator genuinely cannot derive from its own articles, because "this company supplies that one" is knowledge about companies rather than about this event. So the coordinator now receives the relationships of the companies the event is about, and is told to name the relationship in causal_channel when it reasons through one. The cutoff filter is the part that matters. first_seen_at on a relationship is derived from article dates rather than processing time, so a historical proposal only sees what the world had actually revealed by its own cutoff. Without that this feature would quietly reintroduce the lookahead the evidence check exists to prevent, and it is pinned by a test rather than left to review. Relationships are explicitly background rather than evidence: predictions still have to cite the article ids the story came from, and an instrument the articles give no reason to care about is still not a prediction. strategy_version moves to autonomy-2, because a prompt change this material changes what a prediction means and the two populations should be comparable later rather than silently blended. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WnNxwxfXSbeNtjvtz5gayb
This commit is contained in:
@@ -7,9 +7,14 @@ const { leaseNextJob, completeJob, failJob } = require('../src/autonomy/jobs');
|
||||
const { callCoordinator } = require('../src/autonomy/llm');
|
||||
const { acceptProposal, recordRejectedProposal, INSTRUMENT_RULES } = require('../src/autonomy/coordinator');
|
||||
const { EVENT_FAMILY_NAMES } = require('../src/autonomy/calibration');
|
||||
const { buildGraphContext } = require('../src/autonomy/graphContext');
|
||||
|
||||
function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
||||
|
||||
// bumped when the prompt changes in a way that changes what a prediction means.
|
||||
// autonomy-2 is the first version that can see the relationship graph.
|
||||
const STRATEGY_VERSION = 'autonomy-2';
|
||||
|
||||
function loadConfig() {
|
||||
const configPath = path.resolve(process.env.DURIIN_CONFIG || path.join(__dirname, '..', 'config.json'));
|
||||
const raw = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
@@ -20,11 +25,11 @@ function loadConfig() {
|
||||
return raw;
|
||||
}
|
||||
|
||||
function buildPrompt(event, articles) {
|
||||
function buildPrompt(event, articles, graphContext = '') {
|
||||
const evidence = articles.map((article, index) =>
|
||||
`[Evidence ${index + 1}] article_id=${article.id}\nTitle: ${article.title}\n${String(article.content || article.description || '').slice(0, 4000)}`
|
||||
).join('\n\n---\n\n');
|
||||
return `Event title: ${event.title}\n\n${evidence}\n\nReturn JSON only in this shape:\n${JSON.stringify({ predictions: [{
|
||||
return `Event title: ${event.title}\n\n${evidence}\n\n${graphContext ? `${graphContext}\n\n` : ''}Return JSON only in this shape:\n${JSON.stringify({ predictions: [{
|
||||
instrument: '<ticker supported by the articles>', direction: '<positive or negative>',
|
||||
event_type: '<one value from the event_type list below>',
|
||||
causal_channel: '<short description>', horizon_days: '<one of 1, 5, 10, 20, 30, 60, 90>',
|
||||
@@ -60,14 +65,15 @@ async function runCoordinatorWorker({ archivePath, intelligencePath, workerId =
|
||||
const informationCutoff = historical
|
||||
? (articles.map((article) => article.pub_date_effective).filter(Boolean).sort().pop() || new Date().toISOString())
|
||||
: new Date().toISOString();
|
||||
const raw = await callCoordinator(config, buildPrompt(event, articles));
|
||||
const graphContext = buildGraphContext(intelligenceDb, event.id, informationCutoff);
|
||||
const raw = await callCoordinator(config, buildPrompt(event, articles, graphContext));
|
||||
try {
|
||||
acceptProposal(intelligenceDb, archiveDb, raw, {
|
||||
eventId: event.id,
|
||||
informationCutoff,
|
||||
model: config.openRouter.llmModel || 'unknown',
|
||||
promptVersion: 'coordinator-1',
|
||||
strategyVersion: 'autonomy-1',
|
||||
strategyVersion: STRATEGY_VERSION,
|
||||
// only a genuine live lane job may ever feed learning
|
||||
origin: historical ? 'historical' : 'live',
|
||||
learningEligible: !historical,
|
||||
|
||||
Reference in New Issue
Block a user