Skip to content

fix(scheduling): generar respetando días fijos y solicitudes, y mes publicado de solo lectura - #19

Merged
bpstack merged 7 commits into
claude/compassionate-planck-gh6aoffrom
opencode/fix-scheduling
Oct 12, 2026
Merged

bpstack merged 7 commits into
claude/compassionate-planck-gh6aoffrom
opencode/fix-scheduling

Conversation

@bpstack

@bpstack bpstack commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Cambios

  • Al generar, se respetan las celdas de días fijos y de solicitudes aprobadas (antes quedaban vacías).
  • Un mes publicado es de solo lectura (409); las ediciones masivas no salen de su mes; reiniciar un mes va en una transacción.
  • Guardar la lista de empleados conserva fechas y orden.
  • docs/scheduling/decisions.md: el solver sigue sin ser determinista, LI fuera de las reglas de descanso y la cola del daemon se quedan como están.

Por qué

Los meses generados dejaban vacías celdas fijadas, y se podía editar un mes publicado desde uno en borrador.

…ating

- generated-rows.ts: builds the rows to insert from the solver matrix and
  the locked cells, skipping only those stored with source_constraint_id.
- schedule-generate.controller.ts: uses it; the locked cells that live only
  in lockedCells (fixed days, approved requests) are inserted with their
  locked value.
- generated-rows.test.ts: covers both kinds of locked cell and the virtual
  days of the previous month.

Why: generation skipped every locked cell when inserting, while the delete
before it only spares the stored ones, so fixed-day and approved-request
cells ended empty. Checked against the local database: the two fixed-days
employees had 0 cells in the four solver-generated months; regenerating
October 2026 gives each 31 (P on weekdays, L at weekends), also in the grid.
- scheduling-controller.ts: refusePublished answers 409 when the month is
  published; editing a cell or a day (one or in bulk) and creating,
  editing, approving or deleting a constraint use it. PUT /months/:id no
  longer goes back to draft: that is what unpublish is for. Notes can
  still be edited.
- published-month.test.ts: the nine paths answer 409 and write nothing.

Why: none of these paths looked at the month status, so a published
roster could change under the staff reading it. Checked with curl against
the local database: on a published month a cell edit and PUT back to
draft answer 409; after unpublish the same edit answers 200.
- scheduling-repository.ts: setSchedulableEmployees removes only the
  employees left out and adds only the new ones, in one transaction; the
  rows that stay keep start_date, end_date, display_order and added_by.
  An unknown id still fails instead of being ignored.
- schedulable-employees.test.ts: the queries it runs, the empty list and
  the rollback.

Why: it cleared scheduling_employees and filled it again, so every save
lost the start and end dates and the manual order. Checked with curl
against the local database: a start date set on an employee survives
saving the same list.
- decisions.md: 2026-10-11 entry with the measurements (current, seed,
  one thread, interleave_search) on the local month and the 30x31
  benchmark, the decision and how to revisit it.

Why: the owner chose generation speed over reproducibility; the TODO
entry asked to decide it.
… in one transaction

- Bulk edits of cells and days answer 400 when a day id is not a day of
  the month in the URL (countDaysInMonth).
- bulkUpsertAssignments reads the locked cells FOR UPDATE and writes the
  edit in one transaction; a locked cell still answers 409 and now nothing
  is written.
- resetMonthAssignments corrects the dates, deletes the cells and inserts
  the new grid in one transaction.
- fixMonthDates, deleteAllAssignmentsByMonth and upsertAssignment go: they
  had no other user.
- services/scheduling/AGENTS.md: both rules and the real bulk endpoint.
- month-scope.test.ts: foreign days, the locked cell and the reset.

Why: PUT /months/141/assignments with a day of month 140 rewrote that cell
through uk_day_employee, so a published month could be edited from any
draft month; and a reset that failed after the delete left the month
empty. Checked against the local database: the cross-month edit changed
October from November before and answers 400 now, a locked cell answers
409 with nothing written, a reset whose insert fails keeps its 280 cells,
and editing a cell from the grid in the browser still saves.
…solver

- decisions.md: LI does not count towards the weekly free days nor the
  monthly minimum of L, and it stays that way.

Why: decided by the owner on 2026-10-12; it matches the catalogue, which
describes LI as an extra free day, and keeps every hard rule unchanged.
- decisions.md: the 30-minute startup limit and the unbounded queue are
  kept, with the reasons and what to change if it is revisited.

Why: decided by the owner on 2026-10-12; only admins generate, the demo is
rate limited and the daemon starts in seconds.
@bpstack
bpstack merged commit 9a925bb into claude/compassionate-planck-gh6aof Oct 12, 2026
4 checks passed
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
four-points Ready Ready Preview Oct 12, 2026 6:53pm UTC

@bpstack
bpstack deleted the opencode/fix-scheduling branch October 12, 2026 19:02

This branch was successfully deployed

1 active deployment
Preview — 9f1344ef Deployed Oct 12, 2026 by vercel[bot]
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