fix: code quality, resource cleanup, and duplicate code extraction#98
Open
Misaka477 wants to merge 1 commit into
Open
fix: code quality, resource cleanup, and duplicate code extraction#98Misaka477 wants to merge 1 commit into
Misaka477 wants to merge 1 commit into
Conversation
Collaborator
|
这批改动里 B2(指纹缓存从"满了清空"改成逐条驱逐)和 B12(把
一个不卡合入但建议处理的点:B14 实际没有改变行为——原代码已经是 流程上说明:测试矩阵没跑是因为首次贡献者的 workflow 需要维护者批准,不是你的问题;上面两处修完、push 上来,我们批准 workflow 让三平台跑绿。另外你这三个 PR(#96/#97/#98)之间有文件重叠( |
This was referenced Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five code quality improvements covering deduplication, resource cleanup, and state validation.
Changes
B2: fingerprint LRU — replaces
Set.clear()with LRU eviction (deletes oldest entry) when the approved tool fingerprint cache exceeds the cap.B5: agent-team AbortSignal — rewrites
sleep()to accept and handle an optionalAbortSignal, consistent with the existingagent-loop.tsimplementation.B12: duplicate code extraction — extracts shared
safeParsetoparsers.ts, andnormalizeToolArguments/stableStringify/sortRecursivelytopackages/utils/src/json.ts, eliminating identical copies acrossagent-loop.tsandruntime.ts.B13: state-machine transition validation — adds a transition matrix (
ALLOWED_TRANSITIONS) soAgentStateMachine.transition()rejects invalid state changes with a clear error.B14: coding-bridge listener cleanup — refactors AbortController listener pattern to ensure cleanup via
{ once: true }on the abort path and implicit GC cleanup on normal completion.Verification
tsc --noEmit✅pnpm lint✅ (0 errors)pnpm test✅ (1474 passed, 8 skipped)pnpm dep-graph-check✅Closes [bug] 已批准工具指纹 Set 溢出时全量清空 #82, Closes [bug] agent-team.ts 的 sleep 不支持 AbortSignal #85, Closes [bug] state-machine.ts 不是真正的状态机 #92, Closes [bug] coding-bridge AbortController listener 泄漏 #93, Closes [bug] 重复代码(normalizeArgs / safeParse) #95