feat(binding): add lifecycle primitives#92
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis pull request implements DX-034E "Binding Lifecycle Primitives" for the ChangesBinding Lifecycle Primitives Implementation
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant Owner as defineBindingLifecycleOwner
participant Constructor as bindingLifecycleRecord
participant Mutate as activateBinding
participant Freeze as deepFreeze
participant Record as BindingLifecycleRecord
Client->>Owner: kind, id, label
Owner->>Owner: validate and normalize
Owner->>Record: branded immutable owner
Client->>Constructor: owner, requirementId, state
Constructor->>Constructor: validate owner brand
Constructor->>Freeze: recursively freeze invalidations
Constructor->>Record: branded immutable record v1
Client->>Mutate: record (suspended)
Mutate->>Mutate: assert record, not disposed
Mutate->>Mutate: check suspended→active allowed
Mutate->>Record: new record v2, transition appended
Client->>Record: inspect state, transitions, version
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e205e44e0
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@packages/bijou/src/core/binding-lifecycle.ts`:
- Around line 136-141: isBindingLifecycleOwner and isBindingLifecycleRecord
currently accept brands inherited via the prototype chain; change their checks
to ensure the brand is an own property (not inherited) and value is a non-null
object. Specifically, in isBindingLifecycleOwner replace the prototype-accepting
test with: confirm typeof value === 'object' && value !== null and use
Object.prototype.hasOwnProperty.call(value, BINDING_LIFECYCLE_OWNER_BRAND) and
strict equality against true on (value as
BindingLifecycleOwnerBrandCarrier)[BINDING_LIFECYCLE_OWNER_BRAND]; apply the
same pattern to isBindingLifecycleRecord using its
BINDING_LIFECYCLE_RECORD_BRAND and corresponding BrandCarrier type so only
objects with an own-brand property pass.
- Around line 367-385: The function freezeTransitions currently only checks the
final transition matches expectedState but does not ensure the chain is
continuous; modify freezeTransitions (and use the already-mapped
frozenTransitions) to validate that for every index i > 0
frozenTransitions[i].from === frozenTransitions[i-1].to and throw an Error if
any adjacent pair is discontinuous, preserving the existing final-state check
against expectedState and returning Object.freeze(frozenTransitions) as before;
reference the freezeTransitions function and the freezeTransition-produced
frozenTransitions array when implementing this adjacency validation.
🪄 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
Run ID: 0904de9e-6b76-445d-9286-145cd855b5ec
📒 Files selected for processing (6)
docs/CHANGELOG.mddocs/design/DX-034-declarative-view-data-binding.mdpackages/bijou/src/core/binding-lifecycle.test.tspackages/bijou/src/core/binding-lifecycle.tspackages/bijou/src/index.tstests/cycles/DX-034/binding-lifecycle-primitives.test.ts
|
@codex PR feedback resolution summary:
Validation after fixes:
|
|
@coderabbitai review please 🥕 |
|
To use Codex here, create an environment for this repo. |
|
( ´・ω・`) 🐇 ✅ Actions performedReview triggered.
|
Summary
Adds DX-034E binding lifecycle primitives to
@flyingrobots/bijou.This introduces immutable transition-algebra value objects for binding lifecycle ownership:
BindingLifecycleOwnerBindingLifecycleRecordBindingLifecycleStateBindingLifecycleTransitionBindingInvalidationThis is a pure contract/value-object slice. Lifecycle records are immutable facts, not runtime managers.
Provider updates are represented as invalidation facts; assembling the next
BindingFrameremains a later runtime integration concern.Non-goals
Validation
npm test -- --run packages/bijou/src/core/binding-lifecycle.test.ts tests/cycles/DX-034/binding-lifecycle-primitives.test.tsnpm test -- --run packages/bijou/src/core/binding.test.ts packages/bijou/src/core/binding-lifecycle.test.ts packages/bijou/src/core/app-shell-composition.test.ts tests/cycles/DX-034/binding-frame-primitives.test.ts tests/cycles/DX-034/provider-scope-contracts.test.ts tests/cycles/DX-034/app-shell-composition-contract.test.ts tests/cycles/DX-034/active-binding-lifecycle.test.ts tests/cycles/DX-034/binding-lifecycle-primitives.test.tsnpm run typecheck:testnpm run docs:inventorygit diff --checknpm run lintnpm testnpm run typecheck:test,npm test, andnpm run verify:interactive-examplesFull suite: 288 test files passed, 3342 tests passed.
Summary by CodeRabbit
New Features
Documentation
Tests