Skip to content

demo: make Admin delete schedule-aware - #55

Merged
AmaraNecib merged 11 commits into
developfrom
feature/demo-scheduled-delete
Jul 22, 2026
Merged

demo: make Admin delete schedule-aware#55
AmaraNecib merged 11 commits into
developfrom
feature/demo-scheduled-delete

Conversation

@AmaraNecib

@AmaraNecib AmaraNecib commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Purpose

Prepare the interactive decision demo to show that a permission can be granted only during a configured time window, while still being decided by the real Mizan engine.

Implementation scope

  • Make the existing Admin cars.delete decision use the demo's weekday/work-hours schedule.
  • Keep Support's explicit cars.delete deny override unconditional so matching-denial remains visible.
  • Make the existing evaluation clock, schedule toggle, and hour controls update the visible permission state and table actions.
  • Keep the change inside examples/interactive-decision-demo/ and use the existing memory/demo sources.
  • Preserve the production-security disclaimer: UI state is only a demonstration; real applications must enforce authorization at the server/API boundary.
  • Update the example README and on-screen copy to describe the scenario.

Constraints

  • Do not add authentication, JWT parsing, SQLite, ORM persistence, caching, guards, or new core APIs.
  • Do not duplicate authorization decisions in browser code; protected actions must continue to call Mizan.
  • Do not change Support's unconditional deny behavior.

Verification

Please run the repository checks and verify the browser flow for Admin inside/outside schedule, Support denial, schedule toggle, and clock changes.

Refs #36

Summary by CodeRabbit

  • New Features

    • Refined the interactive decision demo schedule flow: schedule controls apply to Admin’s cars.delete, while only Super Admin can edit the schedule (controls remain visible to all).
    • Replaced the prior policy schedule UI with a compact “Schedule bar” and updated scheduled allow/deny display.
    • Refreshes permission and decision views after schedule evaluation.
  • Documentation

    • Added guidance for verifying “SUCCESS” automated review checks when no review output is posted, including an explicit “report as unavailable” path.
  • Style / Chores

    • Updated schedule-related styling and selectors.
    • Expanded .gitignore to exclude video and Playwright artifacts.
    • Updated README demo description and walkthrough to match the revised Admin capabilities.

@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@AmaraNecib, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4bd466b3-52a0-4b83-977b-656eeffd3ea0

📥 Commits

Reviewing files that changed from the base of the PR and between 7215858 and bb895b6.

📒 Files selected for processing (2)
  • README.md
  • examples/interactive-decision-demo/README.md
📝 Walkthrough

Walkthrough

The interactive authorization demo now schedule-controls Admin’s cars.delete permission at a simulated clock time, with updated controls, authorization checks, policy evaluation, and documentation. Repository review guidance, project documentation, and ignore rules are also updated.

Changes

Interactive schedule enforcement

Layer / File(s) Summary
Schedule-controlled policy wiring
examples/interactive-decision-demo/main.ts
Admin access is narrowed to explicit non-delete permissions, while scheduled cars.delete facts and clock-aware authorization helpers are applied across policy and action checks.
Schedule controls and evaluation display
examples/interactive-decision-demo/index.html, examples/interactive-decision-demo/main.ts, examples/interactive-decision-demo/style.css
Schedule controls move into a main-column bar, are restricted to Super Admin for modification, evaluate Admin’s cars.delete decision, refresh policy views, and receive updated styling.
Schedule behavior documentation
examples/interactive-decision-demo/README.md, README.md
Documentation describes Admin’s scheduled cars.delete restriction, clock-time enforcement, and manage-policy authorization.

Repository workflow maintenance

Layer / File(s) Summary
Review verification and local artifact rules
.agents/wisdom/process.md, .gitignore
Review guidance adds checks for missing review evidence, and ignore rules cover video, Playwright, and worktree directories.
Project overview documentation
README.md
Project narrative sections are expanded and the license reference is consolidated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ScheduleUI
  participant evaluateSchedule
  participant PolicyFacts
  participant AuthorizationDecisions
  participant PolicyViews
  User->>ScheduleUI: set schedule or clock state
  ScheduleUI->>evaluateSchedule: evaluate Admin cars.delete
  evaluateSchedule->>PolicyFacts: update schedule-controlled fact
  evaluateSchedule->>AuthorizationDecisions: evaluate at clockTime
  AuthorizationDecisions-->>evaluateSchedule: return allow or deny
  evaluateSchedule->>PolicyViews: refresh table and permission sidebar
