Skip to content

Declare the references between objects by object type - #79

Merged
chelproc merged 1 commit into
mainfrom
object-type-references
Nov 14, 2026
Merged

chelproc merged 1 commit into
mainfrom
object-type-references

Conversation

@chelproc

Copy link
Copy Markdown
Contributor

Introduce object types as typed keys so that code can handle the five kinds of objects in the store generically, and use them to make expectConsistentStore check every reference between objects. This is groundwork for copying part of the store with fresh ids, which needs to know which fields refer to other objects.

  • src/store/types.ts defines the object type keys (components, nodes, componentPins, nodePins, connections), the id of each object type as Tagged<string, K>, and CCObjectStore<K>, the members of an object-specific store that do not depend on its object type.
  • The base class is renamed to CCObjectStoreBase and is parameterized by the object type key. Each store declares references: the fields of its objects holding the id of another object, mapped to the object type of that id. Keeping it complete and correct is a convention documented in the README; the type checker does not enforce it.
  • CCStore.getObjectStore(type) returns the store of an object type, typed per key.
  • expectConsistentStore now checks every declared reference instead of a hand-written list per object type. This adds checks for componentPins.implementation and connections.parentComponentId, and drops componentPins.get(pin.id), which only looked up the pin itself. A failure names the broken reference, e.g. connections.from of <id>.

Id tags change from names like CCNodeId to the object type keys. They only exist in types, so saved circuits are not affected.

Validation:

  • npm run type-check
  • npm run check
  • npm test -- --run
  • npm run build

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with  Cloudflare Pages  Cloudflare Pages

Latest commit: 450e0a9
Status: ✅  Deploy successful!
Preview URL: https://06e5a192.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev
Branch Preview URL: https://object-type-references.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev

View logs

@chelproc
chelproc merged commit 4875135 into main Nov 14, 2026
2 checks passed
@chelproc
chelproc deleted the object-type-references branch November 14, 2026 04:39
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.

1 participant