Repository navigation
fix(syntropy): align meal_type with canonical MealType enum (6 values) - #10
Merged
supmo668 merged 1 commit intoMay 9, 2026
Conversation
Plan task 4.1 from .claude/plans/2026-05-07-ci-schema-cleanup.md.
Closes a silent contract drift between this plugin's tool argument
schemas and SyntropyJournal's canonical contracts.py:
contracts.py:MealType (6 values):
BREAKFAST, LUNCH, DINNER, SNACK, SUPPLEMENT, BEVERAGE
tools.ts (before this PR):
'breakfast, lunch, dinner, or snack' (4 values, free-form string)
The drift surfaces as user-visible failures: when a user logs a
supplement or beverage, the LLM's tool schema doesn't list those
values, so it either omits the meal_type or guesses an invalid one.
The SJ MCP server validates server-side and returns 4xx, manifesting
as a confusing error in the chat.
Changes:
1. New MealTypeSchema constant — Type.Union of 6 Type.Literal values,
mirrors contracts.py:MealType exactly. TypeBox validates input
before the network call; LLM sees the exact enum in the tool
schema (better tool-call accuracy).
2. syntropy_log_food.meal_type → MealTypeSchema (line 52).
syntropy_analyze_food.meal_type → MealTypeSchema (line 116).
3. Header comment block documenting the schema source of truth and
the alignment requirement.
This is the OpenClaw side of the same fix the mobile codegen
will get in a follow-up. Long-term the right move is to generate
TypeBox schemas from shared/schemas/syntropy.schema.json as part
of the parent monorepo's schema-drift workflow; this PR is a
minimal targeted fix while that infra is built.
supmo668
merged commit May 9, 2026
7eba724
into
feat/openclaw-syntropy-integration
5 of 9 checks passed
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
supmo668
added a commit
that referenced
this pull request
May 12, 2026
…tion (#9) * feat(persist-user-identity): user and channel identity tables Adds lp_users and lp_user_channels PostgreSQL tables extending the persist-postgres lp_ schema convention. Supports: - Canonical users with optional external_id (from JWT sub claim) - Many-to-one channel identity mapping (multiple channels → one user) - Upsert channel linking with conflict resolution for re-assignment - Cross-channel user merging via linkExternalId() Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(persist-user-identity): identity resolution hook and /verify /register /whoami commands Core plugin implementation: - before_agent_start hook (priority 60) resolves channel peer → canonical user, injects [USER_IDENTITY] block into prependContext - /verify <token>: validates JWT (HS256) or calls external endpoint, links channel identity to verified user, merges cross-channel - /register <first> <last>: channel-only fallback for users without tokens - /whoami: displays current identity status and linked channels - JWT verification uses Node built-in crypto (zero external deps) - Supports verify-endpoint mode for apps with custom token validation Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(persist-user-identity): identity contract for downstream plugins and revised PRD IDENTITY_CONTRACT.md defines: - [USER_IDENTITY] prependContext block format (fields, statuses) - Three consumption patterns: parse context, direct DB query, memory scoping key - Priority ordering convention (identity@60 > persistence@50 > memory@0) - SQL examples for joining lp_users with lp_conversations/lp_messages - Configuration reference for jwt-hs256 and verify-endpoint modes PRD updated to reflect two-layer architecture split: - Layer 1 (persist-user-identity): user persistence + identity unification [complete] - Layer 2 (auth-memory-gate): memory scoping via resolved identity [pending] Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(auth-memory-gate): LLM-facing identity scope injection plugin Injects [MEMORY_SCOPE] block into agent prompts via before_agent_start hook. Queries persist-user-identity tables (lp_users + lp_user_channels) to resolve canonical user scope from session key, providing the LLM with cross-channel user awareness. - Scope resolution with external_id preference over internal user_id - Configurable priority (default 40) and databaseUrl - 28 unit tests covering scope derivation and plugin behavior Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(memory-graphiti): graph memory plugin with cross-channel identity strategy Graph-based knowledge memory plugin supporting Zep Cloud and self-hosted Graphiti backends. Includes groupIdStrategy: "identity" for cross-channel per-user memory isolation via persist-user-identity DB tables. Cherry-picked base from feat/graphiti branch with identity strategy additions: - config: "identity" strategy + databaseUrl config with DATABASE_URL fallback - identity.ts: session key parsing + DB-backed scope resolution - index.ts: async identity resolution in before_agent_start and agent_end hooks - Auto-recall (fact injection) and auto-capture (episode ingestion) - graphiti_search and graphiti_episodes tools - 65 unit tests (base) + 10 identity tests Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(auth-memory-gate): add hard identity gate with message_sending safety net Add hardGate mode that locks the agent to verification-only conversation until users run /verify or /register. Implements: - formatHardGateSystemPrompt: IDENTITY_GATE block injected via prependContext - formatHardGateReplyAppend: CTA appended to outgoing messages for gated peers - message_sending hook (priority 30) as safety net for LLM non-compliance - In-memory gatedPeers set tracking, cleared on successful identity resolution - gate_eligible field in persist-user-identity unregistered context - Tests for all new hard gate functions and plugin behavior Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(identity-stack): document hard gate flow, plugin relationships, and integration guide - auth-memory-gate/README.md: user-facing overview with hard/soft gate modes - auth-memory-gate/MEMORY_SCOPE_CONTRACT.md: IDENTITY_GATE block format, safety net, upgrade path - memory-graphiti/README.md: identity groupIdStrategy and cross-channel memory section - docs/concepts/identity-scoped-memory.md: unified integration guide for the 4-plugin stack Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(identity-stack): rewrite feature documentation with source-verified accuracy Rewrite docs/concepts/identity-scoped-memory.md from scratch based on actual source code analysis of all 4 plugins. Corrects execution order, documents JWT authentication methodology, adds context block reference, clarifies that memory-graphiti queries DB independently (does not parse [MEMORY_SCOPE] block). Add integration test (auth-memory-gate/src/integration.test.ts) that validates the full chain against a live PostgreSQL database: - Hard gate for unregistered users - Guest registration with channel-only scope - Token verification upgrades scope_key to external_id - Cross-channel linking shares scope_key - Graphiti group_id matches gate scope_key 7 integration tests, 101 total tests passing across 4 test files. Co-Authored-By: Claude Opus 4.6 <[email protected]> * test(identity-e2e): 37-case E2E suite for identity-scoped memory pipeline Validates the full 4-plugin chain (persist-user-identity → persist-postgres → auth-memory-gate → memory-graphiti) against real PostgreSQL and Zep Cloud. Test groups: - Session key parsing: deriveChannel/derivePeerId cross-plugin agreement for WhatsApp, Slack, webchat, shared sessions, and edge cases (12 tests) - Hard gate lifecycle: unregistered → /register → /verify → scoped memory (5) - Multi-channel convergence: same user across WhatsApp+Slack shares scope_key, guest user isolated to UUID-based scope (5) - Zep Cloud isolation: userA's facts invisible to userB, 404 = isolation (4) - messageProvider override: takes priority over sessionKey for channel (3) - JWT verification: valid/invalid/expired/missing-sub tokens (4) - Full pipeline agreement: resolveScope and resolveIdentityScopeKey produce identical keys for all channels (4) Also adds: - scripts/test-identity-e2e.sh — runner with --setup/--teardown flags - Testing section in docs/concepts/identity-scoped-memory.md - PRD phase 2d marked complete Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(slack-bot): startup script for Slack bot with identity-scoped memory Adds scripts/start-slack-memory-bot.sh — a turnkey script that configures and starts OpenClaw as a Slack bot with the full 4-plugin identity + memory stack. Key configuration: dmScope: "per-channel-peer" so session keys encode the Slack user ID (agent:main:slack:direct:{userId}), enabling the identity plugins to resolve cross-channel scope. Also documents the Slack deployment workflow and the critical dmScope setting in docs/concepts/identity-scoped-memory.md. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat: externalize secrets, enable all channels, fix whoami command - Remove hardcoded Slack tokens, database URLs, and Graphiti API key from openclaw.json — now read from env vars (SLACK_BOT_TOKEN, DATABASE_URL, etc.) via verified fallback chains - Enable WhatsApp channel and voice-call (Twilio) plugin in config - Expand plugin allowlist from 4 to 6 (+ whatsapp, voice-call) - Add .env.example with Longevity Clinic section (DATABASE_URL, TWILIO_*, GRAPHITI_API_KEY) - Remove 'whoami' from RESERVED_COMMANDS in plugin command registry so persist-user-identity plugin can register its /whoami handler - Add GitHub Actions deploy-fly.yml for automated Fly.io deployment * ci: enable Fly.io deploy on feat/auth-memory-gate branch * feat: set Cerebras as default LLM model for production Set cerebras/qwen-3-235b-a22b-instruct-2507 as the primary model in project-level openclaw.json so it applies on Fly.io deployment. * ci: trigger deploy with org-level Fly token * chore: trigger CI/CD deploy * feat(catch-phrases): modular auto-response plugin for trigger phrases Create extensions/catch-phrases/ — a configurable plugin that matches incoming messages against a list of trigger phrases and instructs the agent to respond with predefined text. Architecture: - Phrases defined in openclaw.json plugins.entries.catch-phrases.config - Supports matchMode: startsWith (default), exact, contains - Uses before_agent_start hook at priority 200 to inject response - Works across all channels (Slack, WhatsApp, etc.) Adding new phrases: just add entries to the "phrases" array in config. First phrase: "I want to bring health & joy to the world..." → "Aye aye, that's the way to a prosperous race!..." * feat(auth): add passcode-endpoint auth mode for cross-channel identity verification Add name-based identification (!identify) and 6-digit passcode verification flow to replace JWT-only !verify. Users on Slack/WhatsApp can now verify by providing their name (fuzzy matched via Syntropy Journals API) then entering a short-lived passcode from the app. Changes: - persist-user-identity: new passcode-endpoint auth mode, !identify command, modified !verify to auto-detect 4-10 digit codes, pendingIdentify Map - auth-memory-gate: conversational gate UX (name→passcode flow) - openclaw.json: switched to passcode-endpoint mode - Config schema: passcodeVerifyUrl, userLookupUrl, apiToken fields * chore: update fly app name to shrine-openclaw, gitignore FLY_SETUP.md * feat(syntropy): add consolidated Syntropy Health plugin with identity gate, token storage, and 9 health tools - extensions/syntropy/: single plugin owning identity gate (priority 35), token storage (syntropy_tokens table), and 9 MCP health tools - persist-user-identity: capture auth_token from pairing verify response, store in syntropy_tokens via SQL upsert - openclaw.json: replace syntropy-tools with syntropy in allow list + config - docs/deployment/headless-syntropy.md: headless deployment guide Ref: PRD Phase 4b — openclaw-syntropy-pairing-bridge * chore: update pnpm-lock.yaml for new extensions Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(nemoclaw): add sandbox policy presets, agent manifest, and deployment config Network policy presets (syntropy, zep, whatsapp, postgresql), agent manifest for syntropy-openclaw, sandbox-adapted openclaw.json, combined policy, bootstrap deploy script, and headless deployment docs. Ref: NemoClaw-Syntropy Migration PRD Phase 1 Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(nemoclaw): address code review findings — TLS, Landlock, placeholders - Add tls: terminate to Slack REST entries in combined policy - Replace Railway proxy hostname with fail-safe placeholder - Fix deploy script: handle Landlock read-only path for openclaw.json - Add Twilio voice-call port to forward_ports in agent manifest - Document requireVerified: false rationale in openclaw.json - Annotate slack preset source in manifest _policy_additions Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(syntropy): align meal_type with canonical MealType enum (6 values) (#10) Plan task 4.1 from .claude/plans/2026-05-07-ci-schema-cleanup.md. Closes a silent contract drift between this plugin's tool argument schemas and SyntropyJournal's canonical contracts.py: contracts.py:MealType (6 values): BREAKFAST, LUNCH, DINNER, SNACK, SUPPLEMENT, BEVERAGE tools.ts (before this PR): 'breakfast, lunch, dinner, or snack' (4 values, free-form string) The drift surfaces as user-visible failures: when a user logs a supplement or beverage, the LLM's tool schema doesn't list those values, so it either omits the meal_type or guesses an invalid one. The SJ MCP server validates server-side and returns 4xx, manifesting as a confusing error in the chat. Changes: 1. New MealTypeSchema constant — Type.Union of 6 Type.Literal values, mirrors contracts.py:MealType exactly. TypeBox validates input before the network call; LLM sees the exact enum in the tool schema (better tool-call accuracy). 2. syntropy_log_food.meal_type → MealTypeSchema (line 52). syntropy_analyze_food.meal_type → MealTypeSchema (line 116). 3. Header comment block documenting the schema source of truth and the alignment requirement. This is the OpenClaw side of the same fix the mobile codegen will get in a follow-up. Long-term the right move is to generate TypeBox schemas from shared/schemas/syntropy.schema.json as part of the parent monorepo's schema-drift workflow; this PR is a minimal targeted fix while that infra is built. --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
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
Stacked PR targeting
feat/openclaw-syntropy-integration(the parent PR #9). Closes a silent contract drift between this plugin's tool argument schemas and SyntropyJournal's canonicalcontracts.py.The drift
contracts.py:MealTypedefines 6 values:But
extensions/syntropy/src/tools.tswas advertising only 4 to the LLM:User-visible impact: when a user logs a supplement or beverage, the LLM's tool schema doesn't list those values, so it either omits
meal_typeor hallucinates an invalid one. The SJ MCP server validates server-side and returns 4xx, manifesting as a confusing error in chat.Changes
New
MealTypeSchema—Type.Unionof 6Type.Literalvalues, mirrorscontracts.py:MealTypeexactly. TypeBox now rejects invalid values before the network call; the LLM sees the exact enum in the tool schema (better tool-call accuracy).syntropy_log_food.meal_type→MealTypeSchema(line 52)syntropy_analyze_food.meal_type→MealTypeSchema(line 116)Header comment block documenting the schema source of truth (
contracts.py+shared/schemas/syntropy.schema.json) and the alignment requirement.Why a stacked PR (not a separate one)
extensions/syntropy/only exists onfeat/openclaw-syntropy-integration(PR #9), not onmain. This PR targets that branch so the fix lands as part of the same line of work — either (a) merge this into PR #9's branch first, then merge #9 to main, or (b) include this commit as part of #9's squash if you prefer.Verification
npx tsc --noEmit -p tsconfig.json: no new errors in tools.ts (pre-existing unrelated errors inextensions/bluebubbles/src/monitor.test.tsare not introduced by this PR)Type.Union([Type.Literal(...)])is the established pattern for enum encoding in TypeBoxLong-term
The right move is to generate TypeBox schemas from
shared/schemas/syntropy.schema.jsonas part of the parent monorepo'sschema-driftworkflow. That eliminates the entire class of drift. This PR is a minimal targeted fix while that infra is built. Tracked in plan task 4.1.Other tools' parameters
Audited remaining 7 tools (
get_diet_score,get_diet_gap,get_health_snapshot,analyze_foodnon-meal-type args,get_health_profile,get_my_checkins,chat_with_shrine,log_checkin): they take onlystringandnumbertypes with no enum constraints, so no drift surface beyondmeal_type.