docs(graphify): knowledge-graph codebase audit findings#4467
Open
vibegui wants to merge 1 commit into
Open
Conversation
Structural audit generated from a graphify knowledge graph of the monorepo (2,764 files, 16,839 nodes, 44,925 edges). Surfaces sync-work-on-daemon event-loop bugs, an automation re-fire loop, a leaked wildcard MCP key, hand-rolled async primitives, and simplification opportunities. Graph artifacts omitted to avoid repo bloat; reproduction steps included. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
A one-off structural audit of the monorepo, generated by building a
graphify knowledge graph of the
code and sending targeted audit agents into the hotspots the graph surfaced.
Adds a single doc —
GRAPHIFY_FINDINGS.md— with the findings below. No codechanges; the graph artifacts (27MB
graph.json/ 23MBgraph.html) aredeliberately not committed to avoid permanent repo bloat (reproduction
steps are in the doc).
Method. The code graph is deterministic (tree-sitter AST, no LLM, nothing
left the machine): 2,764 files → 16,839 nodes / 44,925 edges, 99% of edges
EXTRACTEDvs 1%INFERRED. The graph'saffected/path/explaintraversals identified the load-bearing hubs and complexity hotspots; those
exact files were then read and audited. Every finding cites
file:line.Architecture at a glance
The graph recovered Studio's shape from imports/calls alone. Largest labeled
communities:
MCP UI Resources & Client Hooks(248),Dialog UI Components(214),
Tool IO Types(209),Tool Definition & OAuth Providers(166),MCP Proxy Factory(161). Load-bearing hubs are exactly the documented ones —StudioContext(blast radius 152),defineTool()(imported by 143 toolfiles),
cn()/Button(). No direct circular imports. Codebase is heavilyUI-weighted.
🔴 High — real bug risk
1. Synchronous network git on the sandbox daemon request path —
packages/sandbox/daemon/git/rebase-onto-base.ts:283,297,331,357rebaseOntoBase()(viaroutes/git.ts:693) runsfetch/push --force/rebasethroughspawnSync(git-sync.ts:33). Violates CONTRIBUTING rule #1: freezes the single Bun event loop for seconds→30s, the/healthprobe misses, and Studio tears the sandbox down mid-rebase.gitAsyncalready exists (git/git-async.ts) — rebase was never migrated.2. Uncapped synchronous file read in the daemon fs route —
packages/sandbox/daemon/routes/fs.ts:173-174readFileSync+.split("\n")with no size ceiling (images capped at 5MB, text isn't) blocks the loop twice. Thebranch-status.tsmonitor (:215,244, on thefs.watch/poll path) and glob walk (:751,910) are also sync — while upload/download in the same file were already made async.3. Permanent setup failures thrown as plain
Error→ automations re-fire forever —apps/mesh/src/api/routes/decopilot/dispatch-run.ts:974,1073,1092"Model not allowed", "not allowed to write to thread", and async-research-model-in-wrong-slot throw plain
Error, notPermanentRunError. The automation workflow (automations/dbos-workflow.ts:463) only deactivates onisPermanentRunError, so a cron automation pinned to a now-disallowed model fails identically every tick forever, burning a run each time.🟠 Medium — security-adjacent & correctness
4. Full-access (
*:*) MCP key leaked on aborted dispatch —dispatch-run.ts:347,358(leak paths:1953,2013)mintMcpEndpointcreates a{"*":["*"]}/ 1h-TTL key before the payload-size and org-slug gates. On either failure the wildcard key is never revoked and stays live up to an hour.5. SSO check does an uncached DB query on every authenticated request —
apps/mesh/src/api/app.ts:1723→storage/org-sso-config.ts:11getByOrgIdis an uncachedselectFromrun for every org+user request, even when SSO isn't enforced (the common case). Fix: short-TTL cache like the adjacentmemberRoleCache.6.
resolveOrgFromPathregistered twice for the same hot route —app.ts:1698andapp.ts:1906No early-return, so every
/api/:org/files/*request does the org lookup + rebind twice. Delete L1906.🟡 Complexity / simplification
7. 7 confirmed hand-rolled
@decocms/stdviolations — SSE reconnect backoff without jitter (web/components/sandbox/hooks/sandbox-events-context.tsx:488→exponentialBackoffWithJitter) + 6 Promise-wrappedsetTimeoutsleeps (cli/lib/port-wait.ts:32,sandbox/server/provider/agent-sandbox/client.ts:410,512,harnesses/decopilot/built-in-tools/cluster-research-job.ts:272,web/components/monaco/index.ts:71,web/components/sandbox/preview/preview.tsx:777) →sleep.8.
mountLegacyboilerplate copy-pasted 9× —app.tsL1747/1811/1817/1824/1912/1928/1954/1973/1989. Each hand-types amountPathstring that must match its mount arg; a stale copy silently mislabels deprecation logs. AmountLegacy(app, path, routes)helper removes the footgun.9. Two un-cleared timers —
app.ts:1644(24h API-keysetIntervalnever cleared → leaks stale-pool closures across dev HMR/tests; sibling sweeper is disposed) andapp.ts:216(rejectAfter5s health-probesetTimeoutnever cleared).🟢 Dead code
createDesktopSubtaskDispatcher(packages/harness/src/decopilot/built-in-tools/desktop-subtask-dispatcher.ts:48) — zero inbound edges, grep confirms 1 occurrence total. Genuinely dead.Suggested order
rebase-onto-base.ts+routes/fs.ts+branch-status.tsoff sync fs/spawn (feat: Genesis #1, chore: add agents #2).PermanentRunError(Chore: migrate chat and agent-settings #3).*:*key ([Bug] New Agents get created without any Core Tool available #4).Testing notes
Docs-only change — no code touched, no tests affected. Findings are line-cited for follow-up PRs; nothing here is applied.
🤖 Generated with Claude Code
Summary by cubic
Adds
GRAPHIFY_FINDINGS.md, a docs-only report from agraphifyknowledge-graph audit of the monorepo. It surfaces high-risk sync git/file I/O on the sandbox daemon path, non-permanent automation errors that cause infinite retries, and a leaked wildcard MCP key, plus small cleanup items; graph artifacts are omitted with repro steps included, and no code is changed.Written for commit 5013265. Summary will update on new commits.