Skip to content

Update scanner layout and renderer alignment - #20

Draft
integrate-your-mind wants to merge 4 commits into
mainfrom
clean-codebase-2026-02-04
Draft

Update scanner layout and renderer alignment#20
integrate-your-mind wants to merge 4 commits into
mainfrom
clean-codebase-2026-02-04

Conversation

@integrate-your-mind

@integrate-your-mind integrate-your-mind commented Feb 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • refresh canvas renderer hook and layout helpers for the latest clean-codebase report
  • adjust scanner service, cache, and detectors along with shared types to align with new conventions
  • document changes in CONTINUITY.md and docs/clean-codebase-report.md

Testing

  • Not run (not requested)

Ensure you read the contribution guide before submitting a commit and follow the exact guidelines.


Open with Devin

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Comment thread public/src/lib/layout.ts
Comment on lines +354 to +369
function removeAgent(state: LayoutState, id: string): void {
const coord = state.layout.get(id);
if (coord) {
unindexAgent(id, state.spatial);
}
state.layout.delete(id);

const groupKey = state.agentGroupKey.get(id);
if (groupKey && coord) {
const group = state.groups.get(groupKey);
if (group) {
group.freeStack.push(gridKeyFromWorld(coord));
}
}
state.agentGroupKey.delete(id);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Memory leak: seenGen map entries never cleaned up when agents are removed

The seenGen map accumulates entries indefinitely because removeAgent does not delete entries from it.

Click to expand

How it happens

In updateLayout (public/src/lib/layout.ts:404), every agent gets an entry in seenGen:

state.seenGen.set(id, gen);

When agents are removed via removeAgent (public/src/lib/layout.ts:354-369), the function cleans up layout, spatial, and agentGroupKey, but never removes the entry from seenGen:

function removeAgent(state: LayoutState, id: string): void {
  // ... cleans layout, spatial, agentGroupKey
  // BUT: state.seenGen.delete(id) is missing!
}

Impact

Over time, as agents come and go (processes start and stop), the seenGen map will grow unboundedly. Each unique agent ID that has ever existed will remain in the map forever (until agents.length === 0 triggers a full clear at line 393). This causes gradual memory growth in long-running applications.

Actual vs Expected

  • Actual: seenGen retains entries for all agents that have ever existed
  • Expected: seenGen should only contain entries for currently active agents

Recommendation: Add state.seenGen.delete(id); to the removeAgent function to clean up the entry when an agent is removed.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80ada1db1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread public/src/lib/layout.ts
Comment on lines +310 to +314
function findPlacement(
group: GroupState,
spatial: SpatialIndex,
maxAttempts = 256
): Coordinate | null {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid fixed 256-attempt placement cap

The new findPlacement hard-caps the spiral search at 256 attempts. In crowded layouts (or large agent counts in one group), it’s easy to exhaust 256 collisions, causing findPlacement to return null and addAgent to bail out without assigning a coordinate. That results in new agents silently not rendering. Previously the search radius scaled with layout size, so placement kept expanding. Consider scaling maxAttempts with current layout density or continuing the spiral until a free cell is found.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Backlog triage: keeping this work, but returning it to draft. The distinct value is the removal of the unused src/scanner/ tree and the lower-allocation process-classification pass in src/scan.ts. Those changes now overlap the active graph and multi-harness scanner work in #29, so they need a fresh rebase plus scanner correctness and performance measurements before review. Suggested scope after #29: one PR for dead-module removal, then a separate measured process-classification optimization if the benchmark still supports it.

@integrate-your-mind
integrate-your-mind marked this pull request as draft July 19, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant