Skip to content

fix(flint): correctness fixes for memory type, token counting, and secret redaction#5

Open
DizzyMii wants to merge 3 commits into
mainfrom
fix/flint-correctness
Open

fix(flint): correctness fixes for memory type, token counting, and secret redaction#5
DizzyMii wants to merge 3 commits into
mainfrom
fix/flint-correctness

Conversation

@DizzyMii
Copy link
Copy Markdown
Owner

@
Three independent, low-risk correctness fixes in the flint package. Each is its own commit with a changeset and test coverage.

1. ConversationMemory.append typed as async

The interface declared append(m: Message): void, but the implementation is async and awaits the summarizer. Anyone typing against the interface would not await it and silently drop summarization work. The return type is now Promise<void>; all existing callers already await.

2. Guard approxCount against non-serializable tool arguments

tc.arguments is typed unknown, so JSON.stringify could throw on circular references or BigInt, or return undefined for a bare undefined — crashing a pure token estimate. Such arguments now contribute 0 tokens instead of throwing.

3. Redact PKCS#8 and other private-key formats

The private-key pattern in secretPatterns used [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 lint clean on changed files
    @

DizzyMii added 3 commits May 29, 2026 11:57
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.
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.

1 participant