LearnNewsExamplesServices
Frontmatter
id10107
titleAudit core.Base + Neo.mjs — document rationale, benchmark hot paths, file follow-up refactors only where data supports
stateClosed
labels
enhancementaiarchitecture
assigneesneo-gpt
createdAtApr 19, 2026, 7:48 PM
updatedAtJun 6, 2026, 4:59 PM
githubUrlhttps://github.com/neomjs/neo/issues/10107
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 6, 2026, 4:59 PM

Audit core.Base + Neo.mjs — document rationale, benchmark hot paths, file follow-up refactors only where data supports

Closed v13.0.0/archive-v13-0-0-chunk-5 enhancementaiarchitecture
tobiu
tobiu commented on Apr 19, 2026, 7:48 PM

Summary

Empirical session probe against gemma-4-31b-it (session memory: project_core_base_conventions.md) surfaced observations about our core — some with intentional rationale already baked in, some genuinely worth investigating.

Intentional patterns (not refactor candidates — need documentation in class JSDoc):

  • className / ntype on instance (not just static) — Chrome DevTools ergonomics: inspecting this in debugger shows className immediately without expanding the prototype chain. Deliberate choice, saves significant debugging time at framework scale.
  • globalThis.Neo dual role (module export + global singleton) — single-registry architecture required for mixed-runtime (dist/production + dynamically-loaded dist/esm). Splitting would break the setupClass gatekeeper's "first-one-wins" guarantee.
  • me = this pattern — tracked separately (see the me=this policy audit ticket).

Candidates worth investigating (with strict benchmarking gate):

  • Neo.setupClass as "god function" (~193 lines handling namespace gatekeeping + config merging + overwrite application + getter/setter generation + mixin application + singleton creation + class-hierarchy registration). Runs once per class at module load, but is hot at cold-start for any Neo.mjs app (hundreds to thousands of classes). Decomposition into internal helpers might help readability — but any such refactor must demonstrate zero cold-start regression + accounted GC pressure from intermediate objects.
  • Variable shadowing in Neo.createclassName reassigned from string / object / class constructor depending on input type. Cognitive tax for readers without TypeScript; possibly clearer as separate variables.

Audit scope — documentation + benchmarks, NOT refactor:

  • The output of this ticket is (a) JSDoc additions capturing intentional rationale and (b) a baseline benchmark harness for hot paths. Any actual refactor becomes a follow-up ticket that must pass the A/B benchmark gate.

The Fix

  1. Add class-level JSDoc in src/Neo.mjs explaining the globalThis.Neo single-registry architecture + the setupClass hot-path / GC-pressure constraint.
  2. Add class-level JSDoc in src/core/Base.mjs explaining the className / ntype on-instance DevTools-ergonomics rationale.
  3. Add a buildScripts/benchmarks/ harness (or extend existing) with a setupClass-cold-start.mjs micro-benchmark producing a baseline timing + memory profile. Baseline gets committed as reference for future refactor proposals to A/B against.
  4. File follow-up tickets ONLY for refactor candidates that demonstrate measurable improvement AND account for application-engine + agent-OS ripple.

Acceptance Criteria

  • Neo.mjs class-level JSDoc explains globalThis.Neo single-registry + setupClass hot-path constraint with pointer to benchmark harness
  • Base.mjs class-level JSDoc documents className / ntype on-instance DevTools rationale
  • buildScripts/benchmarks/setupClass-cold-start.mjs (or similar) produces reproducible baseline
  • Baseline numbers committed as reference data
  • No code refactor in this ticket — decisions + documentation + benchmark harness only
  • Any refactor proposal spawned from this audit MUST reference the benchmark for A/B comparison + address application-engine + agent-OS ripple

Out of Scope

  • Actual refactors (they become downstream tickets pending benchmark data).
  • me = this policy (separate ticket).
  • PR-comment hygiene rule (separate ticket).

Related

  • Session memory: project_core_base_conventions.md — historical rationale preservation
  • Empirical probe origin: PR #10105 (capability probe against gemma-4-31b-it)
  • Coding standards: .github/CODING_GUIDELINES.md §35 (const economy, by extension applies to hot-path patterns)

Origin Session ID: 1db25bbe-f39d-4dcd-bb0e-bc125ce91326

tobiu added the enhancement label on Apr 19, 2026, 7:48 PM
tobiu added the ai label on Apr 19, 2026, 7:48 PM
tobiu added the architecture label on Apr 19, 2026, 7:48 PM
tobiu cross-referenced by #10030 on Apr 19, 2026, 7:53 PM
tobiu closed this issue on Jun 6, 2026, 4:59 PM
tobiu referenced in commit d7c4c6b - "docs(core): capture setupClass rationale and benchmark (#10107) (#12636)" on Jun 6, 2026, 4:59 PM