(options)
| 335 | midRun: (data.loops || []).some((loop) => !['done', 'stopped', 'verifier-passed'].includes(loop.status || (loop.state && loop.state.status))), |
| 336 | }); |
| 337 | const hooksState = inspectDirectory(projectRoot, '.planning/telemetry', { |
| 338 | filter: (name) => /^(hook-timing|hook-errors|audit|agent-runs|task-events)\.jsonl$/.test(name), jsonl: true, |
| 339 | }); |
| 340 | const handoffsState = inspectDirectory(projectRoot, '.planning/handoffs', { filter: (name) => name.endsWith('.md') }); |
| 341 | const cost = data.snapshot && data.snapshot.cost; |
| 342 | const costFileState = inspectDirectory(projectRoot, '.planning/telemetry', { |
| 343 | filter: (name) => name === 'session-costs.jsonl', jsonl: true, |
| 344 | }); |
| 345 | const costState = costFileState.status === 'unreadable' ? costFileState |
| 346 | : cost && (cost.session_count > 0 || cost.real_sessions > 0) |
| 347 | ? source('.planning/telemetry/session-costs.jsonl', 'healthy', cost.data_source || 'telemetry available', cost.session_count || cost.real_sessions) |
| 348 | : source('.planning/telemetry/session-costs.jsonl', 'unknown', 'no cost telemetry is available'); |
| 349 | let activationState = inspectFile(projectRoot, '.planning/product-proof/activation-report.json', { json: true, schema: 1 }); |
| 350 | if (activationState.status === 'unknown') { |
| 351 | activationState = inspectFile(projectRoot, '.planning/product-proof/activation-cohort-report.json', { json: true, schema: 1 }); |
| 352 | } |
| 353 | if (activationState.status === 'unknown') { |
| 354 | activationState = inspectDirectory(projectRoot, '.planning/telemetry', { |
| 355 | filter: (name) => name === 'activation.jsonl', jsonl: true, |
| 356 | }); |
| 357 | if (activationState.status === 'empty') activationState = source('.planning/telemetry/activation.jsonl', 'unknown', 'source is absent'); |
| 358 | } |
| 359 | return { campaigns: campaignState, fleet: fleetState, forks: forksState, loops: loopsState, hooks: hooksState, handoffs: handoffsState, cost: costState, activation: activationState }; |
| 360 | } |
| 361 | |
| 362 | function readActivation(projectRoot, state) { |
| 363 | let cohort = null; |
| 364 | let cohortNote = 'No shared cohort has been ingested yet.'; |
| 365 | const cohortPath = path.join(projectRoot, '.planning', 'product-proof', 'activation-cohort-report.json'); |
| 366 | if (fs.existsSync(cohortPath)) { |
| 367 | try { |
| 368 | cohort = JSON.parse(fs.readFileSync(cohortPath, 'utf8')); |
| 369 | if (cohort.schema !== 1 || cohort.kind !== 'activation_cohort_report') throw new Error('cohort report is not schema 1'); |
| 370 | cohortNote = 'Explicit, redacted submissions from the public product-proof cohort.'; |
| 371 | } catch (error) { |
| 372 | cohortNote = `Shared cohort report is unreadable: ${error.message}`; |
| 373 | } |
| 374 | } |
| 375 | if (!state || state.status === 'unknown') return { mode: cohort ? 'cohort_only' : 'unknown', note: 'No local activation report has been recorded.', report: null, cohort, cohort_note: cohortNote }; |
| 376 | if (state.status === 'unreadable') return { mode: 'unreadable', note: state.detail, report: null, cohort, cohort_note: cohortNote }; |
| 377 | try { |
| 378 | const reportPath = path.join(projectRoot, '.planning', 'product-proof', 'activation-report.json'); |
| 379 | const value = fs.existsSync(reportPath) |
| 380 | ? JSON.parse(fs.readFileSync(reportPath, 'utf8')) |
| 381 | : activationReport(projectRoot); |
| 382 | if (value.schema !== 1) throw new Error('activation report is not schema 1'); |
| 383 | return { mode: value.total_events > 0 ? 'healthy' : 'empty', note: value.total_events > 0 ? 'local, redacted activation evidence' : 'Activation telemetry is enabled but no events are recorded.', report: value, cohort, cohort_note: cohortNote }; |
| 384 | } catch (error) { |
| 385 | state.status = 'unreadable'; |
| 386 | state.detail = error.message; |
| 387 | return { mode: 'unreadable', note: error.message, report: null, cohort, cohort_note: cohortNote }; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | // --------------------------------------------------------------------------- |
| 392 | // View derivations (snapshot -> per-endpoint payloads) |
| 393 | // --------------------------------------------------------------------------- |
| 394 |
no test coverage detected