feat(selfhost): wire Codex reviews and secure observability#1678
feat(selfhost): wire Codex reviews and secure observability#1678JSONbored wants to merge 68 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1678 +/- ##
==========================================
+ Coverage 95.59% 95.68% +0.09%
==========================================
Files 204 211 +7
Lines 22316 22985 +669
Branches 8067 8310 +243
==========================================
+ Hits 21332 21994 +662
+ Misses 408 402 -6
- Partials 576 589 +13
🚀 New features to boost your workflow:
|
74f4dcc to
d89d349
Compare
d89d349 to
f4aa25e
Compare
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - fixes requiredReview updated: 2026-06-29 16:22:56 UTC
🛑 Suggested Action - Manual Review
Review summary Blockers
Nits — 7 non-blocking
Why this is blocked
CI checks failing
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
|
@gittensory gate-override Maintainer-lane self-host setup PR: all CI, security, coverage, and self-host smoke checks are green. The remaining blocker is the deployed gate readiness/preflight hold for owner-authored work when repo registration is unavailable, and this PR includes the upstream fix for that false-positive. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 9d7d044 | Commit Preview URL Branch Preview URL |
Jun 29 2026, 11:31 AM |
| && chown -h node:node /home/node/.codex \ | ||
| && chown -R node:node /home/node/.npm-global /home/node/.npm | ||
| USER node | ||
| RUN if [ "$INSTALL_AI_CLIS" = "true" ]; then npm install -g @anthropic-ai/[email protected] @openai/[email protected]; fi |
There was a problem hiding this comment.
P2: Docker image build executes npm postinstall scripts from global CLI packages
The Dockerfile installs @anthropic-ai/claude-code and @openai/codex globally via npm install -g without --ignore-scripts, allowing postinstall lifecycle scripts from these packages and their transitive dependencies to execute during the Docker image build.
Add --foreground-scripts to make postinstall execution visible in build logs, and audit the CLI packages and their transitive dependencies with npm audit before image publication. Consider using reproducible installs with a lock file for global dependencies.
AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.
<file name="Dockerfile">
<violation number="1" location="Dockerfile:49">
<priority>P2</priority>
<title>Docker image build executes npm postinstall scripts from global CLI packages</title>
<evidence>The runtime-base stage in the Dockerfile runs npm install -g @anthropic-ai/[email protected] @openai/[email protected] as the unprivileged node user without the --ignore-scripts flag. This executes any postinstall scripts defined in these packages and their transitive dependencies during the Docker build. Because npm install -g does not use a lock file for transitive dependencies, their versions can shift between builds based on upstream semver ranges, increasing supply-chain risk.</evidence>
<recommendation>Add --foreground-scripts to the npm install -g command so postinstall execution is visible in build logs. Run npm audit against the installed CLI packages before image publication. Consider pinning transitive dependency versions by generating and verifying a lock file for the global install, or install the native binaries via direct verified downloads instead of npm to eliminate script execution entirely.</recommendation>
</violation>
</file>
| -v "$PWD:/work" \ | ||
| -w /work \ | ||
| "$NODE_IMAGE" \ | ||
| sh -lc 'apt-get update >/dev/null && apt-get install -y --no-install-recommends ca-certificates git >/dev/null && git config --global --add safe.directory /work && (npx -y @sentry/cli@latest releases new "$SENTRY_RELEASE" >/tmp/gittensory-sentry-release-new.log 2>&1 || true) && npx -y @sentry/cli@latest releases set-commits "$SENTRY_RELEASE" --auto && npx -y @sentry/cli@latest sourcemaps inject dist && node scripts/validate-selfhost-sourcemap.mjs && npx -y @sentry/cli@latest sourcemaps upload --release="$SENTRY_RELEASE" dist && npx -y @sentry/cli@latest releases finalize "$SENTRY_RELEASE" && chown -R "$HOST_UID:$HOST_GID" dist node_modules package-lock.json' |
There was a problem hiding this comment.
P2: Deploy script fetches and runs unpinned Sentry CLI via npx
The self-host deploy script invokes npx -y @sentry/cli@latest multiple times to manage Sentry releases and upload source maps. Using @latest means any compromised Sentry CLI release could execute arbitrary code during deployment with access to SENTRY_AUTH_TOKEN and the mounted project directory.
Pin the Sentry CLI to a specific version (e.g., @sentry/[email protected]) consistent with the release workflow, and verify the installed package integrity before execution. Replace npx -y @sentry/cli@latest with the pinned version throughout the script.
AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.
<file name="scripts/deploy-selfhost-prebuilt.sh">
<violation number="1" location="scripts/deploy-selfhost-prebuilt.sh:158">
<priority>P2</priority>
<title>Deploy script fetches and runs unpinned Sentry CLI via npx</title>
<evidence>The run_sentry_upload function executes npx -y @sentry/cli@latest for releases new, releases set-commits, sourcemaps inject, sourcemaps upload, and releases finalize. The @latest tag fetches the most recent published version without integrity verification. If the Sentry npm package or its dependencies are compromised, arbitrary code executes inside the throwaway Docker container with access to the SENTRY_AUTH_TOKEN environment variable and the $PWD:/work volume mount, allowing modifications to persist on the host filesystem after the container exits.</evidence>
<recommendation>Pin the Sentry CLI version explicitly (e.g., npx -y @sentry/[email protected]) to match the version used in the official release pipeline. Consider installing the CLI via npm ci --ignore-scripts with a local package.json and lock file, or use the official Sentry CLI binary downloaded directly from GitHub releases with checksum verification.</recommendation>
</violation>
</file>
Merge main into the self-host review branch, preserve the pinned Sentry release path, and drop Cloudflare review bindings from gittensory-api now that review execution is self-host-only. Validation: - npm run test:ci - npm audit --audit-level=moderate
Hold missing AI public output as a visible manual-review signal with Sentry context instead of publishing a deterministic-only surface. Honor QDRANT_DIM during collection initialization and add regression coverage for renamed checks, guardrail manual holds, self-host routing, provider edge cases, and review-comment signals.
Document that direct review-app webhooks and Cloudflare review jobs are retired while central Orb ingress remains live for self-host relay. Add an Orb webhook invariant without SELFHOST_TRANSIENT_CACHE and update the stale review-job log name.
Publish public-safe unstructured AI review text as a non-cacheable manual-review fallback instead of dropping it into deterministic-only output. Add provider diagnostics to Sentry context and cover the fallback path in AI review and queue tests.
Summary
CODEX_AI_*,CLAUDE_AI_*,OLLAMA_AI_*,OPENAI_COMPATIBLE_AI_*,OPENAI_AI_*, andANTHROPIC_AI_*settings instead of shared ambiguous AI knobs.AI_MODEL,AI_EFFORT,AI_BASE_URL,AI_API_KEY, orAI_TIMEOUT_MSvalues cannot silently steer the wrong backend.AGENTS.mdfor Codex review context while preservingCLAUDE.mdfallback and skills loading.gittensory-selfhost@<version>release id and the release workflow uploads the exact built bundle maps.Closes #1469.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires >=97% coverage of the lines AND branches you changed (aim for 98%+ on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateAdditional validation:
npm run test:cinpm run typechecknpx vitest run test/unit/selfhost-grafana-reporting.test.ts test/unit/selfhost-ai.test.ts test/unit/ai-review-advisory.test.tsnpx vitest run test/unit/signals-coverage.test.ts test/unit/selfhost-ai.test.tsGRAFANA_ADMIN_PASSWORD=placeholder docker compose --profile observability configestimated_neurons; older source DBs without that column still materialize a valid dashboard-safeestimated_neurons = 0column.node scripts/build-selfhost.mjs --all --sourcemapdist/server.mjs,dist/server.mjs.map,sourceMappingURL=server.mjs.map, non-empty original sources, andsourceRoot=/app/dist.runtime-prebuiltrelease target both build successfully.runtime-prebuiltwithINSTALL_VISUAL_REVIEW=trueinstallspuppeteer-coresuccessfully.GITTENSORY_VERSION,NODE_OPTIONS=--enable-source-maps,dist/server.mjs,dist/server.mjs.map, and source mapsourceRoot=/app/dist./ready, confirmed Codex review settings and auth mount behavior, confirmed Codex reviews completed, and confirmed Codex token/request metrics increased.If any required check was skipped, explain why:
Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.UI Evidence
Notes
reporting-exporter; it does not mount the live application database, and the exporter now mounts the app data volume read-only.estimated_neuronscolumn. Current source DBs copy the real value; older source DBs without the column export0so dashboards remain queryable while operators migrate.CODEX_AI_MODEL,CODEX_AI_EFFORT,CLAUDE_AI_MODEL,CLAUDE_AI_EFFORT,OLLAMA_AI_MODEL,OPENAI_AI_MODEL, and matching provider-specific base URL/key/timeout settings.AI_PROVIDER, so uncredentialed or ignored provider entries are not reported as if they actually ran.GITTENSORY_REPORTING_SOURCE_DB. If the live store is not SQLite, the exporter emits a valid empty reporting database until a compatible reporting source is configured./appand Source Code Root..SENTRY_AUTH_TOKENin thereleaseenvironment; non-official forks skip Sentry upload when the token is absent.