Repository navigation
Harden consistency and reliability (single-instance) - #2
Merged
Merged
Conversation
Moves consistency-critical behaviour from prompt-only into code, and removes silent-failure / data-loss paths, keeping the single-user design. Behavioural guardrails: - notion.mjs `sync-dashboard`: re-derives the This Week, Goals, and Body Stats tiles directly from the databases (counts/values come from queries, never the model), so the Dashboard cannot drift or carry fabricated numbers. The coach now runs one deterministic command after any data change. `--now` takes the chat-header date so "this week" is timezone-correct. - notion.mjs writes now validate select/multi_select/status values against the live schema and range-check RPE (1-10), failing locally with the valid options instead of writing a miscategorised or impossible row. Adds `log --dry-run`. - runner.ts injects a deterministic context line (Notion/workspace status, PERSONAL.md filled-in state) into every prompt, so onboarding facts are present even on resumed sessions instead of relying on the model to fetch them. - Fast model tier is now opt-in (`FAST_TIER_ENABLED`, default off), so default behaviour is consistent; every message uses CLAUDE_MODEL unless enabled. Runtime reliability: - Shared writeJsonAtomic() (temp + rename) for sessions, schedule, and the Notion id caches, so a crash mid-write can't truncate state into a silent reset. - runner.ts retries the agent query with backoff on transient startup errors (only before a session is established, to avoid duplicate writes) and broadens subscription-cap detection. - Dashboard tile refresh is now append-then-delete, so a failed refresh leaves the old tile intact rather than empty. - Startup fails fast in webhook mode when PUBLIC_BASE_URL or CRON_SECRET is unset, so the service never runs with an unauthenticated /cron/run. - Scheduler warns on duplicate task ids instead of silently overwriting. Tests + CI: - Extends scripts/notion.test.mjs (26 tests) covering value validation and the pure dashboard-tile renderers. - Adds .github/workflows/ci.yml running build + test on push/PR. Docs: CLAUDE.md, notion-formatting skill, configuration.md, and .env.example updated for sync-dashboard, FAST_TIER_ENABLED, and the webhook requirements. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XvGkxgFtZB4DfNAVkFwx54
FrancescoCoding
added a commit
that referenced
this pull request
Jul 19, 2026
…dening Harden consistency and reliability (single-instance)
FrancescoCoding
added a commit
that referenced
this pull request
Jul 19, 2026
…dening Harden consistency and reliability (single-instance)
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
Makes the agent way more consistent and closer to public-ready, keeping the single-user / single-instance design (no distributed store). The theme: move consistency-critical behaviour from prompt-only into code, and remove silent-failure / data-loss paths. Planned and scoped with the maintainer; this is the recommended first batch.
Behavioural guardrails (consistency now code-enforced)
sync-dashboard(scripts/notion.mjs): re-derives the This Week, Goals, and Body Stats tiles directly from the databases. Counts and values come from queries, never the model, so the Dashboard can't drift or carry fabricated numbers. The coach runs one deterministic command after any data change instead of hand-building three tiles.--now <YYYY-MM-DD>takes the chat-header date so "this week" is timezone-correct.select/multi_select/statusvalues are checked against the live schema andRPEis range-checked (1–10), failing locally with the valid options instead of writing a miscategorised or impossible row. Addslog --dry-runto read a parsed row back before committing.runner.tsinjects Notion/workspace status and whetherPERSONAL.mdis filled in, into every prompt — so onboarding facts are present even on resumed sessions rather than depending on the model to fetch them.FAST_TIER_ENABLED, default off): every message usesCLAUDE_MODELby default for consistent behaviour; enable it to route trivial logs to the cheap model.Runtime reliability (no silent failure, no data loss)
writeJsonAtomic()(temp + rename) for sessions, the schedule, and the Notion id caches, so a crash mid-write can't truncate state into a silent reset (which previously reseeded defaults or re-created databases).runner.tsretries the agent query with backoff on transient startup errors — only before a session is established, to avoid duplicate Notion writes — and broadens subscription-cap detection.PUBLIC_BASE_URLandCRON_SECRET, so/cron/runis never left unauthenticated.Tests + CI
scripts/notion.test.mjsto 26 tests covering value validation and the pure dashboard-tile renderers..github/workflows/ci.ymlrunningnpm ci,npm run build(strict tsc), andnpm teston push/PR.Docs
CLAUDE.md, the notion-formatting skill,docs/configuration.md, and.env.exampleupdated forsync-dashboard,FAST_TIER_ENABLED, and the webhook requirements.Verification
npm run build(strict tsc) — green.npm test— 26/26 pass.node --check;sync-dashboardis wired into the command table.Out of scope (by decision)
Multi-user / multi-instance and a shared session/schedule store. The single-instance constraint stays; fail-fast config makes it explicit and safe rather than silent. Follow-up tier (ffmpeg timeout, attachment feedback, hard message-split, SECURITY.md, package metadata, wider redaction) can land in a second PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XvGkxgFtZB4DfNAVkFwx54
Generated by Claude Code