feat(typescript): persist findings and embeddings through the API - #660
feat(typescript): persist findings and embeddings through the API#660kmbroai wants to merge 4 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 64e1aad676
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| if (route === "GET /v1/findings") { | ||
| console.log(route); | ||
| json(response, 200, await service.list(pagination(url.searchParams))); |
There was a problem hiding this comment.
Security: Authenticate requests before returning stored findings
When the opt-in service is running and its user visits an attacker-controlled HTTP origin capable of DNS rebinding to 127.0.0.1:3000, this new GET returns complete stored findings without any auth, Host, or Origin check. The rebound origin is same-origin, so lack of CORS does not protect the response; local start:server also uses the CLI's default workbench state, whose findings can include code evidence. The same missing control lets POSTs spend the configured embedding key or alter known documents. Loopback binding only blocks direct remote sockets. Authenticate every route and reject untrusted Host/Origin values before database or provider access.
Useful? React with 👍 / 👎.
Summary
Implement part 2 of the findings service: persist complete findings and embeddings through the existing HTTP endpoints and list stored findings with pagination.
Stacked on #653, with
dev/kyleb/findings-serviceas the base so this diff contains only part 2. After #653 merges, rebase this commit ontomainand retarget the PR.Changes
POST /v1/bulk/findingsto validate the existingFindingmodel, generate embeddings, and atomically store findings plus vectors. Return finding IDs in request order.GET /v1/findingswithlimit/offsetpagination, a default page size of 50, andnextOffset.text-embedding-3-largewith 1,536 dimensions, token-aware batching, lossless chunking, and normalized pooling. Add.env.exampleand document Compose credential setup and the API contracts. No CLI commands or flags are added.tsconfig.json, with a small mounted TypeScript helper using Node SQLite for storage checks. Both files are explicitly type-checked. YAML only sets up Bun and invokes the runner; helpers are excluded from npm and the production image.Testing
Verified at
2e7d40b7:12345and3562923079).pnpm run types,pnpm run format, andgit diff --check: passed.pnpm packandpnpm run check:package: passed with 314 archive entries. Inspected the archive: live server modules are present; the removed dedupe module and smoke fixtures are absent. Installed public imports, NodeNext types, CLI, 114 bundled plugin files, bundled Codex, and nested-worker checks passed.Risk and rollout
OPENAI_API_KEYorCODEX_API_KEY. Automated verification uses synthetic provider responses, not a live embedding API call.Public disclosure review