Actually instrument the ordering sync

The earlier attempt at this never landed: its patch failed an assertion, and
I read a `grep -c "pf-order"` of 1 as confirmation when that count is just
the logger's own template literal — every call site was missing. So the
function was reached, returned silently, and reported nothing, twice over.

Logs on entry, the inputs it resolved, the expressions already in the saved
config, and each exit. Verified against the source and against the
individual strings in the built bundle rather than a count.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-09-17 14:40:22 -04:00
parent a5bb814a68
commit 6c9d0eef11

View File

@ -933,12 +933,24 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio
} }
async function syncOrderExpressions() { async function syncOrderExpressions() {
dbgOrder('enter')
const viewer = viewerRef.current const viewer = viewerRef.current
if (!viewer) return if (!viewer) { dbgOrder('exit: no viewer'); return }
const version = versions.find(v => String(v.id) === String(versionId)) const version = versions.find(v => String(v.id) === String(versionId))
const wanted = buildOrderExpressions(version?.bucket_order, logMeta) const wanted = buildOrderExpressions(version?.bucket_order, logMeta)
dbgOrder('inputs', {
versionId,
versionFound: !!version,
bucket_order: version?.bucket_order ?? null,
logMetaCount: Object.keys(logMeta || {}).length,
seqs: Object.entries(logMeta || {})
.filter(([, m]) => m.seq != null)
.map(([id, m]) => `${id}=${m.seq}`),
wanted: Object.keys(wanted),
})
const { table: _t, ...cfg } = await viewer.save() const { table: _t, ...cfg } = await viewer.save()
dbgOrder('saved config read', { existing: Object.keys(cfg.expressions || {}) })
const current = cfg.expressions || {} const current = cfg.expressions || {}
const managed = Object.values(ORDER_EXPR_NAMES) const managed = Object.values(ORDER_EXPR_NAMES)
@ -958,8 +970,10 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio
.map(([id, m]) => `${id}:${m.tag || m.note}=${m.seq}`), .map(([id, m]) => `${id}:${m.tag || m.note}=${m.seq}`),
}) })
} }
else dbgOrder('exit: already applied', Object.keys(next))
return return
} }
dbgOrder('applying', Object.keys(next))
// An expression the pivot is using cannot simply vanish; drop it from the // An expression the pivot is using cannot simply vanish; drop it from the
// axes first or restore() rejects the config. // axes first or restore() rejects the config.