feat: offline fallback for Langfuse + repo quality guardrails#73
Open
michaelpetrik wants to merge 1 commit intolainra:mainfrom
Open
feat: offline fallback for Langfuse + repo quality guardrails#73michaelpetrik wants to merge 1 commit intolainra:mainfrom
michaelpetrik wants to merge 1 commit intolainra:mainfrom
Conversation
Offline fallback (src/offlineFallback.js): - When Langfuse flush fails after retries, write a lightweight session reference to ~/.claude/telemetry-fallback.jsonl (JSONL append-only) - Reference contains sessionId, userId, org, stats — enough to locate the full transcript in local Claude session data - Configurable via FALLBACK_FILE env var - Synchronous appendFileSync so fallback itself cannot silently fail async - sessionHandler.js finalize() catch block now calls writeReference(this) - serverHelpers.js createConfig() exposes fallbackFile config field - FALLBACK_FILE documented in .env.example and docs/ENVIRONMENT_VARIABLES.md - Unit tests: test/unit/offlineFallback.test.js (dir creation, append, metadata) Quality guardrails: - AGENTS.md created (canonical agent doc); CLAUDE.md reduced to @AGENTS.md - .nvmrc pins Node 22 for local development - .githooks/pre-commit: lint + format:check + staged-file secret scan - scripts/install-hooks.sh: one-time hook wiring (npm run hooks:install) - scripts/ci/run_quality_gates.sh: offline-runnable format + lint + unit tests - scripts/ci/run_security_review.sh: npm audit + secret scan + docker build - package.json: quality, security, hooks:install scripts; AGENTS.md in files[] - .quality/guardrails-report.md: policy vs enforcement matrix with N/A rows - prettier --write applied to entire codebase (format:check was never in CI) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/offlineFallback.js): when Langfuse is unreachable and all retries are exhausted, a lightweight session reference is appended to~/.claude/telemetry-fallback.jsonl. The reference containssessionId,userId, org metadata, and cost/token stats — enough to locate the full transcript in local Claude session data (~/.claude/projects/). No retry queue, no replay — just a bookmark.Changes
Offline fallback
src/offlineFallback.jswriteReference(),getFallbackPath(), JSONL append-onlysrc/sessionHandler.jsfinalize()catch block now callswriteReference(this)on flush failuresrc/serverHelpers.jscreateConfig()exposesfallbackFilefield.env.exampleFALLBACK_FILEenv vardocs/ENVIRONMENT_VARIABLES.mdFALLBACK_FILEsection addedtest/unit/offlineFallback.test.jsQuality guardrails
AGENTS.mdCLAUDE.mdis now@AGENTS.md).nvmrc.githooks/pre-commitscripts/install-hooks.shnpm run hooks:install)scripts/ci/run_quality_gates.shscripts/ci/run_security_review.shpackage.jsonquality,security,hooks:installscripts;AGENTS.mdinfiles[].quality/guardrails-report.mdPrettier was also run across the entire codebase —
format:checkwas never in CI so 41 files had accumulated drift.Test plan
npm run qualitypasses (format:check + lint + unit tests)npm test— 12 suites, 160 tests all pass~/.claude/telemetry-fallback.jsonlis written when Langfuse is stopped and bridge receives telemetryGuardrail status summary
npx gitnexus analyze)🤖 Generated with Claude Code