Skip to content

fix(assistant): preserve conversation process lifecycle evidence - #1100

Open
wcy12378 wants to merge 1 commit into
Tencent:mainfrom
wcy12378:codex/conversation-process-evidence
Open

wcy12378 wants to merge 1 commit into
Tencent:mainfrom
wcy12378:codex/conversation-process-evidence

Conversation

@wcy12378

Copy link
Copy Markdown

Fixes #1086.

The conversation process pool forwarded stdout/stderr but dropped process start, start failure, and exit events. As a result, assistant diagnostics could report not_started alongside hundreds of output lines and omit the exit code. Runner JSON transport also changes integer map values to floating-point values, so strict Go type assertions lost PID, exit-code, and CPU metadata.

Forward the three lifecycle events through the existing bounded queue, clearing process.started.Message before enqueueing so command arguments and prompts stay private. Read numeric metadata from native integers, ordinary JSON, and UseNumber JSON. After cancellation, drain only remaining lifecycle evidence within the existing bounded stop context; do not replay protocol output. Preserve a final event batch when stdin failure races the final poll. Execution outcomes and the event wire shape are unchanged.

Validation: Go 1.26.11, Linux amd64, CGO disabled. Test binaries ran in a Linux container with their respective package directories as working directories.

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c -o runtime.test ./internal/runtime
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c -o httpapi.test ./internal/httpapi
# From internal/runtime:
./runtime.test -test.run='^(TestConversationProcess(BidirectionalAndRootFence|CancelUnblocksUnreadInput|PollReturnsCancellation|PreservesLifecycleEvidence)|TestConversationStop.*|TestConversationStartRejectsExpiredIDsAfterTombstoneExpiry|TestConversationSlowPreparationDoesNotBlockOtherSessions|TestConversationAssetsResetChmodAndRejectSymlink|TestConversationRewriteOnlyGeneratedInputs|TestConversationGuardPathsRemainPlatformOwned)$' -test.v -test.timeout=90s
# From internal/httpapi:
./httpapi.test -test.run='^(TestAssistantDiagnostic.*|TestAgentTool.*|TestGenerationSurvivesRequestAndCanBeCancelled|TestGenerationCompletedReplyAndSnapshot|TestConversation(Executor.*|RemoteSync.*|ClaudeGeneratedInvocation.*|CredentialFailure.*|Stop.*|ProcessRetriesBusyRunner)|TestUnstartedSharedSessionRetainsIdentityAndUsesFullPrompt)$' -test.v -test.timeout=90s
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go vet ./internal/runtime ./internal/httpapi
py -X utf8 scripts/check-public.py
git diff --check
  • Runtime: 12 top-level tests passed, 0 failed/skipped. Covers real processes that succeed, exit 7, or fail to start, event ordering, private argv exclusion, cancellation, and existing process fencing.
  • HTTP API: 43 top-level tests passed, 0 failed/skipped. Covers native/JSON/UseNumber metadata, real process cancellation retaining exit evidence, diagnostic redaction, and existing remote stop/retry behavior.
  • Before the fix, the lifecycle regression failed in all three cases, JSON round-trip lost PID, and the cancellation regression lost the final exit event. The original focused runtime baseline passed 7 tests.
  • Related vet, public-content, and diff checks passed. Existing chatbot embedding assets built from the same base were reused.

Full repository tests, browser acceptance, live providers, and live remote runners were not run. Native Windows package compilation has existing Unix syscall dependencies, so tests used Linux. Execution hosts must run the updated runtime to forward the lifecycle evidence; older runners retain their existing behavior.

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.

[Bug]: AI 对话诊断的 process.state 恒为 not_started,同时累加 stdoutLines,且拿不到退出码

1 participant