fix: bug fixes (B47-B52), type safety audit, architecture docs#22
Merged
Conversation
added 5 commits
March 21, 2026 20:55
…chitecture docs Bug fixes: - B47: objective extract() cache staleness — always re-evaluates messages - B48: Session.remove() error swallowing — cleanup errors now propagate - B49: context-edit mark() missing transaction — wrapped in Database.transaction() - B50: AsyncQueue.push() after close — throws instead of silent discard - B51: ID counter atomicity — documented single-threaded assumption (deferred) - B52: Bus.publish subscriber errors — try-catch per subscriber + Promise.allSettled Type safety (~236 any eliminated, 14 documented exceptions remain): - Strong Zod schemas: JsonValue, ProviderMeta, ToolInput, ToolMeta in message-v2.ts - All z.any() replaced with strong types (except 3 upstream OpenAI SDK) - SDK boundary casts documented at ~15 crossing points - Branded ProjectID threaded through side-thread, tools, prompt pipeline - Provider/transform options typed with JSONValue from @ai-sdk/provider - Tool metadata uses ?? null for JSON-compliant undefined elimination Documentation: - docs/EFFECTIFICATION.md — Effect-TS architecture, 22 services, upstream PR timeline - docs/AGENT_CLIENT_PROTOCOL.md — ACP v1 support, protocol flow, tool mapping - docs/API_PROVIDERS.md — 21+ providers, models.dev, transform pipeline - docs/FRANKENCODE_DIFFERENCES.md — unified diff vs upstream OpenCode - docs/README.md — documentation index with architecture diagram - Cross-links added to all 6 existing docs - AGENTS.md updated with strong typing rules - CLAUDE.md symlink to AGENTS.md
The SDK build (`bun dev generate`) failed because `permission/service.ts` imported `MessageV2.JsonValue` from `session/message-v2.ts`, creating a circular dependency. At Bun's module evaluation time, `MessageV2` was undefined, causing `TypeError: undefined is not an object`. Fix: Move `JsonValue` Zod schema to `src/util/json.ts` (no dependencies). All files that used `MessageV2.JsonValue` in module-level Zod schemas now import directly from `@/util/json`. `MessageV2` re-exports for backward compatibility. Also updates AGENTS.md to clarify that pre-existing issues must always be fixed or documented in BUGS.md.
- Extract JsonValue to util/json.ts with z.any() + named meta ref (z.lazy() generates __schema0 $ref that breaks @hey-api/openapi-ts) - Add SDK type casts in share-next.ts for tsgo structural matching - Fix ACP event-subscription test SDK/internal type boundary - Regenerate SDK types from updated OpenAPI spec
- Note Frankencode always enables plan mode (flag ignored) - Add cross-links to related docs - Remove CODE_REVIEW.md (superseded by PR reviews)
Document all sites where Zod v3/v4 incompatibility exists (zod-to-json-schema, hono-openapi, z.lazy() $ref generation).
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
anytypes eliminated across ~40 source files — 14 documented exceptions remain at SDK/structural boundariesCLAUDE.mdsymlink createdBug Fixes
session/objective.tsextract()session/index.tsremove()context-edit/index.tsmark()inDatabase.transaction()util/queue.tspush()afterclose()id/id.tsbus/index.tsPromise.allSettled()Type Safety
JsonValue,ProviderMeta,ToolInput,ToolMeta) defined in message-v2.tsz.any()replaced with strong types except 3 upstream OpenAI SDKProjectIDthreaded through side-thread, tools, promptJSONValuefrom@ai-sdk/providerDocumentation
docs/EFFECTIFICATION.md— Effect-TS architecture, 22 services, 20+ upstream PR URLsdocs/AGENT_CLIENT_PROTOCOL.md— ACP v1 protocol flow, tool mappingdocs/API_PROVIDERS.md— 21+ providers, models.dev API, transform pipelinedocs/FRANKENCODE_DIFFERENCES.md— unified diff vs upstream OpenCodedocs/README.md— documentation index with architecture diagramTest plan
npx tsc --noEmit— 0 errorsbun test— 1448 pass, 0 fail