Skip to content

gut(agents): remove dead resolveTranscriptPolicy + transcript-policy.ts — middleware-not-platform #2490

@alexey-pelykh

Description

@alexey-pelykh

Context

RemoteClaw is middleware that delegates LLM execution to CLI agents (Claude Code, Gemini, Codex, OpenCode). The CLI agents own LLM API communication, including per-provider message-transcript formatting (how to sanitize tool_call_ids for Google, how to order turns for Gemini, how to preserve thinking signatures for Anthropic, etc.).

src/agents/transcript-policy.ts contains resolveTranscriptPolicy(...) — a function that returns a TranscriptPolicy object describing how to sanitize a transcript for a specific LLM API protocol. Its input parameters (modelApi, provider, modelId) are concerns middleware doesn't have: RemoteClaw doesn't speak LLM API protocols. It relays messages to CLI subprocesses that speak their own CLI-stdio protocols (ACP, Claude Code JSON stream, etc.), which are already abstracted over LLM-API specifics.

This is platform concern masquerading as middleware code. Leftover from the pre-fork embedded execution path.

Problem

Live-by-attestation, dead-by-consumption

  • src/agents/transcript-policy.ts:10-12 declares MODULE_ATTESTATIONS = { resolveTranscriptPolicy: "live" } (enforced by scripts/check-attestations.mjs — the attestation-gate CI check).
  • src/agents/transcript-policy.test.ts exercises resolveTranscriptPolicy with 13+ test scenarios.
  • Zero production callers. Exhaustive search:
    rg -n "resolveTranscriptPolicy" src/ ui/ extensions/ apps/ --type ts -g '!*.test.ts'
    # Returns only the declaration itself
  • The gateway, middleware, and auto-reply paths have zero references to transcript-policy or resolveTranscriptPolicy.

The attestation says "live" but no production code consumes the function. This is an inconsistency: the attestation system records intent, not actual wiring, and here intent has outlived relevance.

The isGoogleModelApi stub at line 14 makes Google policies unreachable

transcript-policy.ts:14 defines a module-local stub:

const isGoogleModelApi = (..._args: unknown[]): boolean => false;

Introduced in #2303 / merge #2333 (gut(stubs): sweep gutted CLI/command/agent stubs and clean up consumers). This stub shadows the REAL isGoogleModelApi function in src/agents/agent-helpers/google.ts (which agent-helpers.ts re-exports). Because the local stub always returns false, every Google-specific branch in resolveTranscriptPolicy is permanently dead:

  • isGoogle = false always → applyGoogleTurnOrdering, validateGeminiTurns, Gemini thought-signature sanitization never activate for Google models.

This would be a genuine bug if the function were wired — but it isn't. It's bug-free-by-death. No need to fix the stub because the whole function goes away.

Imports are shared utilities, NOT orphaned by removal

  • import { normalizeProviderId } from "./provider-utils.js"provider-utils.ts has 20+ importers across auth/, agents/, commands/, cron/. Not orphaned.
  • import type { ToolCallIdMode } from "./tool-call-id.js"tool-call-id.ts has 5+ importers (agent-helpers, session-transcript-repair, agent-helpers/images). Not orphaned.

Scope is cleanly bounded to the file + its test.

Non-goals

  • Don't fix the isGoogleModelApi stub by importing the real function. The file is being deleted; repairing the stub would be dead work.
  • Don't preserve the attestation entry. Removing the file removes its attestation declaration; scripts/check-attestations.mjs scans dynamically and won't complain about a non-existent file.
  • No LEGACY_CONFIG_RULES / migration. This is not a config field — it's a source module. File deletion is the migration.
  • No backward-compat shim. No code depends on the exported symbol.

Tasks

  1. Delete src/agents/transcript-policy.ts (146 lines).
  2. Delete src/agents/transcript-policy.test.ts.
  3. Run pnpm tsgo and pnpm lint to confirm no broken imports (expected: none, since no production code imports from this file).
  4. If the post-build scripts (scripts/post-build.mjs or similar) reference transcript-policy specifically, remove those references. Verify via rg -n "transcript-policy" scripts/.

Acceptance Criteria

  • src/agents/transcript-policy.ts does not exist.
  • src/agents/transcript-policy.test.ts does not exist.
  • rg -n "transcript-policy" src/ ui/ extensions/ apps/ scripts/ returns only references in this issue's body (none in code).
  • rg -n "resolveTranscriptPolicy" src/ returns no hits.
  • rg -n "TranscriptPolicy\\b" src/ returns no hits (the exported type also dies with the file; nothing consumes it).
  • pnpm tsgo clean.
  • pnpm lint clean.
  • pnpm test passes with fewer tests (the 13+ test cases in transcript-policy.test.ts are gone; net decrease expected).
  • All required CI gates pass: rebrand-gate, zombie-import-gate, stub-debt-gate, throwing-stub-callers-gate, obsolescence-audit-gate, attestation-gate (the attestation-gate should be happy because the file's MODULE_ATTESTATIONS is gone along with its exports), docs, build, test, lint.

Out of scope

References

Metadata

Metadata

Assignees

Labels

gutRemoving dead upstream subsystems

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions