Repository navigation
feat: grok-bot host driver (driver-synthesized lifecycle for Grok Bot) - #7
Merged
Merged
Conversation
…codex grok-bot CLI
…strap, DevCodex source profile truth - observe-tool: --args-file, --response-file (strips Grok Bot untrusted-data fence, rebuilds CallToolResult), required --project-dir - driver host sets DEVCODEX_HOST_VARIANT=grok-bot/driver-synthesized-local-stdio - profile init for the DevCodex source repo emits ProfileCurrentTruthV1 from observed evidence only - refresh skill portfolio; tests + changelog
…ngressWarnings, native tool passthrough, Grok skill section
…t-event provenance
…ligned PC labels + prompt-language entry check, profile freshness warnings
…der no longer exists
…ntory and reserved mutation tools
…mpletion evidence and runs the fenced terminal
…ion for concurrent conversations
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
Adds a
grok-bothost for Grok Bot (desktop assistant): it mounts stdio MCP servers and loads skills but has no native lifecycle hook events. A driver synthesizes lifecycle events so ContextRead → SkillRoute → TaskAdmission works end-to-end through the bot's own mounted MCP connectors.Changes
hooks/_runtime/host-adapter-identity.cjs: variantgrok-bot/driver-synthesized-local-stdio, entry surfacegrok-bot-driver, aliases, surfacedriver-synthesized.mcp/agent-identity.cjs:DEVCODEX_AGENT=grok-bot→grok(no longerunknown-agent).hooks/_runtime/lifecycle-host-adapters.cjs:grok-botdriver host reusesGROK_EVENT_MAP; payload/output taggeddevcodexEventProvenance=driver-synthesized; setsDEVCODEX_HOST_VARIANTso SkillRouteBootstrap reportsgrok-bot/driver-synthesized-local-stdio.hooks/_runtime/host-skill-route-capabilities.v1.json: entryUNVERIFIED,defaultEligible:false.scripts/lib/grok-bot-driver.js+devcodex grok-bot:turn-begin <projectDir> <prompt>observe-tool --project-dir <dir> --phase pre|post --tool devcodex-profile__x|devcodex-memory__x --tool-use-id <id> --args-file <f> [--response-file <raw host output>]— strips Grok Bot's untrusted-data fence and rebuilds the MCP CallToolResult; one shell call per pre/post.run <projectDir> <prompt>full-turn mode.scripts/lib/devcodex-source-profile-truth.js:devcodex profile initon the DevCodex source repo now emitsProfileCurrentTruthV1+currentTruthReffrom observed evidence only (package.json, git HEAD, local candidate id, CI matrix, public GitHub release/publish/CI receipts). Missing evidence staysUNVERIFIEDand the unchangedProfileCurrentTruthGaterejects it;sourceCandidateisLOCAL_PENDING,releaseAuthorized:false.scripts/test-grok-bot-host.js(npm run test:grok-bot-host), packagefiles, refreshedcontent/skills/portfolio.json, changelog.Entry check (S07) for grok-bot — commit 6461d5d
profile_compose_entry_check: PC5 reports the Grok Bot driver tier (WARN, Partial-like, never Full) when the connector runs withDEVCODEX_AGENT=grok-bot; PC6 reports observed Git branch + uncommitted count (WARNwhen dirty); PC4 reads Profileconfig.modeand isPASSin dev mode only when the caller suppliesentry.specRadar. Other hosts are unchanged (UNVERIFIEDwithout evidence).memory_task_admit_v2receipt now carriesingressWarnings, so a rejected caller ingressRef that fell back to the server projection is no longer silent.observe-tool --toolonly namespaces bare DevCodex tool names; native tools (Write/Edit/Bash) pass through (previously becamedevcodex-profile__Write).Entry check (S07) for grok-bot — commit 6461d5d
profile_compose_entry_check: PC5 reports the Grok Bot driver tier (WARN, Partial-like, never Full) when the connector runs withDEVCODEX_AGENT=grok-bot; PC6 reports observed Git branch + uncommitted count (PASSclean /WARNdirty) and an optionalentry.activeTask; PC4 reads Profileconfig.modeand isPASSin dev mode only whenentry.specRadaris supplied. Other hosts without evidence keepUNVERIFIED.memory_task_admit_v2receipt now carriesingressWarnings; a malformed calleringressRefstill falls back to the server-owned projection (deliberate continuity design from 36d3d18, no authority gain) but is no longer silent.observe-tool --toolpasses native tool names (Write/Edit/Bash) through instead of prefixingdevcodex-profile__.Runtime pinning, provenance, closeout — commits a78456c, 9f73fdc
scripts/grok-bot-runtime.sh update|restart|status: connectors and driver run from a clean runtime copy (default/workspace/devcodex-runtime, fast-forward only, refuses a dirty copy);restartstops that copy's profile/memory servers so the host respawns them.driver-synthesized-host-event: driver events are no longer recorded astrusted-host-event. The envelope, route-decision, semantic-decision, admission and recovery checks accept it only for host variantgrok-bot/driver-synthesized-local-stdio; a forged level on any other variant fails validation (driver-provenance-host-variant). Other hosts unchanged.memory_turn_closeout_v1: one call writes an optional report (newreports/file, authorized through the same operational write lease), allocates/reuses the session, appends a numbered 📨 row, sets the status line, and appends SUMMARY.memory_session_write: newturnandsessionStatus; free Markdown after a table gets a blank-line separator;contentoptional (anyOf content/turn/sessionStatus). tools/list stays under the 28 KiB budget.languageDecisionis given.turn-beginreportsprofileFreshness+warnings(PROFILE_TRUTH_DRIFT,PROFILE_POSSIBLY_STALE).Verified end-to-end via the bot's mounted connectors (CallDynamicTool only)
monSQLize and devcodex (fix intent), mounted connectors only: turn-begin → profile_compose_entry_check (PC0–PC10: PC4 PASS, PC5 WARN grok-bot tier, PC6 PASS clean / WARN dirty) → profile_context_plan(semanticDecision) → post observe-tool routeStatus=selected → profile_load(files) → memory_status → skill_route catalog×3 → commit → memory_task_admit_v2 (ingressRef omitted, ingressWarnings []) → memory_session_allocate/write + summary_append; devcodex also operational write lease + report file ⇒
FormalTaskAdmissionReceiptV2 status=active, ingressSource=host-hook, ingressWarnings=[]→ memory_session_allocate/write, memory_summary_append (monSQLize), operational write lease + report file (devcodex). Test tasks deleted.Usage prerequisite
Run
devcodex initin the parent workspace (e.g./workspace), not inside a repo; thendevcodex profile initin each project. MCP servers:node <pkg>/mcp/{profile,memory}-server.js <any project root>with envDEVCODEX_AGENT=grok-bot DEVCODEX_HOST_PLATFORM=grok DEVCODEX_HOST_SESSION_ID=grok-bot-session, started after the workspace layout exists.Re-verified on monSQLize after 9f73fdc (driver from
/workspace/devcodex-runtime): Chinese PC0–PC10 table (PC4 PASS, PC5 宿主 WARN driver tier, PC6 工作区 PASS) → plan selected → load → memory_status relevant-complete → catalog×3 → commit fix-default → admission active/finalized withdriver-synthesized-host-event→memory_turn_closeout_v1(report + row + 🔄 进行中 + SUMMARY). Test tasks removed.Tests (clean checkout outside any workspace)
✅ validate.js, validate-versions, test:grok-bot-host, test-mcp-servers, test:host-adapters, test-skill-route-contracts, test-hooks-runtime, test:mcp-stdio, test-cli-behavior, test-cli-json-contract, test-host-capability-routing, test-validate-profile, test-profile-materialization-stage-b
❌ test-global-host-config.js — pre-existing on main (stale codex runtimeContractDigest in host-skill-route-capabilities.v1.json; actual digest identical on main and branch).
✅ also: test-v1178-batch-d, test-grok-bot-host (closeout/provenance/freshness), test-visible-output-contract, test-host-parity-scorecard, test-host-parity-remaining, test-pending-session-binding, test-artifact-mutation-authority, test-host-installation, test-skill-route-contracts (after registry regen), validate.js
Note: inside a directory that has a parent
.devcodexworkspace with a draft devcodex Profile, validate.js/test-validate-profile check that real Profile and fail on draft content — environmental, not a code regression.Limitations
trusted-host-eventinternally.scripts/refresh-profile-current-truth.jsor re-init.memory_task_admit_v2deliberately falls back to the server-owned projection when a supplied ingressRef is invalid/stale (continuity design from 36d3d18); authority is never taken from the caller ref, and the fallback is now reported viaingressWarnings.Orphaned task recovery binding (23e8ede)
TaskRecoveryBindingwhose task folder was removed outside DevCodex no longer drives resume rehydration or the admission bounded-resume fallback.isTaskRecoveryBindingOrphaned(task-recovery-store-v5) is checked inrehydrateBoundedResumeIngress, which drops the binding (reasonCode=task-root-missing), and inreadServerOwnedAdmissionIngress.test-grok-bot-host: remove the task folder, then the next tool event clears the binding, and admission withoutingressRefsucceeds.memory_task_admit_v2withoutingressRefreturned active.Required CI green (abf9a3b, 760ec4e)
PASStoUNVERIFIED(defaultEligible=false). The old S15 evidence digests were stale against the current runtime contract (this was also red onmain). A real-host replay withprobe-skill-route-s15-host.js --host codexon codex-cli 0.155.1 failed every time, in both isolated and production mode and also onorigin/main: after commit, the host recovery instruction forces an immediateload_stage, which conflicts with the probe's conditional replan. No promotable evidence was obtained, and none was fabricated. Re-promote withrefresh-host-skill-route-capability.jsonce a real replay passes.memory_turn_closeout_v1is now registered in the docs-surface inventory and in the reserved DevCodex mutation tool leaves.Terminal closeout producer (3d8cf37)
memory_turn_closeout_v1gains an optionalterminalblock: renders ECR + completion checklist from real turn data under<taskRoot>/evidence/closeout/, cites report/session-memory digests, reads the owner CAS state and runs the fencedmemory_task_terminal_v1.completedstill requires a verified CP1.Per-session isolation for Grok Bot (1b2b25f, 38c8a5a)
DEVCODEX_HOST_SESSION_ID=grok-bot-sessionand onelifecycle-state.jsonper project, so concurrent conversations overwrote each other's phase / recovery binding / admission / route state.--session-id <id>onturn-begin,observe-tool,run; observe-tool rejects connector args whosehostSessionis missing or names another session.hostSession(advertised only for grok-bot), validated and scoped to exactly one call (the JSON-line transport serializes requests); acontextBindingminted for another session is rejected (HOST_SESSION_INVALID)..memory/hooks/<project>/.sessions/<id>/(defaultgrok-bot-sessionkeeps the old location so existing tasks stay reachable). Other hosts unchanged.