test(langfuse): structural guard for setup_hook + hook file coexistence#1052
test(langfuse): structural guard for setup_hook + hook file coexistence#1052yasinBursali wants to merge 1 commit intoLight-Heart-Labs:mainfrom
Conversation
Add TestLangfuseManifestHook to dashboard-api/tests/test_hooks.py. Two
narrow assertions guarantee that langfuse's manifest declares
service.setup_hook = "hooks/post_install.sh" AND that the referenced hook
file exists on disk. If either drifts (file renamed, manifest field
removed, hook deleted), _validate_hook_path returns None and
_handle_install silently skips the hook — langfuse silently regresses to
the broken Linux postgres uid mismatch behaviour with no CI signal. The
test catches that.
Uses defensive manifest.get("service", {}).get("setup_hook") so a future
regression that deletes the entire service: block produces a clean assertion
failure instead of a less-actionable KeyError. Assertion messages reference
the langfuse postgres uid 70 install fix conceptually rather than a
transient PR number, so the wording remains accurate after rebase.
|
Audit follow-up: keep draft / stack on the implementation. The structural guard is useful, but this branch currently asserts that the Langfuse hook implementation already exists while the branch does not include it. Please retarget/stack this on the PR that adds the hook file and |
|
This is still draft and still red on its own branch. I re-ran the focused hook tests locally: python -m pytest dream-server/extensions/services/dashboard-api/tests/test_hooks.py -qResult: Please stack/rebase this after the Langfuse hook implementation is merge-ready, or include the implementation here, then undraft and rerun the API job. As-is it cannot merge because it intentionally redlines CI. |
What
Add
TestLangfuseManifestHooktodream-server/extensions/services/dashboard-api/tests/test_hooks.py. Two narrow structural-guard assertions that langfuse's manifest declaresservice.setup_hook = "hooks/post_install.sh"AND that the referenced hook file exists on disk.Why
The langfuse postgres uid 70 install fix relies on
service.setup_hookpointing athooks/post_install.sh. If either drifts (file renamed, manifest field removed, hook deleted), the host agent's_validate_hook_pathreturnsNone,_handle_installsilently skips the hook at theif hook_path:guard, and langfuse silently regresses to the broken Linux postgres uid mismatch behaviour with no CI signal. The structural guard catches that.How
Append a single test class to the existing
test_hooks.py(the established home for hook-related tests, sharing itsimport yaml,pathlib.Path, and class-based conventions):Path expression
Path(__file__).resolve().parents[2] / "langfuse"is the corrected form:parents[0]=tests/,parents[1]=dashboard-api/,parents[2]=extensions/services/. (The original issue suggestionPath(__file__).resolve().parent.parent / "dream-server" / ...resolves to a nonexistent path — fixed during implementation.)Defensive
manifest.get("service", {}).get("setup_hook")mirrors the host agent's own style at line 441 — produces a cleanAssertionErrorif the entireservice:block is removed in some future regression, instead of a less-actionableKeyError.Assertion messages reference the langfuse postgres uid 70 install fix conceptually rather than a transient PR number, so the wording remains accurate after rebase regardless of whether that fix's PR number changes.
Testing
python3 -m py_compile→ PASSruff→ clean (no new warnings, no unused imports)Path(__file__).resolve().parents[2] / "langfuse"resolves toextensions/services/langfuse✓upstream/mainuntil fix(langfuse): chown postgres/clickhouse data dirs to image uids on Linux #1040 lands)gh pr diff 1040 | git applylocally, run tests, revert): both new tests PASS cleanly; revert leaves worktree pristineManual (operator after #1040 merges):
git fetch upstream && git rebase upstream/main— should be a clean fast-forward / mechanical merge with no conflicts (this PR only modifies test_hooks.py; fix(langfuse): chown postgres/clickhouse data dirs to image uids on Linux #1040 does not touch that file)pytest dream-server/extensions/services/dashboard-api/tests/test_hooks.py::TestLangfuseManifestHook -v→ both tests PASShooks/post_install.shtohooks/postinstall.shand re-run → second test fails with the actionable diagnostic messageReview
Critique Guardian APPROVED (post-warning-fix re-review). The two warnings from the first CG pass — stale "PR #1040" mentions in source and missing
.get()defensive style — were both addressed before commit.Platform Impact