feat(lifecycle): implement reversible claim state machine and visibility#98
Merged
Merged
Conversation
…ity handling (Fixes Memact#70) Signed-off-by: CodeSpark45 <somvanshipavan2006@gmail.com>
Member
|
SSoC26 Labeling: This Pull Request has been automatically linked to the corresponding issue labels: |
Member
|
Difficulty label updated to Hard. Implementing a fully reversible state machine (lifecycle.mjs) that manages state transitions, visibility switches, and contradiction logic represents core system-level engineering, going well beyond standard category definitions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Closes #70
What this PR does
This PR introduces a robust, fully reversible state machine for context claims to manage the fluid nature of user identity. By decoupling a claim's status (e.g., pending, approved, deleted) from its visibility (private vs. shared), users can now seamlessly approve, temporarily hide, edit, or soft-delete their context history. It also establishes the architectural design guidelines for action buffering (undo mechanics) and third-party revocation syncing.
Type of change
[ ] Bug fix
[x] New feature
[ ] ML model / training pipeline
[ ] Refactor (no behaviour change)
[x] Documentation
[ ] Tests only
ML tier (if applicable)
[ ] Tier 1 — Triage
[ ] Tier 2 — Predictive
[ ] Tier 3 — Autonomous
[x] Not ML-related
Stack affected
[x] Backend / Logic Core
[ ] Frontend
[ ] Both
Changes
Backend
State Machine Implementation (src/lifecycle.mjs): Introduced CLAIM_LIFECYCLE_STATES, CLAIM_VISIBILITY, and the transitionClaimState() pure function to handle immutable state transitions, including revoked_at timestamping and lifecycle_history audit trails.
Engine Integration (src/engine.mjs): Updated shapeContextProposal() to initialize context proposals with the new robust lifecycle base state, including guardrail documentation for reversibility.
Architecture Documentation (docs/claim-lifecycle-design.md): Added a comprehensive design proposal detailing the core states, the 5-second action buffering rule (UI undo), and the architectural approach for decentralized revocation sync.
Frontend
New dependencies
Database / schema changes
Modifies the base object shape of Context Proposals to include status, visibility, revoked_at, last_action, updated_at, and an append-only lifecycle_history array.
Testing
How did you test this?
Validated the state transitions locally by passing mock context objects through transitionClaimState().
Confirmed that actions like hide correctly drop visibility to private and populate the revoked_at timestamp, while unhide correctly restores shared visibility.
Verified that shapeContextProposal() correctly initializes new context payloads without breaking existing tests.
Checklist
[x] Tested locally end-to-end (upload ZIP or GitHub URL → scan → findings returned correctly)
[ ] New ML model falls back gracefully when model file is absent
[x] No new console.error or unhandled Python exceptions introduced
[ ] Added or updated tests where applicable
[ ] requirements.txt / package.json updated if new dependencies added
[ ] New model files (.pkl, .pt, etc.) are gitignored, not committed
Anything reviewers should focus on
Please review the docs/claim-lifecycle-design.md document to ensure the proposed architecture for "Action Buffering" and "Revocation Sync" aligns with the broader Memact SDK roadmap.