Skip to content

feat: grok-bot host driver (driver-synthesized lifecycle for Grok Bot) - #7

Merged
rockyshi1993 merged 15 commits into
mainfrom
feat/grok-bot-host
Oct 23, 2026
Merged

rockyshi1993 merged 15 commits into
mainfrom
feat/grok-bot-host

Conversation

@rockyshi1993

@rockyshi1993 rockyshi1993 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a grok-bot host 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: variant grok-bot/driver-synthesized-local-stdio, entry surface grok-bot-driver, aliases, surface driver-synthesized.
  • mcp/agent-identity.cjs: DEVCODEX_AGENT=grok-bot → grok (no longer unknown-agent).
  • hooks/_runtime/lifecycle-host-adapters.cjs: grok-bot driver host reuses GROK_EVENT_MAP; payload/output tagged devcodexEventProvenance=driver-synthesized; sets DEVCODEX_HOST_VARIANT so SkillRouteBootstrap reports grok-bot/driver-synthesized-local-stdio.
  • hooks/_runtime/host-skill-route-capabilities.v1.json: entry UNVERIFIED, 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 init on the DevCodex source repo now emits ProfileCurrentTruthV1 + currentTruthRef from observed evidence only (package.json, git HEAD, local candidate id, CI matrix, public GitHub release/publish/CI receipts). Missing evidence stays UNVERIFIED and the unchanged ProfileCurrentTruthGate rejects it; sourceCandidate is LOCAL_PENDING, releaseAuthorized:false.
  • scripts/test-grok-bot-host.js (npm run test:grok-bot-host), package files, refreshed content/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 with DEVCODEX_AGENT=grok-bot; PC6 reports observed Git branch + uncommitted count (WARN when dirty); PC4 reads Profile config.mode and is PASS in dev mode only when the caller supplies entry.specRadar. Other hosts are unchanged (UNVERIFIED without evidence).
  • memory_task_admit_v2 receipt now carries ingressWarnings, so a rejected caller ingressRef that fell back to the server projection is no longer silent.
  • observe-tool --tool only namespaces bare DevCodex tool names; native tools (Write/Edit/Bash) pass through (previously became devcodex-profile__Write).
  • Grok plugin Skill: new "Grok Bot (no native hooks)" section + HostParity driver-tier row (no kernel rules duplicated).
  • Regenerated workflow-root registry (host-parity-scorecard digest) and skill portfolio.

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 with DEVCODEX_AGENT=grok-bot; PC6 reports observed Git branch + uncommitted count (PASS clean / WARN dirty) and an optional entry.activeTask; PC4 reads Profile config.mode and is PASS in dev mode only when entry.specRadar is supplied. Other hosts without evidence keep UNVERIFIED.
  • memory_task_admit_v2 receipt now carries ingressWarnings; a malformed caller ingressRef still falls back to the server-owned projection (deliberate continuity design from 36d3d18, no authority gain) but is no longer silent.
  • observe-tool --tool passes native tool names (Write/Edit/Bash) through instead of prefixing devcodex-profile__.
  • Grok plugin skill: "Grok Bot (no native hooks)" section + HostParity driver-tier row (no kernel rules duplicated).
  • 6f3aeb7: regenerated workflow-root registry (sourceDigest covers host-parity-scorecard.js) and portfolio.

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); restart stops that copy's profile/memory servers so the host respawns them.
  • New provenance level driver-synthesized-host-event: driver events are no longer recorded as trusted-host-event. The envelope, route-decision, semantic-decision, admission and recovery checks accept it only for host variant grok-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 (new reports/ 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: new turn and sessionStatus; free Markdown after a table gets a blank-line separator; content optional (anyOf content/turn/sessionStatus). tools/list stays under the 28 KiB budget.
  • Entry check: PC labels match row content (PC0 版本与运行 / Version, PC2 会话, PC3 执行准备, PC5 宿主 / Host, PC6 工作区 / Workspace, PC7 续接, PC8 流程与方案); template updated; renders in the prompt's language when no languageDecision is given.
  • turn-begin reports profileFreshness + warnings (PROFILE_TRUTH_DRIFT, PROFILE_POSSIBLY_STALE).
  • Grok skill: S04 is not enforceable on the Grok Bot path; freshness warnings; closeout tool; runtime copy.

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 init in the parent workspace (e.g. /workspace), not inside a repo; then devcodex profile init in each project. MCP servers: node <pkg>/mcp/{profile,memory}-server.js <any project root> with env DEVCODEX_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 with driver-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 .devcodex workspace 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

  • Events are driver-synthesized; ingress is stored with provenanceLevel trusted-host-event internally.
  • PreToolUse is observational only, not enforced.
  • The generated DevCodex source Profile goes stale (gitHead/candidateId drift) after each commit; refresh with scripts/refresh-profile-current-truth.js or re-init.
  • memory_task_admit_v2 deliberately 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 via ingressWarnings.
  • Mounted connectors run code from the checkout; they must be restarted after code changes or branch switches.

Orphaned task recovery binding (23e8ede)

  • A TaskRecoveryBinding whose task folder was removed outside DevCodex no longer drives resume rehydration or the admission bounded-resume fallback. isTaskRecoveryBindingOrphaned (task-recovery-store-v5) is checked in rehydrateBoundedResumeIngress, which drops the binding (reasonCode=task-root-missing), and in readServerOwnedAdmissionIngress.
  • Regression in test-grok-bot-host: remove the task folder, then the next tool event clears the binding, and admission without ingressRef succeeds.
  • Verified live on monSQLize through the mounted connectors: the stale binding was dropped and memory_task_admit_v2 without ingressRef returned active.

Required CI green (abf9a3b, 760ec4e)

  • Codex CLI skill-route capability demoted from PASS to UNVERIFIED (defaultEligible=false). The old S15 evidence digests were stale against the current runtime contract (this was also red on main). A real-host replay with probe-skill-route-s15-host.js --host codex on codex-cli 0.155.1 failed every time, in both isolated and production mode and also on origin/main: after commit, the host recovery instruction forces an immediate load_stage, which conflicts with the probe's conditional replan. No promotable evidence was obtained, and none was fabricated. Re-promote with refresh-host-skill-route-capability.js once a real replay passes.
  • memory_turn_closeout_v1 is now registered in the docs-surface inventory and in the reserved DevCodex mutation tool leaves.
  • CI run 39953329158: all jobs succeeded, including Required validation aggregate.

Terminal closeout producer (3d8cf37)

  • memory_turn_closeout_v1 gains an optional terminal block: 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 fenced memory_task_terminal_v1. completed still requires a verified CP1.

Per-session isolation for Grok Bot (1b2b25f, 38c8a5a)

  • Root cause: every Grok Bot conversation shared DEVCODEX_HOST_SESSION_ID=grok-bot-session and one lifecycle-state.json per project, so concurrent conversations overwrote each other's phase / recovery binding / admission / route state.
  • Driver: --session-id <id> on turn-begin, observe-tool, run; observe-tool rejects connector args whose hostSession is missing or names another session.
  • Connectors: per-call hostSession (advertised only for grok-bot), validated and scoped to exactly one call (the JSON-line transport serializes requests); a contextBinding minted for another session is rejected (HOST_SESSION_INVALID).
  • State: grok-bot only, .memory/hooks/<project>/.sessions/<id>/ (default grok-bot-session keeps the old location so existing tasks stay reachable). Other hosts unchanged.
  • Tests: two interleaved sessions on one project (no clobbering, separate recovery bindings, cross-session terminal close refused, strict id validation). Verified live via the mounted connectors.

…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
…ligned PC labels + prompt-language entry check, profile freshness warnings
…mpletion evidence and runs the fenced terminal
@rockyshi1993
rockyshi1993 merged commit 601469d into main Oct 23, 2026
15 checks passed
@rockyshi1993
rockyshi1993 deleted the feat/grok-bot-host branch October 23, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant