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): only a tracker-reported close time may date a decision
[._.]/ Adam Eivyfd32b54c85f2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex cf9faa0d9c..0ef2d79bc8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -80,7 +80,7 @@## Layered Intelligence-- **[issue-3120] The self-improvement loop can now see where its proposals are stuck in *your* review queue.** Its self-evaluation block reported how resolved proposals fared and whether approved ones got delivered, but nothing about the approval funnel itself — so a loop with a dozen proposals sitting unread for weeks had no way to know that its bottleneck was review capacity rather than idea quality, and kept filing into a queue nobody was reading. Every run now also reports the approval rate over the last 14 days (measured on decisions you actually made in that window, so it tracks your current triage rather than restating the lifetime rate), the median time from filing to a decision, and a proposal-phase throughput figure kept explicitly separate from the agent-task run rates in `cosMetrics`. When something is genuinely waiting there's a "pending human review" line with the count, how many have sat past 1/3/7 days, and how long the oldest has waited — and once anything crosses a week the loop is told plainly to raise its bar or file nothing. Nothing pending means no line at all, rather than a reassuring "0 awaiting review" on every run. An idle approver reads as an unknown rate, never 0%, and an unreadable history says so instead of rendering an empty queue. The same numbers are on `GET /api/apps/:id/layered-intelligence/outcomes` for querying.+- **[issue-3120] The self-improvement loop can now see where its proposals are stuck in *your* review queue.** Its self-evaluation block reported how resolved proposals fared and whether approved ones got delivered, but nothing about the approval funnel itself — so a loop with a dozen proposals sitting unread for weeks had no way to know that its bottleneck was review capacity rather than idea quality, and kept filing into a queue nobody was reading. Every run now also reports the approval rate over the last 14 days (measured on decisions you actually made in that window, so it tracks your current triage rather than restating the lifetime rate), the median time from filing to a decision, and a proposal-phase throughput figure kept explicitly separate from the agent-task run rates in `cosMetrics`. When something is genuinely waiting there's a "pending human review" line with the count, how many have sat past 1/3/7 days, and how long the oldest has waited — and once anything crosses a week the loop is told plainly to raise its bar or file nothing. Nothing pending means no line at all, rather than a reassuring "0 awaiting review" on every run. An idle approver reads as an unknown rate, never 0%, and an unreadable history says so instead of rendering an empty queue. Only a decision your tracker actually timestamped counts toward the window and the median — a PLAN.md item checked off months ago but first noticed today is recorded as such rather than passed off as a decision made today. The same numbers are on `GET /api/apps/:id/layered-intelligence/outcomes` for querying.- **[issue-3085] The self-improvement loop can now see whether its approved proposals actually get delivered, not just whether its agent runs finish.** The `cosMetrics` block it reasons over reported per-task-type run success — "did the agent's task complete?" — and nothing about delivery, so a 90% run rate sat there looking healthy beside a pipeline that had landed none of ten approved proposals. That same block now carries a `delivery` figure (approved, delivered, and the current delivery rate) plus a per-scope breakdown, so the two numbers are read side by side. The rate is reported as unknown rather than 0% until something has actually been approved — a loop with no track record shouldn't read as a loop that fails everything.## Antigravity model and effort selectiondiff --git a/server/services/layeredIntelligence/approvalFunnel.js b/server/services/layeredIntelligence/approvalFunnel.jsindex 53e320d6d3..8028deab85 100644--- a/server/services/layeredIntelligence/approvalFunnel.js+++ b/server/services/layeredIntelligence/approvalFunnel.js@@ -27,6 +27,13 @@* already keeps (the "no cold-bootstrap LLM calls" policy). `now` is an injected clock* seam so the ages are testable and so one selfEval run reasons against a single "now".*+ * DECISION TIMESTAMPS MUST BE AUTHORITATIVE. Only a tracker-reported close time dates+ * the human's decision. The `plan` tracker reports none, so `reconcileOutcomes`+ * synthesizes one from the reconcile clock and marks it `outcomeAtSource: 'observed'`;+ * this module treats such a record as UNDATED rather than as a decision made now, so a+ * PLAN.md item checked off months ago but first reconciled today cannot inflate the+ * window cohort or report a latency the user never took.+ ** SENTINEL DISCIPLINE throughout — a rate whose denominator is zero is `null`, never 0:* "no decision has been made in this window" and "every decision was a rejection" are* opposite facts, and a 0% approval rate in the prompt is a direct instruction to the@@ -93,7 +100,13 @@ export function computeApprovalFunnel(outcomes = [], { now = Date.now(), windowMconst decidedInWindow = [];let undatedDecisions = 0;for (const r of decided) {- const decidedMs = parsedMs(r.outcomeAt);+ // A SYNTHESIZED decision timestamp (`outcomeAtSource === 'observed'`) is the+ // reconcile clock, not the human's decision: the `plan` tracker reports no close+ // time, so a PLAN.md item checked off months ago but first reconciled today carries+ // today's date. Treated exactly like an unparseable one — it lands in `undated`+ // rather than being read as a decision made now, which would both inflate the+ // window cohort and report a filing-to-decision latency the user never took.+ const decidedMs = r.outcomeAtSource === 'observed' ? null : parsedMs(r.outcomeAt);// An undatable decision cannot be placed in or out of the window. Counting it in// 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.diff --git a/server/services/layeredIntelligence/approvalFunnel.test.js b/server/services/layeredIntelligence/approvalFunnel.test.jsindex 3c139d067c..9cd7480362 100644--- a/server/services/layeredIntelligence/approvalFunnel.test.js+++ b/server/services/layeredIntelligence/approvalFunnel.test.js@@ -176,6 +176,32 @@ describe('computeApprovalFunnel (#3120)', () => {expect(funnel.window.timeToDecision.maxMs).toBeLessThanOrEqual(4 * DAY);});+ it('treats a SYNTHESIZED decision timestamp as undated, not as a decision made now', () => {+ // The `plan` tracker reports no close time, so reconcileOutcomes stamps the reconcile+ // clock and marks it `observed`. A PLAN.md item checked off months ago but first+ // reconciled today must not read as a fresh decision with a months-long latency.+ const outcomes = [+ { ...decidedRecord('plan-item', 'merged', 90 * DAY, 0), outcomeAtSource: 'observed' }+ ];+ const funnel = computeApprovalFunnel(outcomes, { now: NOW });+ expect(funnel.window).toMatchObject({ decided: 0, approved: 0, undated: 1, approvalRate: null });+ expect(funnel.window.timeToDecision.medianMs).toBeNull();+ // It is still a real verdict for lifetime throughput — only its DATE is unusable.+ expect(funnel.proposalPhase).toMatchObject({ totalFiled: 1, totalDecided: 1, totalPending: 0 });+ });++ it('trusts a tracker-reported decision timestamp and a legacy record without the flag', () => {+ const outcomes = [+ { ...decidedRecord('forge-item', 'merged', 4 * DAY, 2 * DAY), outcomeAtSource: 'tracker' },+ // Written before outcomeAtSource existed: forge/jira always report closedAt, so a+ // legacy record is trusted rather than blanking the metric for existing installs.+ decidedRecord('legacy-item', 'rejected', 5 * DAY, DAY)+ ];+ const funnel = computeApprovalFunnel(outcomes, { now: NOW });+ expect(funnel.window).toMatchObject({ decided: 2, approved: 1, rejected: 1, undated: 0, approvalRate: 50 });+ expect(funnel.window.timeToDecision.count).toBe(2);+ });+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();diff --git a/server/services/layeredIntelligenceOutcomes.js b/server/services/layeredIntelligenceOutcomes.jsindex 89487751cc..de757db389 100644--- a/server/services/layeredIntelligenceOutcomes.js+++ b/server/services/layeredIntelligenceOutcomes.js@@ -31,6 +31,12 @@ import { classifyExecutionFailure, EXECUTION_FAILURE_VALUES } from './layeredInt// only bounds a hand-edited/corrupt value — the real tokens are far shorter.const FAILURE_SIGNAL_MAX_LEN = 64;+// Where a record's `outcomeAt` came from (#3120) — see `sanitizeOutcomeRecord`.+// `'tracker'` is a real close time reported by the tracker; `'observed'` was+// synthesized from the reconcile clock because the tracker (currently only `plan`)+// reports none, and is therefore only a lower bound on when the human decided.+export const OUTCOME_AT_SOURCES = ['tracker', 'observed'];+// The report/retention window. Reuses the dedup suppression window so a proposal// stays in the outcome report exactly as long as it still suppresses re-proposal —// the two "LI remembers this" windows move in lockstep.@@ -90,6 +96,22 @@ export function sanitizeOutcomeRecord(raw) {filedAt: typeof raw.filedAt === 'string' ? raw.filedAt : null,outcome,outcomeAt: outcome && typeof raw.outcomeAt === 'string' ? raw.outcomeAt : null,+ // Provenance of `outcomeAt` (#3120). The approval-funnel metrics measure WHEN the+ // human decided, and only a tracker-reported close time actually says that: the+ // `plan` tracker reports no timestamp at all, so reconcileOutcomes synthesizes one+ // from the reconcile clock. Without this flag a PLAN.md item checked off months ago+ // but first reconciled today would read as a decision made today, inflating both the+ // sliding-window cohort and the filing-to-decision latency. Three-valued, in the+ // same spirit as `rejectionReason`:+ // - `'tracker'` — the tracker reported a real close time; authoritative.+ // - `'observed'` — synthesized at reconcile time; a LOWER BOUND on the decision,+ // not the decision itself. Excluded from window/latency math.+ // - `null` — unrecognized, or a record written before this field existed.+ // Legacy records are treated as `tracker` by the funnel: forge and jira always+ // report `closedAt`, so a synthesized timestamp was already the narrow exception,+ // and blanking the metric for every existing install to cover it would be the+ // worse trade. Such records age out within the 30-day retention window.+ outcomeAtSource: outcome && OUTCOME_AT_SOURCES.includes(raw.outcomeAtSource) ? raw.outcomeAtSource : null,outcomeReason: outcome && typeof raw.outcomeReason === 'string' ? raw.outcomeReason : null,rejectionReason: rejectable && REJECTION_REASON_VALUES.includes(raw.rejectionReason) ? raw.rejectionReason : null,// Implementing-PR handle (#2748, deliverable 2) — the number of the PR that was@@ -180,6 +202,8 @@ export async function recordFiledProposal({ appId, slug, tracker = null, issueRefiledAt: new Date(now).toISOString(),outcome: null,outcomeAt: null,+ // No decision yet, so nothing to attribute a decision timestamp to (#3120).+ outcomeAtSource: null,outcomeReason: null,// Unresolved: nothing has rejected it yet, so there is nothing to diagnose.rejectionReason: null,@@ -286,7 +310,7 @@ export async function recordProposalExecution({ appId, slug, scope = null, succeappId, slug: normSlug, tracker: null, issueRef: null,scope: normScope,filedAt: new Date(now).toISOString(),- outcome: null, outcomeAt: null, outcomeReason: null, rejectionReason: null,+ outcome: null, outcomeAt: null, outcomeAtSource: null, outcomeReason: null, rejectionReason: null,implementingPr: null};const next = {@@ -503,10 +527,21 @@ export async function reconcileOutcomes({ appId, existingIssues = [], now = Date// from `issue`, not `fresh`, so a concurrent execution write can't revert them either.const ok = await store.queueRecordWrite(id, async () => {const fresh = (await store.loadOne(id).catch(() => null)) || r;+ // Only a tracker-reported `closedAt` dates the human's decision. When the tracker+ // reports none (the `plan` filer), the fallback is the reconcile clock — which is+ // a LOWER BOUND, not the decision time — so stamp the provenance alongside it so+ // the approval-funnel metrics (#3120) can exclude it from the window and latency+ // math instead of reading a months-old checkbox as a decision made today. A+ // previously-stored timestamp keeps whatever provenance it already carried.+ const outcomeAt = issue.closedAt || fresh.outcomeAt || new Date(now).toISOString();+ const outcomeAtSource = issue.closedAt+ ? 'tracker'+ : (fresh.outcomeAt ? (fresh.outcomeAtSource ?? null) : 'observed');const next = {...fresh,outcome,- outcomeAt: issue.closedAt || fresh.outcomeAt || new Date(now).toISOString(),+ outcomeAt,+ outcomeAtSource,outcomeReason: issue.stateReason || 'auto-derived from tracker state',rejectionReason,implementingPr: nextImplementingPrdiff --git a/server/services/layeredIntelligenceOutcomes.test.js b/server/services/layeredIntelligenceOutcomes.test.jsindex 6effbb9ba5..666fef57f6 100644--- a/server/services/layeredIntelligenceOutcomes.test.js+++ b/server/services/layeredIntelligenceOutcomes.test.js@@ -235,6 +235,30 @@ describe('reconcileOutcomes', () => {expect(byslug['still-open'].outcome).toBeNull();});+ it('stamps outcomeAt provenance so a synthesized decision date is distinguishable (#3120)', async () => {+ await recordFiledProposal({ appId: 'app-1', slug: 'has-closed-at', scope: 'app-improvement' }, store);+ // A `plan`-tracker close: the filer reports no closedAt at all, so reconcile has to+ // synthesize the timestamp from its own clock.+ await recordFiledProposal({ appId: 'app-1', slug: 'no-closed-at', scope: 'app-improvement' }, store);++ const now = Date.parse('2026-07-20T00:00:00Z');+ await reconcileOutcomes({+ appId: 'app-1',+ now,+ existingIssues: [+ { slug: 'has-closed-at', state: 'closed', stateReason: 'completed', closedAt: '2026-07-01T00:00:00Z' },+ { slug: 'no-closed-at', state: 'closed' }+ ]+ }, store);++ const bySlug = Object.fromEntries((await listOutcomes({ appId: 'app-1', now }, store)).map(r => [r.slug, r]));+ // A tracker-reported close time is authoritative — the funnel may date the decision.+ expect(bySlug['has-closed-at'].outcomeAtSource).toBe('tracker');+ // A synthesized one is only a lower bound, so it is marked and excluded downstream.+ expect(bySlug['no-closed-at'].outcomeAtSource).toBe('observed');+ expect(bySlug['no-closed-at'].outcomeAt).toBe(new Date(now).toISOString());+ });+it('does not re-resolve an already-resolved record', async () => {await recordFiledProposal({ appId: 'app-1', slug: 's', scope: 'app-improvement' }, store);await reconcileOutcomes({ appId: 'app-1', existingIssues: [{ slug: 's', state: 'closed', stateReason: 'completed' }] }, store);