Files
dotfiles/overlays/patches/prometheus
Richie 50d4aa383f
treefmt / nix fmt (pull_request) Successful in 3s
test ebook search / test-ebook-search (pull_request) Failing after 8h50m21s
pytest / pytest (pull_request) Failing after 8h50m22s
build_systems / build-rhapsody-in-green (pull_request) Failing after 8h50m23s
build_systems / build-portal-1 (pull_request) Failing after 8h50m24s
build_systems / build-jeeves (pull_request) Failing after 8h50m24s
build_systems / build-brain (pull_request) Failing after 8h50m24s
build_systems / build-bob (pull_request) Failing after 8h50m24s
Clean up overlays and remove obsolete dependencies
2026-09-18 19:59:12 -04:00
..

Prometheus complete test parsing

CodeMirror gives editor-state creation a 20 ms synchronous parsing budget. The shared createEditorState() test helper can therefore return an incomplete syntax tree when the process is descheduled. The completion and vector-matching tests immediately inspect that tree.

Scope and behavior

complete-test-parsing.patch changes only module/codemirror-promql/src/test/utils-test.ts inside web/ui. It completes the small test expression with ensureSyntaxTree(..., Infinity) and publishes the completed parse through an empty transaction so syntaxTree(state) sees it. Failure to obtain a tree raises an error.

The original assertions remain enabled, including autocomplete topk params 2 and foo * on(test,blub) bar. The unlimited budget applies to the test helper; production editor parsing budgets are unchanged.

Reproduction and focused checks

Use a disposable Prometheus 3.14.0 checkout. The patch root is web/ui, matching the Nix assets derivation. From this directory:

patch --fuzz=0 -d /path/to/prometheus/web/ui -p1 < complete-test-parsing.patch
cd /path/to/prometheus/web/ui
pnpm install --frozen-lockfile
pnpm --filter @prometheus-io/lezer-promql build
pnpm --filter @prometheus-io/codemirror-promql test

To force the scheduling condition, temporarily append this clock to module/codemirror-promql/setupJest.cjs in the disposable checkout:

let parseClock = 0;
Date.now = () => (parseClock += 25);

Each clock read crosses the editor's initial parsing budget. Against the original helper, the hybrid and vector suites have 186 failures, including both locally excluded cases. With the patch, all 386 CodeMirror tests pass under that same clock. Remove the injected clock before normal builds.

Upstream status

This is a standalone test-helper patch for Prometheus 3.14.0. No upstream submission was made during this work. Recheck the helper when updating Prometheus or CodeMirror, including how an ensured parse becomes visible through the editor state.

Local NixOS integration and build results

../default.nix loads default.nix, which patches the separate assets derivation. It updates both passthru.assets and the main Prometheus build's reference to those assets. From the repository root:

nix build --no-link -L .#nixosConfigurations.jeeves.pkgs.prometheus.assets

The full x86-64-v3 assets build passed with the normal clock, including the CodeMirror and UI suites. Host-flake evaluation confirmed that the main Prometheus derivation refers to these patched assets. The Go server package was not rebuilt for this test-helper change.