Loading

Possibly related PRs

  • AmaraNecib/mizan#53: Also modifies schedule and authorization behavior in the interactive decision demo.
🚥 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 matches the main change: Admin delete in the demo now follows schedule-aware behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/demo-scheduled-delete

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.

❤️ Share

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

@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 @.agents/wisdom/process.md:
- Around line 10-20: Update the “CodeRabbit SUCCESS with no review” guidance to
avoid treating empty review output as definitive evidence of rate limiting.
Require verifying whether the review covered the latest commit, distinguish
incremental skips from rate-limited or unavailable results, and obtain an
explicit human decision before proceeding in either uncertain case; align the
instructions with the behavior described in adversarial-review guidance and
engineering workflow documentation.
🪄 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: 947550f4-550b-4986-b47c-869c732c008d

📥 Commits

Reviewing files that changed from the base of the PR and between bf20e23 and 71c454c.

📒 Files selected for processing (6)
  • .agents/wisdom/process.md
  • .gitignore
  • examples/interactive-decision-demo/README.md
  • examples/interactive-decision-demo/index.html
  • examples/interactive-decision-demo/main.ts
  • examples/interactive-decision-demo/style.css

Comment thread .agents/wisdom/process.md Outdated
@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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/demo-video-script.md`:
- Line 3: Align the target duration with the storyboard by either trimming at
least three seconds from the final sequence so it ends by 2:55, or updating the
target range to include the 2:58 storyboard endpoint. Keep the overall “never
over 3:00” constraint intact.
🪄 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: 376037a5-be48-4b11-9e97-e64903284c63

📥 Commits

Reviewing files that changed from the base of the PR and between 71c454c and 553ae45.

📒 Files selected for processing (2)
  • .agents/wisdom/process.md
  • docs/demo-video-script.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .agents/wisdom/process.md

Comment thread docs/demo-video-script.md Outdated
@@ -0,0 +1,57 @@
# Mizan demo video — YouTube / OpenAI Build Week

Target: 2:40–2:55, landscape 16:9, public YouTube, never over 3:00.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Align the target duration with the storyboard.

The stated target ends at 2:55, but the storyboard ends at 2:58. Either trim at least three seconds from the final sequence or update the target range so production does not treat an out-of-range cut as complete.

Also applies to: 25-26

🤖 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/demo-video-script.md` at line 3, Align the target duration with the
storyboard by either trimming at least three seconds from the final sequence so
it ends by 2:55, or updating the target range to include the 2:58 storyboard
endpoint. Keep the overall “never over 3:00” constraint intact.

@AmaraNecib
AmaraNecib force-pushed the feature/demo-scheduled-delete branch from 553ae45 to 4dc15fd Compare July 21, 2026 19:28
@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmaraNecib
AmaraNecib force-pushed the feature/demo-scheduled-delete branch from 5c215bb to 08b39b4 Compare July 21, 2026 19:44
…Admin cars.delete only, restore manage-policy gate
@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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

🧹 Nitpick comments (2)
examples/interactive-decision-demo/main.ts (2)

209-236: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate admin cars.delete fact-construction logic.

The scheduled-vs-unrestricted admin/cars.delete fact block is duplicated verbatim in restorePolicyFactsFromSaved (Lines 221-235) and evaluateSchedule (Lines 759-770). Any future change to the fact shape (e.g. adding a startsAt, changing the effect) needs to be kept in sync by hand in two places.

♻️ Suggested consolidation
+function applyAdminCarsDeleteFact(enabled: boolean, startH: number, startM: number, endH: number, endM: number): void {
+  policySource.removeAllFacts("admin", "cars.delete");
+  policySource.addFact("admin", {
+    permission: "cars.delete",
+    effect: "grant",
+    ...(enabled ? { schedule: makeWeekSchedule(startH, startM, endH, endM) } : {}),
+  });
+}

Then call this from both restorePolicyFactsFromSaved and evaluateSchedule.

