Keep moving parts explicit and replaceable.
DbClient(src/runtime/db.ts): owns typed Postgres connectivity via Kysely and provides thegravityschema handle.SlackTransport(src/runtime/slack-transport.ts): owns Slack Socket Mode connection, inbound event normalization, and channel-scoped message queueing.defineConfig/defineAgentcontracts (agents/contracts.ts): canonical code-defined configuration and agent declaration authoring model.AgentRegistry(agents/index.ts): typed registry assembly with duplicateagentIdand slash-command collision guards.CompiledAgentDeclarations(agents/index.ts): code-defined ingress/proactive/session declarations compiled fromdefineConfig+defineAgentcontracts for runtime cutover.SurfaceAdapter: surface-specific ingress/egress adapters (Slack now; additional surfaces later).AgentSpecRepository: transitional repository seam while behavior source moves offgravity.agents.config.EventIdempotencyGuard(src/runtime/event-idempotency.ts): blocks duplicate source events across slash and non-slash ingress paths.SessionKeyBuilder(src/runtime/session-key.ts): canonical builders for mode-dependent session key patterns across slash, message, and proactive entrypoints.SessionResolver: resolvessessionKeyand session mode (thread,main,isolated) per trigger.SessionCatalog: stores and resolves session metadata ingravity.sessions(ownership, mode, status) while keeping full transcript/context inworkspace/files, including explicit close transitions for idle/shutdown hooks and guarded stale-callback close checks (closeSessionIfUnchanged).ResourcePlugin(src/resources/types.ts): typed resource interface (load(...)) with discriminated resource specs and compile-time contribution contracts.ResourceRegistry(src/resources/registry.ts): statically maps all resource kinds to plugins with exhaustive compile-time coverage checks and resolves per-turn resource contributions.CapabilityCatalog(agents/capability-catalog.ts): canonical catalog of capability definitions (resourceSlots,skills, and tool grants).CapabilityBindingContract(agents/contracts.ts): typeduseCapabilities[]+bindResourcesagent contract with compile-time slot/resource-kind checks.CapabilityCompiler(agents/capability-compiler.ts): compiles capability bindings into per-agent runtime capability profile (required skills/resources + tool grants).SkillResolver(src/runtime/context-assembler.ts): resolves capability-derived shared skill IDs to shared skill markdown each turn (no caching).MemoryStore: loads/writesMEMORY.mdper agent.ContextAssembler(src/runtime/context-assembler.ts): builds per-turn system context from compiled capability profile + memory + resource contributions.SessionHistoryStore(src/runtime/session-history-store.ts): owns dual-history file contract (log.jsonl,context.jsonl,agent-log.jsonl) and pre-run log-to-context sync with source-event dedupe markers plus explicit replay-exclusion metadata (skipContextReplay).SlackThreadHistory(src/runtime/slack-thread-history.ts): shared thread-message contract used by Slack transport and startup backfill seams.SessionStartupBackfill(src/runtime/session-startup-backfill.ts): startup seam that reconciles active Slack thread sessions and appends missed thread messages into session logs before runs.SessionOverflowRecovery(src/runtime/session-overflow-recovery.ts): fail-safe helper that compacts and retries once when prompt execution throws context-overflow errors.SessionIdleEvictionCoordinator(src/runtime/session-idle-eviction.ts): idle timer + callback orchestrator that triggers session-end close flows (idle_evictionand shutdown).SessionEndMemoryHook(src/runtime/session-end-memory-hook.ts): silent memory-write hook that runs a final model turn on idle close, appends hook input/output records to session log, and enforces skip guards (missing_api_key,missing_memory_path).TurnRunner(PiAgentRunnerfor CP4/CP6): executes one model turn viapi-coding-agent, applies pre-run sync, compaction/retry settings, and overflow recovery.DeliveryAdapter: posts acknowledgements/final responses using surface-specific delivery defaults.SessionStore: implemented throughSessionHistoryStoreandSessionManagerfor per-sessionlog.jsonlandcontext.jsonllifecycle.RunLifecycleLogger(src/runtime/run-lifecycle.ts): emits typed run lifecycle events with stable IDs (runId,agentId,sessionKey) and lifecycle stages (started,completed,failed).RunLogStore(src/runtime/run-log-store.ts): maps lifecycle stages into durablegravity.runsinserts/updates.ExecutorManager(src/runtime/executor-manager.ts): single executor dispatch seam for all tool execution with per-agent runtime selection, fail-closed sandbox policy decisions (allow/deny+ reason), and force-host fail-closed mode (GRAVITY_SANDBOX_FORCE_HOSTdenies sandbox-declared runs).ToolDispatcher: single dispatch seam for all tool execution (implemented throughExecutorManagerin current runtime).ProactiveTriggerScheduler(src/runtime/proactive-trigger-scheduler.ts): runs cron/heartbeat triggers, replays missed proactive runs from persisted history, enforces quiet-hours suppression, and exposes manual wake control for heartbeat demo triggers.
SelfAuthoringIntentDetector(src/runtime/self-authoring-intent.ts): detects teach/update intent and generates the single-turn structured mutation payload used by CP8 mutation transactions.SelfAuthoringTypes(src/runtime/self-authoring-types.ts): shared CP8 transaction types for mutation payloads and stable-ID request context across coordinator, queue, policy, and applier seams.SelfAuthoringMutationCoordinator(src/runtime/self-authoring-mutation-coordinator.ts): orchestrates one self-authoring mutation transaction (request -> authoring turn -> lock -> apply -> audit) for a target agent/session context.SelfAuthoringMutationQueue(src/runtime/self-authoring-mutation-queue.ts): enforces per-agent conflict serialization with FIFO queueing for concurrent self-author requests plus trigger-key dedupe.SelfAuthoringMutationPolicy(src/runtime/self-authoring-mutation-policy.ts): validates proposed mutation targets against CP8 allowlist policy (skills + agent memory only) and rejects all non-allowlisted paths fail-closed.SelfAuthoringMutationApplier(src/runtime/self-authoring-mutation-applier.ts): applies approved self-authored skill/memory deltas to durable stores (store/shared/skills,store/agents/{agentId}/memory/MEMORY.md) with explicit write boundaries.SkillVersionAuditStore(src/runtime/skill-version-audit-store.ts): records self-authored skill evolution metadata ingravity.skill_versionswith stable-ID linkage to request/run context.
PiAgentRunner(src/runtime/pi-agent-runner.ts): executes Pearlboy turns using the same conversational runtime path as other agents.Compliance Guidance Skills(store/shared/skills/compliance-helper-review-rules.md,store/shared/skills/compliance-helper-flag-patterns.md): shared policy guidance surfaced in prompt context for conversational review and follow-up Q&A.
src/runtime/agent-config.tssrc/runtime/ingress-binding-resolver.tssrc/runtime/proactive-trigger-resolver.tssrc/runtime/slash-command-router.tssrc/runtime/trigger-normalizer.ts
- No full multi-surface adapter set beyond Slack yet.
- No full multi-surface ingress matrix beyond Slack entrypoints yet.
- No full sandbox approval-state workflow yet (
request_id, timeout, cancel, pending states; TD-008).
- Legacy seam rollback: removed CP5.1 seams are restored only via revision revert.
DbClientowner: platform runtime layer.DbClientrollback path: swapsrc/runtime/db.tsback to directpgaccess while preserving SQL contracts and migration files.SlackTransportowner: platform runtime layer.SlackTransportrollback path: disable live Slack connection insrc/index.tsand fall back to no-op inbound logging while preserving normalized inbound event contracts.defineConfig/defineAgentcontracts owner: platform runtime layer.defineConfig/defineAgentrollback path: revertagents/contracts.tsto previous declaration shape while preserving required IDs (agentId,sessionKey,runId) in downstream runtime contracts.AgentRegistryowner: platform runtime layer.AgentRegistryrollback path: pinagents/index.tsto previous known-good declarations and keep DB projection unchanged.EventIdempotencyGuardowner: platform runtime layer.EventIdempotencyGuardrollback path: disable runtime pre-run duplicate checks and rely ongravity.runs.source_event_iduniqueness only.SessionKeyBuilderowner: platform runtime layer.SessionKeyBuilderrollback path: revert session-key builders to previous deterministic patterns while preserving DB session metadata and stable IDs.AgentSpecRepositoryowner: platform runtime layer.AgentSpecRepositoryrollback path: read minimal agent fields directly fromgravity.agentsand ignore advanced config blocks.SessionResolverowner: platform runtime layer.SessionResolverrollback path: revert to deterministicsessionKey = {agentId}:{sourceEventId}behavior.SessionCatalogowner: platform runtime layer.SessionCatalogrollback path: resolve sessions fromworkspace/path conventions only while preservinggravity.sessionsschema for forward compatibility.SessionHistoryStoreowner: platform runtime layer.SessionHistoryStorerollback path: bypass log/context sync hooks and write onlycontext.jsonlthroughSessionManagerwhile preserving workspace path conventions.SessionStartupBackfillowner: platform runtime layer.SessionStartupBackfillrollback path: disable startup reconciliation and rely on live inbound events + pre-run sync only.SessionOverflowRecoveryowner: platform runtime layer.SessionOverflowRecoveryrollback path: delegate overflow handling to defaultpi-coding-agentbehavior with no explicit post-error compact/retry wrapper.SessionIdleEvictionCoordinatorowner: platform runtime layer.SessionIdleEvictionCoordinatorrollback path: disable idle timers and keep sessions active until process shutdown while preservinggravity.sessionsschema.SessionEndMemoryHookowner: platform runtime layer.SessionEndMemoryHookrollback path: disableGRAVITY_SESSION_MEMORY_HOOK_ENABLEDand retain session close transitions without silent memory-write turns.ResourceRegistryowner: platform runtime layer.ResourceRegistryrollback path: hardcode a single resource path per agent in runtime code while preserving agent config columns.CapabilityCompilerowner: platform runtime layer.CapabilityCompilerrollback path: inline capability expansion in runner/context code while preserving capability declarations inagents/contracts.ts.SkillResolverowner: platform runtime layer.SkillResolverrollback path: revert context assembly to direct shared skill loading while preserving capability-derived skill IDs.ContextAssemblerowner: platform runtime layer.ContextAssemblerrollback path: inline context assembly in runner code while preserving per-turn reload semantics.RunLifecycleLoggerowner: platform runtime layer.RunLifecycleLoggerrollback path: revert runtime entrypoints to directconsole.logmessages while preserving stable ID fields in log lines.RunLogStoreowner: platform runtime layer.RunLogStorerollback path: keep lifecycle log lines but disablegravity.runswrites fromsrc/index.tswhile retaining the DB schema contract.ExecutorManagerowner: platform runtime layer.ExecutorManagerrollback path: block sandbox-declared runs by settingGRAVITY_SANDBOX_FORCE_HOST=true(orGRAVITY_SANDBOX_ENABLED=false) while keeping runtime policy fields backward-compatible.ProactiveTriggerSchedulerowner: platform runtime layer.ProactiveTriggerSchedulerrollback path: disable scheduler startup and replay/wake control surfaces while preservingproactiveTriggersconfig contracts.SelfAuthoringMutationCoordinatorowner: platform runtime layer.SelfAuthoringMutationCoordinatorrollback path: disable autonomous mutation orchestration and require explicit operator/manual mutation flow while preservinggravity.runslogging contracts.SelfAuthoringMutationQueueowner: platform runtime layer.SelfAuthoringMutationQueuerollback path: disable queueing and execute only when mutation lock is immediately available, with explicit busy-reject responses for conflicts.SelfAuthoringMutationPolicyowner: platform runtime layer.SelfAuthoringMutationPolicyrollback path: disable autonomous mutation policy checks and force manual operator approval for all mutation writes until allowlist enforcement is restored.SelfAuthoringMutationApplierowner: platform runtime layer.SelfAuthoringMutationApplierrollback path: disable autonomous skill/memory writes and require manual operator-authored file updates while preserving request/run lifecycle logging.SkillVersionAuditStoreowner: platform runtime layer.SkillVersionAuditStorerollback path: disablegravity.skill_versionswrites and rely on file history-only audit until DB audit path is restored.PiAgentRunnerowner: platform runtime layer.PiAgentRunnerrollback path: revert inbound execution paths to deterministic echo-only behavior while preservingRunLifecycleLogger+RunLogStorecontracts.
Do not change interface boundaries without updating this file and docs/checkpoints/mvp-status.md in the same change.