Skip to content

chore: audit component IVersionedStatefulComponent/IInspectableComponent applicability#162

Merged
stid merged 1 commit into
masterfrom
chore/component-contracts-audit
May 24, 2026
Merged

chore: audit component IVersionedStatefulComponent/IInspectableComponent applicability#162
stid merged 1 commit into
masterfrom
chore/component-contracts-audit

Conversation

@stid

@stid stid commented May 24, 2026

Copy link
Copy Markdown
Owner

Closes #159

What & why

CodeRabbit's coding-guideline flags components that don't implement
IVersionedStatefulComponent / IInspectableComponent. But those contracts
model the emulated-hardware tree, not the React presentation layer — applying
them blanket to UI components is a false positive. This PR audits the codebase,
documents the applicability rule, and records the per-component classification.

Finding

Both contracts are implemented only by core/IO classes — and that is correct.
No React component in src/components/** implements (or should implement) them:
they render and consume the inspectable tree (typically via an
apple1Instance: IInspectableComponent prop) and hold only ephemeral view state
through hooks/contexts.

Implementers (the only classes that should)

Class IInspectableComponent IVersionedStatefulComponent
Apple1 (src/apple1/index.ts)
Bus (src/core/Bus.ts)
Clock (src/core/Clock.ts)
CPU6502 (src/core/cpu6502/core.ts)
PIA6820 (src/core/PIA6820.ts)
RAM (src/core/RAM.ts)
ROM (src/core/ROM.ts)
CRTVideo (src/apple1/WebCRTVideo.ts)
Keyboard (src/apple1/WebKeyboard.ts)

Component audit — src/components/**

Every component is React presentation / a UI helper. None owns versioned
hardware state or produces an inspectable node, so the contracts are N/A for
all of them (including Actions and RegisterRow, which are stateless;
AppContent only delegates save/load to the worker/core; InspectorView /
DebuggerLayout consume the tree). Full per-component table is in
docs/active/architecture.md.

The documented rule

  • Implement the contracts on emulated-hardware classes that own
    persisted/versioned state (→ IVersionedStatefulComponent) and/or expose
    debug-inspectable state (→ IInspectableComponent).
  • Do NOT implement them on React components or presentational/stateless
    helpers.

Documented in docs/active/architecture.md (new "Where these contracts apply"
section + implementer table + full component classification table) and the
CLAUDE.md "Key Patterns to Follow" wording was tightened from the blanket
"components implement …" to the scoped core/IO layer.

What was implemented

Nothing in code — the audit found every contract correctly placed already. Per the
project's anti-overengineering rule, no contracts were added or removed. Deliverable
is the documented rule + classification. Version bumped 4.43.0 → 4.43.3.

Checks

  • yarn lint
  • yarn type-check
  • yarn test:ci ✅ (692 passed, 18 skipped — WASM parity/benchmark, gitignored artifacts)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • App version bumped to 4.44.3
  • Documentation

    • Clarified architecture and component responsibilities, explicitly separating emulated-hardware entities from UI/presentation components and refining guidance for component inspection and debugger visibility.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR clarifies that IVersionedStatefulComponent and IInspectableComponent apply to emulated-hardware core/IO classes (not React presentational components), expands architecture docs with an audit and usage rules, makes small docs formatting tweaks, and bumps APP_VERSION to '4.44.3'.

Changes

Component Contract Scope Clarification

Layer / File(s) Summary
Developer pattern clarification
CLAUDE.md
State management and component inspection rules now specify that IVersionedStatefulComponent applies only to emulated-hardware classes (CPU, Bus, RAM, ROM, PIA, Clock, Apple1), and that IInspectableComponent is implemented by those hardware classes via getInspectable() while React components consume the inspectable tree.
Architecture specification, memory map & worker API formatting
docs/active/architecture.md
New section defines the emulated "hardware tree" scope for the contracts, includes do/not guidance distinguishing React presentation components from core/IO emulation classes, an audit table of current implementers, adjusted Apple 1 memory map table spacing (no address changes), and reformatting of the IWorkerAPI interface blocks (no signature changes).
App version update
src/version.ts
Bumped exported APP_VERSION constant from '4.44.2' to '4.44.3'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • stid/Apple1JS#154: Directly related — both PRs modify CLAUDE.md guidance and touch the versioning documentation/metadata.

Poem

🐰 I hopped through docs to set things right,
Hardware keeps the contracts in sight,
React just reads the inspectable tree,
A tiny bump — version three,
🍃🔧🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main objective of the PR: auditing where component contracts apply, which is the core change across documentation updates.
Linked Issues check ✅ Passed The PR fully addresses issue #159 by auditing components, documenting contract applicability rules, providing per-component classification table, and updating documentation without implementing unnecessary contracts.
Out of Scope Changes check ✅ Passed All changes align with the audit scope: documentation updates clarify contract applicability, version bump is routine maintenance, and no extraneous changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/component-contracts-audit

Comment @coderabbitai help to get the list of available commands and usage tips.

@stid stid force-pushed the chore/component-contracts-audit branch from cb52185 to f0bd914 Compare May 24, 2026 01:09
…lity

Resolves #159. Audits which components should implement
IVersionedStatefulComponent / IInspectableComponent so CodeRabbit's
coding-guideline isn't applied blanket.

Finding: both contracts model the emulated-hardware tree and are
implemented only by core/IO classes (Apple1, Bus, Clock, CPU6502,
PIA6820, RAM, ROM, CRTVideo, Keyboard). No React component in
src/components/** implements them, and none should — they render/consume
the inspectable tree and hold only ephemeral view state via hooks.

Documents the applicability rule + per-component classification table in
docs/active/architecture.md and tightens the CLAUDE.md "Key Patterns"
wording from "components implement" to the scoped core/IO layer.

No contracts added or removed: the audit found everything already
correct. Bumps version 4.43.0 -> 4.43.3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stid stid force-pushed the chore/component-contracts-audit branch from f0bd914 to 5cfca8f Compare May 24, 2026 01:11

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/active/architecture.md`:
- Around line 259-261: Update the contradictory statement about
IVersionedStatefulComponent so it matches the audit: replace the blanket claim
"All components implement IVersionedStatefulComponent" with a precise sentence
stating that only core/IO/hardware classes (or components that manage versioned
state) implement the contract and that React UI components do not implement it;
ensure the wording references IVersionedStatefulComponent and the audit
conclusion to make the exception explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f76d1f61-ee09-455c-91c0-5561cc1c2e4c

📥 Commits

Reviewing files that changed from the base of the PR and between f0bd914 and 5cfca8f.

📒 Files selected for processing (3)
  • CLAUDE.md
  • docs/active/architecture.md
  • src/version.ts
✅ Files skipped from review due to trivial changes (2)
  • src/version.ts
  • CLAUDE.md

Comment on lines +259 to +261
**Audit result:** every core/IO class that needs the contracts already implements
them, and no React component does (correctly). No contract was added or removed by
this audit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Resolve contradiction with the “All components implement IVersionedStatefulComponent” claim.

This new audit section says only core/IO hardware classes should implement these contracts, but later in this same doc (Line 414) it still says “All components implement IVersionedStatefulComponent.” Please align that statement to avoid conflicting guidance.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/active/architecture.md` around lines 259 - 261, Update the contradictory
statement about IVersionedStatefulComponent so it matches the audit: replace the
blanket claim "All components implement IVersionedStatefulComponent" with a
precise sentence stating that only core/IO/hardware classes (or components that
manage versioned state) implement the contract and that React UI components do
not implement it; ensure the wording references IVersionedStatefulComponent and
the audit conclusion to make the exception explicit.

@stid stid merged commit 1aad7d8 into master May 24, 2026
8 checks passed
@stid stid deleted the chore/component-contracts-audit branch May 24, 2026 01:19
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.

audit: which components should implement IVersionedStatefulComponent / IInspectableComponent

1 participant