fix(llm): route semantic calls through SubLLM - #88
Conversation
There was a problem hiding this comment.
Deterministic Validator approval for exact head 4c35747ae4a8c7ca1fca1187ef56ab0d1675b03e.
Ticket: ticket-074
Correlation ID: todo2code-pr-88-4c35747ae4a8
Model: openrouter/z-ai/glm-5.2
Reviewed diff chunks: 5
Advisory LLM verdict: APPROVE
Advisory summary: Reviewed all 5 diff chunk(s). This chunk covers ticket documentation, changelog, and metadata updates for ticket-074. The changes are well-structured documentation artifacts describing the SubLLM routing implementation. No executable code changes are present in this chunk. All visible test checks in test_results_data show PASS (with expected SKIPPING for governance and opt-in live contract). No security issues, credential exposure, or workflow modifications are present in the visible diff. | This chunk adds SubLLM routing integration to the LLM boundary, including audit configuration that reports effective routing (subllm vs direct), provider transport abstraction in OpenRouterClient, and governance metadata for ticket-074. The audit function safely reports secret-free route metadata and handles three states (resolved, unresolved, invalid-configuration). The transport refactor correctly uses provider-specific credentials and API bases. Test results show all checks passing. | This diff refactors the OpenRouter client to support a transport abstraction layer, enabling routing through a central SubLLM policy (preferring direct Z.AI GLM 5.2 with OpenRouter as fallback). The changes introduce a LlmTransport interface, provider-specific request body preparation, and dynamic provider labeling in error messages. The implementation fails closed when no credential is configured, avoids cross-provider replays once a request begins, and maintains standalone OpenRouter behavior outside Subactor integration. No credential values are exposed in error messages; redaction is preserved via redactProviderFailureText. Test results show verify passing with no failures. | This chunk adds provider-aware labeling to OpenRouter response errors and introduces a new SubLLM module that resolves provider routes, reads credentials securely from shared files with file mode validation, and redacts diagnostics. The code validates external JSON output defensively, enforces HTTPS-only API base URLs, restricts inherited environment variables, and uses O_NOFOLLOW to prevent symlink attacks on credential files. No credential values are printed or logged. Tests pass per the provided test results data. | This chunk adds a test file (test/subllm.test.ts) and supporting implementation for SubLLM route resolution. The test validates credential isolation (unrelated process secrets are not forwarded), credential redaction in diagnostics and audit output, fail-closed behavior when SubLLM is unavailable, and correct structured Z.AI request routing. The redactDiagnostic function properly masks API keys and Bearer tokens. All visible test_results_data checks pass.
Advisory findings: {'severity': 'info', 'file': 'test/subllm.test.ts', 'note': 'Test correctly verifies that unrelated process secrets (T2C_UNRELATED_SECRET) are not forwarded to the SubLLM subprocess, and that credential values (fixture-value) do not appear in route JSON, request bodies, or audit output. Fail-closed test confirms policy-bypass credentials are not leaked in error messages.'}
The LLM output above is advisory and was not used as the approval trust root.
Merge was not requested or performed.
Decision record (recomputable)
DECISION D-074-3928
TICKET ticket-074
HEAD_SHA 4c35747ae4a8c7ca1fca1187ef56ab0d1675b03e
CORRELATION_ID todo2code-pr-88-4c35747ae4a8
ACTOR agent:ifuri-validator-agent[bot]
APPLIED_RULE P-CORE-015
INPUT author_login = "tom-sapletta-com"
INPUT observed_checks = ["governance=SKIPPING","Live OpenRouter contract (opt-in)=SKIPPING","verify=PASS","Java adapter (JDK 17 required)=PASS","koru / code-review=PASS","governance=SKIPPING","Live OpenRouter contract (opt-in)=SKIPPING","verify=PASS","Java adapter (JDK 17 required)=PASS"]
INPUT required_checks = ["verify","Java adapter (JDK 17 required)","koru / code-review"]
INPUT required_checks_source = "env/request"
INPUT reviewer_login = "ifuri-validator-agent[bot]"
VERDICT APPROVE AUTHORITY DETERMINISTIC
REJECTED REQUEST_CHANGES BECAUSE NO_UNSAFE_CHANGE_REASON_FOUND
ADVISORY llm_verdict = "APPROVE" MODEL "openrouter/z-ai/glm-5.2"
ASSERT VERDICT_AUTHORITY != "ADVISORY"
Outcome
Routes Subactor-owned todo2code semantic requests through the central SubLLM policy. Direct Z.AI GLM 5.2 is preferred, OpenRouter remains the configured fallback, and todo2code identity is sent to provider logs.
Safety
Validation
Ticket: ticket-074