Also applies to: 756-792

🤖 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 `@examples/interactive-decision-demo/main.ts` around lines 209 - 236, Extract
the shared admin `cars.delete` fact construction from
`restorePolicyFactsFromSaved` and `evaluateSchedule` into a helper that uses the
schedule settings to create either the scheduled or unrestricted grant fact.
Replace both duplicated blocks with calls to this helper, preserving the
existing behavior and fact shape.

839-868: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Redundant saveState() calls after attemptManagement().

attemptManagement() already calls saveState() internally when the decision is allow (Line 519), capturing state after onAllowed() has mutated it. Each clock handler here then calls saveState() again after evaluateSchedule() (Lines 846, 856, 866) even though evaluateSchedule() only rewrites derived policySource facts from the same primitives that were already persisted — no new state to save. This is a newly-introduced instance of a pattern that also exists in the (unchanged) toggle/hour-input handlers above.

♻️ Suggested fix
   byId("clock-inc").addEventListener("click", async () => {
     const granted = await attemptManagement(() => {
       clockTime = new Date(clockTime.getTime() + 3_600_000);
     }, "Advance clock");
     if (!granted) return;
     updateClockDisplay();
     await evaluateSchedule();
-    saveState();
   });

(apply similarly to the clock-dec and clock-reset handlers)

🤖 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 `@examples/interactive-decision-demo/main.ts` around lines 839 - 868, Remove
the redundant saveState() calls from the clock-inc, clock-dec, and clock-reset
click handlers. Keep attemptManagement() responsible for persisting the state
after the allowed mutation, while preserving each handler’s updateClockDisplay()
and evaluateSchedule() calls.
🤖 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 `@examples/interactive-decision-demo/README.md`:
- Around line 58-60: Update the README section describing schedule enforcement
to state that the Admin cars.delete decision, evaluated at clockTime, enforces
the schedule, while manage-policy only authorizes users to modify schedule
settings.

---

Nitpick comments:
In `@examples/interactive-decision-demo/main.ts`:
- Around line 209-236: Extract the shared admin `cars.delete` fact construction
from `restorePolicyFactsFromSaved` and `evaluateSchedule` into a helper that
uses the schedule settings to create either the scheduled or unrestricted grant
fact. Replace both duplicated blocks with calls to this helper, preserving the
existing behavior and fact shape.
- Around line 839-868: Remove the redundant saveState() calls from the
clock-inc, clock-dec, and clock-reset click handlers. Keep attemptManagement()
responsible for persisting the state after the allowed mutation, while
preserving each handler’s updateClockDisplay() and evaluateSchedule() calls.
🪄 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: 22d2c1a6-dcdd-4e14-91a1-146e8b6a3404

📥 Commits

Reviewing files that changed from the base of the PR and between 4dc15fd and 7215858.

📒 Files selected for processing (5)
  • .gitignore
  • examples/interactive-decision-demo/README.md
  • examples/interactive-decision-demo/index.html
  • examples/interactive-decision-demo/main.ts
  • examples/interactive-decision-demo/style.css
🚧 Files skipped from review as they are similar to previous changes (1)
  • .gitignore

Comment thread examples/interactive-decision-demo/README.md Outdated
@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmaraNecib
AmaraNecib marked this pull request as ready for review July 22, 2026 00:47

@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 `@README.md`:
- Line 107: Update the Admin permission descriptions in both README locations to
state that scheduled delete access is restricted to the configured work window
only when scheduling is enabled; when the schedule is disabled, clarify that car
deletion is unrestricted while policy management remains locked.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f0c6879-e832-4de9-9b82-8e796a40ee36

📥 Commits

Reviewing files that changed from the base of the PR and between 7215858 and ba9f83f.

📒 Files selected for processing (2)
  • README.md
  • examples/interactive-decision-demo/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/interactive-decision-demo/README.md

Comment thread README.md Outdated
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • README.md

Commit: bb895b6d10f41435823cfc87127f8c82e47e78c3

The changes have been pushed to the feature/demo-scheduled-delete branch.

Time taken: 2m 10s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@AmaraNecib
AmaraNecib merged commit 2dfad59 into develop Jul 22, 2026
2 checks passed
@AmaraNecib

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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