Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): document why a future-dated decision stays in the window
[._.]/ Adam Eivyb6d19d8d1708
diff --git a/server/services/layeredIntelligence/approvalFunnel.js b/server/services/layeredIntelligence/approvalFunnel.jsindex dce8c1f774..53e320d6d3 100644--- a/server/services/layeredIntelligence/approvalFunnel.js+++ b/server/services/layeredIntelligence/approvalFunnel.js@@ -98,6 +98,14 @@ export function computeApprovalFunnel(outcomes = [], { now = Date.now(), windowM// would inflate a "recent" rate with an unknown-age verdict; counting it out// silently would undercount the user's activity. It gets its own slot.if (decidedMs === null) { undatedDecisions += 1; continue; }+ // Lower bound only, deliberately. A FUTURE-dated decision (clock skew on the peer+ // that reconciled it, a repaired record) is still a decision the user made, and it+ // is by definition the most recent one — so it belongs in the window. Excluding it+ // would be the more dangerous choice, not the safer one: it would silently drop a+ // real verdict from BOTH sides of the rate while `proposalPhase.totalDecided` still+ // counted it, and a dropped REJECTION inflates the approval rate — exactly the+ // direction that must never be flattered. The elapsed-time math clamps at `now`+ // separately (see `latency`), so the skew cannot distort a duration.if (decidedMs >= windowStart) decidedInWindow.push({ record: r, decidedMs });}const countOutcome = (name) => decidedInWindow.filter(({ record }) => record.outcome === name).length;diff --git a/server/services/layeredIntelligence/approvalFunnel.test.js b/server/services/layeredIntelligence/approvalFunnel.test.jsindex 64713701a5..3c139d067c 100644--- a/server/services/layeredIntelligence/approvalFunnel.test.js+++ b/server/services/layeredIntelligence/approvalFunnel.test.js@@ -159,6 +159,23 @@ describe('computeApprovalFunnel (#3120)', () => {expect(funnel.window.timeToDecision.medianMs).toBeLessThanOrEqual(DAY);});+ it('keeps a FUTURE-dated decision inside the window rather than dropping the verdict', () => {+ // Excluding a skewed verdict is the more dangerous choice: it drops a real decision+ // from BOTH sides of the rate while proposalPhase still counts it, and dropping a+ // REJECTION inflates the approval rate — the one direction that must never flatter.+ const outcomes = [+ decidedRecord('skewed-rejection', 'rejected', DAY, -30 * DAY),+ decidedRecord('real-approval', 'merged', 4 * DAY, 2 * DAY)+ ];+ const funnel = computeApprovalFunnel(outcomes, { now: NOW });+ expect(funnel.window).toMatchObject({ decided: 2, approved: 1, rejected: 1, approvalRate: 50 });+ // The window cohort and the lifetime decided count agree — no verdict silently lost.+ expect(funnel.proposalPhase.totalDecided).toBe(2);+ // And the skew still cannot distort a duration: the clamp holds it at the age of+ // the proposal (1d), not the 31d the raw timestamps imply.+ expect(funnel.window.timeToDecision.maxMs).toBeLessThanOrEqual(4 * DAY);+ });+it('honors an injected window span', () => {const outcomes = [decidedRecord('mid', 'merged', 6 * DAY, 5 * DAY)];expect(computeApprovalFunnel(outcomes, { now: NOW, windowMs: 3 * DAY }).window.approvalRate).toBeNull();