Skip to content

feat(elm): fix and complete ELM core – leave rules, workflow, API, UI, tests - #250

Open
Nikhil-the-boy wants to merge 3 commits into
FusionIIIT:mainfrom
Nikhil-the-boy:elm-phase2-refinement
Open

Nikhil-the-boy wants to merge 3 commits into
FusionIIIT:mainfrom
Nikhil-the-boy:elm-phase2-refinement

Conversation

@Nikhil-the-boy

Copy link
Copy Markdown

1. Student Details

  • Roll Number: 24BCS171
  • Partner's Roll Number: 24BCS167

2. Environment Configuration

  • Development Environment: macOS (MacBook Air M5), zsh, Python 3.12, Node 26
  • Testing: pytest, ruff, import-linter, the repo's ops/checks, vitest, tsc

3. Summary of Improvements Made in Phase 2

1. Fixes to the PR #102 Code

  • Fixed apps.py. It had the typo django.db.modelsmodels.BigAutoField and name = "elm", so Django could not start.
  • Added the missing initial migration.
  • Replaced ForeignKey(User) with IAM user ids, as ADR-0013 requires. This platform has no user table.
  • Removed the open access: before this fix, any signed-in user could approve or reject any request.
  • Rewrote the frontend form. It had a wrong API URL, field names that did not match the backend, an onChanget typo, leave types that are not in the spec, and raw axios.

2. Domain Models and Business Rules (pure Python, modules/elm/domain/)

  • Leave categories CL, RH, SCL, EL, COL and VL, with annual entitlements: 8 / 2 / 15 / 30 (non-faculty) / 20 / 60 (faculty) (BR-EL-001 to 006, 009).
  • Category eligibility: only faculty and staff can apply, and VL is faculty-only.
  • Day counting: weekends and supplied holidays are skipped for CL/SCL/RH, and every day counts for EL/COL/VL (BR-EL-011). A half-day CL counts as 0.5 (BR-EL-010).
  • Overlap check against the applicant's active leave. Two different halves of the same day do not overlap (BR-EL-012).
  • Station Leave is part of the same application, and its address and contact are required (BR-EL-013).
  • Balance check. Pending requests reserve days, so two requests cannot spend the same balance.

3. Workflow (declarative state machine)

  • CL/RH: the Unit Head approves or rejects (BR-EL-016).
  • SCL/EL/COL/VL: the Unit Head marks Recommended or Not Recommended. Either way it goes to the Sanctioning Authority, who makes the final decision (BR-EL-017/018).
  • Only the applicant can withdraw, and only before final approval (BR-EL-022). Nobody can decide their own request.
  • Requests cannot be edited after submission (BR-EL-034). Every change is recorded in an append-only history.
  • The balance is deducted only on final approval, inside a locked transaction.

4. Integration with Fusion

  • API at /api/v1/elm/ (requests, requests/apply, requests/<id>, requests/<id>/transition, balances). It is guarded by the leave module grant and the leave.request.* permissions from the platform's permission catalogue.
  • registry.py adds nav items and role grants. The permission manifest and the OpenAPI schema were regenerated.
  • Frontend has Apply for Leave, My Leave and Approvals pages, built on Fusion's shared http client and UI components, and registered in client/src/app/registry.ts.

5. Automated Testing

  • 52 ELM tests: 39 domain and 13 API. The API tests cover permissions, 404 for other people's requests, overlap, balance, the workflow and withdrawal.
  • Verification:
    • 73 tests passed (modules/elm and modules/accesscontrol)
    • ruff clean, import-linter 5/5 contracts kept
    • nav_matches_routes, no_cross_module_fk and permission_manifest --check pass
    • the schema generates with 0 warnings
    • tsc, 35 client tests and vite build pass

6. Remaining Work

  • Substitute nomination and consent (BR-EL-014/015).
  • Cancellation, extension and resumption (BR-EL-023 to 028).
  • RH and holiday calendar (BR-EL-031), Academic Calendar vacation periods for VL, and year-end lapse, carry-forward and VL-to-EL conversion.
  • A configurable hierarchy, Establishment step and Director self-sanction (BR-EL-019/020). Unit Head scoping by department.
  • SLA reminders and escalation, notifications, and offline-leave entry.
  • The module stays at status: "planned" until these are done.

7. Scope Note and Limitations

This PR fixes the module generated in PR #102 and builds a tested core for ELM: rules, workflow, API and UI. It does not cover all ELM requirements.

PostgreSQL was not available locally, so the tests ran on SQLite with --nomigrations. Row locking and the migration were therefore not exercised against Postgres. CI should confirm them.

Nikhil and others added 2 commits October 12, 2026 00:05
…, tests

Refines the DeepSeek-generated ELM module from PR FusionIIIT#102. The refinement was
done with Claude (cloud AI), not the local model; see
docs/elm-phase2-evidence/README.md.

- Fix app config so Django starts; add initial migration
- Replace ForeignKey(User) with IAM user ids (ADR-0013)
- Pure-Python domain: entitlements, eligibility, day counting,
  half-day CL, overlap, Station Leave, balance reservation
- Declarative state machine: Unit Head decides CL/RH; recommendation
  then sanction for SCL/EL/COL/VL; applicant-only withdrawal; no self-approval
- Services with row locking and an append-only transition history
- API guarded by module grant and leave.request.* permissions
- Registry, permission manifest and OpenAPI schema regenerated
- Frontend: Apply, My Leave and Approvals pages on the shared http client
- 52 ELM tests (39 domain, 13 API)

Students: Nikhil (24BCS171), Nehant (24BCS167)
Clarified the source of Phase 2 refinement in the README.
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