Skip to content

feat(lifecycle): implement reversible claim state machine and visibility#98

Merged
keepsloading merged 1 commit into
Memact:mainfrom
CodeSparks45:feat/claim-lifecycle
Jun 28, 2026
Merged

feat(lifecycle): implement reversible claim state machine and visibility#98
keepsloading merged 1 commit into
Memact:mainfrom
CodeSparks45:feat/claim-lifecycle

Conversation

@CodeSparks45

Copy link
Copy Markdown
Contributor

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.

…ity handling (Fixes Memact#70)

Signed-off-by: CodeSpark45 <somvanshipavan2006@gmail.com>
@keepsloading

Copy link
Copy Markdown
Member

SSoC26 Labeling: This Pull Request has been automatically linked to the corresponding issue labels: SSoC26,Medium! Thank you for contributing!

@keepsloading
keepsloading merged commit b458970 into Memact:main Jun 28, 2026
@keepsloading keepsloading added Hard and removed Medium labels Jun 28, 2026
@keepsloading

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design Discussion] Claim Lifecycle & Reversibility

2 participants