Files
insights/bin/dev-sandbox-shims-selftest
zeekay 10e6fec4c0 debrand: the brand token is INSIGHTS_, and a wrong one stops the container
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO
split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live
pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the
container entrypoint, so the misspelling does not degrade a feature -- it runs
migrate --check against a database whose history this tree does not share and
the container never starts.

Both replacements are measured against the shipped tree rather than chosen:
every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL ->
INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12
determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_
tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of
the bad rule and cannot collide with an upstream name.

The rule is fixed for the next convergence, and the tree it already produced is
repaired in the same commit -- the codemod is idempotent against its own output,
so it cannot undo this itself.
2026-08-01 17:42:28 -07:00

63 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Self-test for bin/dev-sandbox-shims routing logic. Pure string logic, so it
# runs anywhere (no sandbox-exec / macOS needed) — unlike bin/dev-sandbox-selftest.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd -P)"
# shellcheck source=/dev/null
source "$here/dev-sandbox-shims"
fail=0
check() { # check <wrap|pass> <tool> <args...>
local expected="$1" got
shift
local tool="$1"
shift
if _ph_sandbox_should_wrap "$tool" "$@"; then got="wrap"; else got="pass"; fi
if [ "$got" != "$expected" ]; then
echo "FAIL: expected $expected, got $got for: $tool $*" >&2
fail=1
else
echo "ok: $tool $* -> $got"
fi
}
# uv: dependency-mutating subcommands are sandboxed
check wrap uv sync
check wrap uv add requests
check wrap uv lock
check wrap uv pip install requests
check wrap uv pip sync
check wrap uv --verbose sync
# uv: everything else passes through
check pass uv run pytest
check pass uv pip list
check pass uv tool install ruff
check pass uv
# pnpm: dependency-mutating subcommands are sandboxed
check wrap pnpm install
check wrap pnpm i
check wrap pnpm add lodash
check wrap pnpm update
check wrap pnpm up
check wrap pnpm --filter=@hanzo/frontend install
# pnpm: everything else passes through
check pass pnpm dev
check pass pnpm exec tsc
check pass pnpm run install # a script named "install" is not `pnpm install`
check pass pnpm
# INSIGHTS_DEV_SANDBOX=0 disables all wrapping
echo "-- with INSIGHTS_DEV_SANDBOX=0 --"
INSIGHTS_DEV_SANDBOX=0
check pass uv sync
check pass pnpm install
unset INSIGHTS_DEV_SANDBOX
if [ "$fail" -ne 0 ]; then
echo "dev-sandbox-shims self-test FAILED" >&2
exit 1
fi
echo "dev-sandbox-shims self-test passed"