fix(flint): correctness fixes for memory type, token counting, and secret redaction#5
Open
DizzyMii wants to merge 3 commits into
Open
fix(flint): correctness fixes for memory type, token counting, and secret redaction#5DizzyMii wants to merge 3 commits into
DizzyMii wants to merge 3 commits into
Conversation
The interface declared append() returning void, but the implementation is async and awaits the summarizer. Callers typing against the interface would not await it, silently dropping summarization work. Correct the return type to Promise<void>; all existing callers already await.
tc.arguments is typed unknown, so JSON.stringify could throw on circular references or BigInt values, or return undefined for a bare undefined, crashing a pure token estimate. Wrap the stringify and treat unserializable arguments as contributing zero tokens.
The private-key pattern in secretPatterns used [A-Z ]+ for the key type, which failed to match the most common modern formats: generic PKCS#8 (-----BEGIN PRIVATE KEY-----, no type word), ENCRYPTED PRIVATE KEY, and types containing digits or hyphens. Make the type segment optional and allow digits/hyphens so these keys are redacted.
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.
@
Three independent, low-risk correctness fixes in the
flintpackage. Each is its own commit with a changeset and test coverage.1.
ConversationMemory.appendtyped as asyncThe interface declared
append(m: Message): void, but the implementation isasyncand awaits the summarizer. Anyone typing against the interface would notawaitit and silently drop summarization work. The return type is nowPromise<void>; all existing callers already await.2. Guard
approxCountagainst non-serializable tool argumentstc.argumentsis typedunknown, soJSON.stringifycould throw on circular references orBigInt, or returnundefinedfor a bareundefined— crashing a pure token estimate. Such arguments now contribute0tokens instead of throwing.3. Redact PKCS#8 and other private-key formats
The private-key pattern in
secretPatternsused[A-Z ]+for the key type, which missed the most common modern formats: generic PKCS#8 (-----BEGIN PRIVATE KEY-----, no type word),ENCRYPTED PRIVATE KEY, and types containing digits or hyphens. The type segment is now optional and allows digits/hyphens.Verification
pnpm --filter flint build✓pnpm --filter flint typecheck✓pnpm --filter flint test✓ (267 tests, including new cases for fixes 2 and 3)biome lintclean on changed files@