Skip to content

feat(miner-hands): define the CodingAgentDriver interface seam #4262

Description

@JSONbored

This is the foundational seam for Phase 3 ("Create + Iterate — the hands"). Everything else in this batch — the CLI-subprocess driver, the Agent-SDK driver, the driver factory, the attempt log, the parity test suite, dry-run mode, the lint-guarded wrapper, cost metering, and the design doc — either implements this interface or consumes it. Confirmed via repo-wide grep: zero hits for CodingAgentDriver anywhere today. This is genuinely greenfield.

The existing precedent to mirror is SelfHostAi in src/selfhost/ai.ts:61-63:

export type AiResult = { response?: string; data?: number[][]; usage?: AiUsage };
export interface SelfHostAi {
  run(model: string, options: AiRunOptions): Promise<AiResult>;
}

A single-method interface that several different backends (openai-compatible HTTP, anthropic HTTP, claude-code CLI subprocess, codex CLI subprocess) all implement identically, selected at runtime by a provider-name string (AI_PROVIDER, parsed in src/selfhost/ai-config.ts). CodingAgentDriver should follow the same shape.

Sibling maintainer-only issue #2333 ("local create->score->self-review iterate-loop orchestrator") already names the expected file path for this seam in its own References section: packages/gittensory-engine/src/miner/coding-agent-driver.ts — a new miner/ subdirectory under the engine package (today's sibling subdirectories are advisory/, github/, governor/, portfolio/, review/, scoring/, settings/, signals/, types/, utils/, focus-manifest/). That same issue also names attempt-log.ts and acceptance-criteria.ts as siblings in that directory — both filed separately in this batch.

Deliverables

  • packages/gittensory-engine/src/miner/coding-agent-driver.ts exporting a CodingAgentDriver interface, mirroring SelfHostAi's single-method shape: one run()-style method taking a scoped local task (working directory, acceptance-criteria file path/content, instructions, a turn/budget ceiling) and returning a structured result (success/failure, changed files, a driver-specific transcript/usage summary). No network calls, no GitHub writes, no autonomous continue/stop decision-making — that orchestration is explicitly issue maintainer: local create->score->self-review iterate-loop orchestrator (the control-flow core) #2333's job, out of scope here.
  • Task/result types stay provider-agnostic: nothing in the interface should assume a subprocess CLI (this batch's CLI-subprocess driver) vs. the Agent SDK's query() loop (this batch's Agent-SDK driver) — both must implement it without leaking provider-specific fields into the shared type.
  • packages/gittensory-engine is otherwise pure/deterministic (its src/index.ts header: "No IO, no Date, no randomness"; reward-risk.ts takes an injected RewardRiskEngineDeps to stay testable despite depending on a non-pure stack) — this interface's implementations MAY perform real IO, but anything a test needs to control (spawn function, clock, filesystem writes) should be an injected parameter, the same way SpawnFn is injected into createClaudeCodeAi/createCodexAi rather than hardcoded (src/selfhost/ai.ts:772, :852).
  • Unit tests for the type-level contract using a minimal fake driver implementing the interface — there's no real behavior yet, but the shape needs to be locked down so the CLI-subprocess and Agent-SDK drivers can implement against it without it shifting under them.
  • Export the new interface + supporting types from packages/gittensory-engine/src/index.ts's barrel, matching its existing grouped-export style with the .js extension convention already used throughout that file.

References

  • src/selfhost/ai.ts:56-63 (AiRunOptions, AiResult, SelfHostAi — the interface shape this seam mirrors)
  • src/selfhost/ai.ts:772, :852 (createClaudeCodeAi, createCodexAi — two concrete SelfHostAi implementations selected by provider name, and the injected-SpawnFn testability convention)
  • src/selfhost/ai-config.ts:41-74 (resolveConfiguredProviderNames/isConfiguredSelfHostProvider — the provider-name-string selection pattern the driver factory, filed separately in this batch, mirrors)
  • packages/gittensory-engine/src/index.ts:1-6 (barrel header: "deterministic, side-effect-free logic" — the DI convention this new module should preserve)
  • Issue maintainer: local create->score->self-review iterate-loop orchestrator (the control-flow core) #2333's References section — names packages/gittensory-engine/src/miner/{coding-agent-driver,attempt-log,acceptance-criteria}.ts as the exact expected paths for this batch's primitives
  • Issue maintainer: PreToolUse-hook-enforced house rules (deny even under bypassPermissions) #2343 ("PreToolUse-hook-enforced house rules") — a maintainer-only sibling that hooks into "the CodingAgentDriver's underlying session," confirming the interface (or at least the Agent-SDK implementation) needs to expose a tool-call interception point

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.gittensor:priorityMaintainer-selected Gittensor priority — scores a 1.5x multiplier.help wantedExtra attention is needed

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions