Skip to content

fix: bug fixes (B47-B52), type safety audit, architecture docs#22

Merged
e6qu merged 5 commits intodevfrom
fix/remaining-bugs-b47-b52
Mar 21, 2026
Merged

fix: bug fixes (B47-B52), type safety audit, architecture docs#22
e6qu merged 5 commits intodevfrom
fix/remaining-bugs-b47-b52

Conversation

@e6qu
Copy link
Owner

@e6qu e6qu commented Mar 21, 2026

Summary

  • 6 bug fixes (B47-B52): objective cache, session error handling, mark transaction, queue push-after-close, bus subscriber errors
  • ~236 any types eliminated across ~40 source files — 14 documented exceptions remain at SDK/structural boundaries
  • 5 architecture docs created with cross-links: Effect-ification, ACP, API Providers, Frankencode Differences, documentation index
  • AGENTS.md updated with strong typing rules, CLAUDE.md symlink created

Bug Fixes

Bug File Fix
B47 session/objective.ts Remove cache early-return in extract()
B48 session/index.ts Remove error-swallowing try-catch in remove()
B49 context-edit/index.ts Wrap mark() in Database.transaction()
B50 util/queue.ts Throw on push() after close()
B51 id/id.ts Document single-threaded assumption (deferred)
B52 bus/index.ts try-catch per subscriber + Promise.allSettled()

Type Safety

  • Strong Zod schemas (JsonValue, ProviderMeta, ToolInput, ToolMeta) defined 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
  • Provider/transform options typed with JSONValue from @ai-sdk/provider

Documentation

  • docs/EFFECTIFICATION.md — Effect-TS architecture, 22 services, 20+ upstream PR URLs
  • docs/AGENT_CLIENT_PROTOCOL.md — ACP v1 protocol flow, tool mapping
  • docs/API_PROVIDERS.md — 21+ providers, models.dev API, transform pipeline
  • docs/FRANKENCODE_DIFFERENCES.md — unified diff vs upstream OpenCode
  • docs/README.md — documentation index with architecture diagram
  • Cross-links added to all existing docs

Test plan

  • npx tsc --noEmit — 0 errors
  • bun test — 1448 pass, 0 fail
  • Manual review of documentation accuracy

Adrian Mârza 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).
@e6qu e6qu merged commit ad835ba into dev Mar 21, 2026
1 check passed
@e6qu e6qu deleted the fix/remaining-bugs-b47-b52 branch March 21, 2026 20:30
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