Commit graph

25 commits

Author SHA1 Message Date
dependabot[bot]
fe97c97db4
Update slack-sdk requirement in /src/weekly-post
Updates the requirements on [slack-sdk](https://github.com/slackapi/python-slack-sdk) to permit the latest version.
- [Release notes](https://github.com/slackapi/python-slack-sdk/releases)
- [Commits](https://github.com/slackapi/python-slack-sdk/compare/v3.41.0...v3.42.0)

---
updated-dependencies:
- dependency-name: slack-sdk
  dependency-version: 3.42.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-20 05:03:50 +00:00
Adam Moussa
fc077e76a4
Fix shared layer packaging that broke all Lambdas (#67)
Some checks failed
Deploy / deploy (push) Has been cancelled
* Fix shared layer packaging — remove python/ wrapper that caused double nesting

SAM BuildMethod: python3.12 wraps layer content in python/ during build.
The source had an extra python/ directory, resulting in the shared package
landing at python/python/shared/ instead of python/shared/. All 4 Lambdas
are failing with ImportModuleError since the PR #62 merge.

* Update CI source-dirs to match new shared layer path
2026-05-13 14:14:21 -04:00
dependabot[bot]
36d3d75654
Update requests requirement from >=2.33.1 to >=2.34.0 in /src/shared (#65)
Some checks are pending
Deploy / deploy (push) Waiting to run
Updates the requirements on [requests](https://github.com/psf/requests) to permit the latest version.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.33.1...v2.34.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.34.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-13 00:00:05 +00:00
dependabot[bot]
8aee98c279
Update slack-sdk requirement in /src/weekly-post (#66)
Updates the requirements on [slack-sdk](https://github.com/slackapi/python-slack-sdk) to permit the latest version.
- [Release notes](https://github.com/slackapi/python-slack-sdk/releases)
- [Commits](https://github.com/slackapi/python-slack-sdk/compare/v3.33.0...v3.41.0)

---
updated-dependencies:
- dependency-name: slack-sdk
  dependency-version: 3.41.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-12 23:59:37 +00:00
dependabot[bot]
3d06b478d4
Update requests requirement in /src/roster-sync (#64)
Updates the requirements on [requests](https://github.com/psf/requests) to permit the latest version.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.33.1...v2.34.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.34.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-12 23:59:24 +00:00
dependabot[bot]
6b91ed4aa4
Update requests requirement in /src/ring-scheduler (#63)
Updates the requirements on [requests](https://github.com/psf/requests) to permit the latest version.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.33.1...v2.34.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.34.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-12 23:59:14 +00:00
Adam Moussa
5fc60b6979
Merge ring-scheduler-3cx and resolve all open issues (#62)
* Add arm64, log retention, and compliance fixes

- Set arm64 architecture globally for all Lambda functions
- Add explicit CloudWatch log groups with 60-day retention
- Add missing WeeklyPostFunctionArn to stack outputs
- Add Dependabot assignees for both ecosystems
- Add samconfig.toml.example for onboarding

* Restructure src/ to per-function layout with shared Layer

Move from flat src/ to per-function directories:
- src/slack-bot/ — Slack Bolt Lambda handler
- src/weekly-post/ — Monday schedule + pay post
- src/roster-sync/ — Daily 3CX roster sync
- src/shared/ — Lambda Layer with schedule, blocks, three_cx_client

Each function has its own requirements.txt and CodeUri. Shared
modules are deployed as a SAM Layer (afterhours-shared) importable
as `from shared.X import Y`.

* Migrate secrets from SSM Parameter Store to Secrets Manager

- Slack bot token and signing secret now read from Secrets Manager
- 3CX credentials (domain, client-id, client-secret) moved to
  Secrets Manager under afterhours-shift-manager/3cx-* prefix
- Channel ID is now a non-secret CloudFormation parameter (ShiftChannel)
- Add shared secrets.py helper for Secrets Manager reads
- Remove SSM and KMS IAM policies, add secretsmanager:GetSecretValue

* Merge ring-scheduler-3cx as 4th Lambda function

- Add afterhours-ring-scheduler Lambda with 4 EventBridge rules
  (daily 8am EST/EDT + weekend 5pm EST/EDT) for 3CX ring group
  routing updates
- Extract shared ring_scheduler.py module for direct ring group
  updates from both the scheduled Lambda and the Slack bot
- Replace cross-Lambda invoke with direct update_ring_group() call
  in the Slack bot — eliminates lambda:InvokeFunction dependency
- Use RingGroup API (correct) instead of Queue API (was wrong in
  the original ring-scheduler repo)
- Eliminate YAML config fallback — DynamoDB is the sole schedule
  source
- Add RingGroupNumber CloudFormation parameter

* Add schedule post live-update and old post deletion (#40, #41)

- Store schedule message timestamp in DynamoDB (SCHEDULE_POST record)
- Delete previous week's schedule post before posting the new one
- Live-update the schedule post via chat_update after any
  pick/drop/swap/button-pickup so it always reflects current state

* Disallow past shifts and add day/night labels (#43, #42)

- Reject /oncall pick and /oncall drop for past dates
- Show ephemeral error when stale pickup buttons are clicked
- Hide pickup buttons for dates in the past
- Add explicit "Day (8am-5pm)" and "Night (5pm-8am)" labels to
  schedule lines, pickup buttons, and shift change notifications

* Add admin slash commands for shift and roster management (#39)

- /oncall admin override <date> <ext> — assign a shift
- /oncall admin open <date> — mark shift as open
- /oncall admin clear <date> — remove override, revert to weekly
- /oncall admin roster add/remove/rename — manage roster entries
- Admin access gated by admin_users list in DynamoDB CONFIG
- Help message shows admin commands for admin users

* Update README for merged architecture and new features

* Switch from RingGroup API to Queue API at extension 801

The 3CX routing was changed from ring group 800 to queue 801 in a
previous PR on ring-scheduler-3cx. Updates all callers and the SAM
template parameter default accordingly.

* Pass SAM parameter overrides in deploy workflow

* Fix review findings: IAM, routing guards, past-date check, roster safety

- Ring scheduler: use DynamoDBCrudPolicy (resolve_shift needs Query)
- Button pickup: update 3CX for active shift type, not just night
- Pick/drop/swap commands: only update 3CX when shift type is active
- Swap command: add missing past-date guard
- add_roster_entry: reject if extension already exists
- Apply ruff formatting

* Add error handling to ring scheduler 3CX call

* Fix weekend day shift commands and admin 3CX routing

- Add _find_employee_shift() to check both day/night on weekends
- Drop/swap now correctly find and operate on weekend day shifts
- Pick finds first available shift type on weekends
- Admin override/open/clear update 3CX for same-day active shifts

* Fix dependabot directories and admin weekend shift handling

Dependabot now scans per-function requirement directories instead
of the repo root. Admin override/open/clear commands accept an
optional day/night parameter for weekend day shift management.

* Fix weekend day shift active window to 8am-5pm

Before midnight-8am on weekends incorrectly reported the day shift
as active when the previous night shift is still running.

* Show shift type label for both weekend shifts in notifications

Night shift notifications on weekends were missing the type label,
making them ambiguous. Also fix schedule post text fallback to use
this_monday instead of now for the start date.

* Extract determine_shift_type into shared layer

Eliminates duplicated weekend day/night boundary logic between
the ring scheduler and Slack bot Lambdas.

* Fix weekly schedule fallback start date

Co-authored-by: Adam Moussa <amoussa1229@users.noreply.github.com>

* Include weekend shift type in command confirmations

Co-authored-by: Adam Moussa <amoussa1229@users.noreply.github.com>

* Apply ruff formatting to app.py

* Only show day/night shift labels on weekends in schedule display

Weekday shifts are always night — the label was redundant clutter.

* Deduplicate 3CX forwarding payload and add shift type to pick command

Extract _update_forwarding helper in ThreeCXClient to share the
payload between queue and ring group methods. Add optional day/night
argument to /oncall pick so users can target a specific weekend shift.

* Consolidate WEEKEND_DAYS and fix weekday pickup button labels

Import WEEKEND_DAYS from shared.schedule instead of redefining in
blocks.py and weekly-post/app.py. Gate pickup button day/night
labels on weekends only, matching all other display surfaces.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Adam Moussa <amoussa1229@users.noreply.github.com>
2026-05-12 19:55:39 -04:00
Adam Moussa
c741924ee7
Add CI workflow and apply ruff formatting (#57) 2026-05-08 15:46:51 -04:00
Adam Moussa
61074dc7cc
Fix shift pickup showing error despite succeeding (#31) (#32)
Two root causes:
- claim_open_shift ConditionExpression failed when no OVERRIDE record
  existed (shift available via weekly fallback). Added attribute_not_exists
  check so claims succeed for both missing and OPEN overrides.
- Slack ack timeout: chat_postMessage took too long before respond() was
  called, causing Slack to show an error. Moved respond() first and made
  channel notifications best-effort with try/except.
2026-05-01 15:16:11 -04:00
Adam Moussa
7b2275a430
Post shift change notifications to the schedule channel (#21) (#22)
Slash command handlers (drop, pick, swap) were posting notifications to
command["channel_id"] — wherever the command was run. If someone ran
/oncall drop from a DM, the notification went there instead of the
schedule channel. Pickup buttons didn't have this problem because
body["channel"]["id"] is always the channel where the button lives.

Added SHIFT_CHANNEL_PARAM to the SlackBotFunction env vars, read it on
cold start, and route all slash command shift-change notifications to
the configured schedule channel.

Closes #21
2026-05-01 14:15:56 -04:00
Adam Moussa
1e90e0eaa2
Fix race condition allowing multiple people to pick up the same shift (#19) (#20)
The pickup button handler used an unconditional put_item, so concurrent
clicks would both succeed with last-write-wins. Added claim_open_shift()
which uses a DynamoDB ConditionExpression to only write if the shift is
still OPEN. The button handler now returns an ephemeral "already taken"
message when the condition fails.

Closes #19
2026-05-01 14:09:39 -04:00
Adam Moussa
fe6b780e12
Fix weekly schedule starting from today instead of Monday (#18)
The handler passed `now` as start_date, so mid-week runs showed
14 days from today instead of Mon–Sun x2. Also, day names were
derived from a static index (DAY_ORDER[i%7]) which assumed
index 0 = Monday — when start_date wasn't Monday, Saturday and
Sunday were mislabeled as Monday and Tuesday.

Fix: pass this week's Monday from the handler, and derive day
names from the actual date via strftime instead of a static list.

Fixes #17
2026-04-08 13:36:34 -04:00
Adam Moussa
6ad952c498
Remove shift count column from pay email, update footer text (#15)
- Remove the Shifts column from the Bonus Pay Summary email table (fixes #14)
- Change footer from "After-Hours Shift Manager" to "Sea Haven Industries" (fixes #13)
- Update README with pay report email section
2026-04-08 13:22:28 -04:00
Adam Moussa
9e2eab6953 DM pay reports to admin, rename email to Bonus Pay Summary
- Pay summary sent as DM to designated user instead of channel
- Email shows only per-person totals, no shift breakdown
- Renamed email subject/header to "Bonus Pay Summary"
2026-04-07 19:07:44 -04:00
Adam Moussa
65d35281b2 Fix DynamoDB float error — use Decimal for pay records 2026-04-07 18:59:52 -04:00
Adam Moussa
f8ceb1dc83 Add force flag to weekly post handler for manual testing 2026-04-07 18:58:03 -04:00
Adam Moussa
9deb8bf251 Email weekly pay summary to payroll via SES on Mondays
Sends an HTML pay summary email to configured payroll recipients
alongside the existing Slack post. Uses SES with noreply@seahaven.com
as sender. Recipients configured via PAYROLL_RECIPIENTS env var
(set to adam@seahaven.com for testing, switch to payroll@seahaven.com
for production).

Closes #3
2026-04-07 18:54:19 -04:00
Adam Moussa
093bb43e71 Add force flag to roster sync DST guard 2026-04-07 18:46:26 -04:00
Adam Moussa
ac3bd455e7 Add 3CX roster sync Lambda with daily EventBridge trigger
Syncs DynamoDB roster from a configured 3CX group daily at 6am ET
(before the 7am schedule post). Includes ThreeCXClient for XAPI
authentication and group member queries. Preserves existing
slack_user_id links and guards against accidental roster wipes.

Closes #4
2026-04-07 18:43:19 -04:00
Adam Moussa
7eb0443866 Add weekend day shifts and exclude fallback ext from pay
Saturdays and Sundays now have two shift slots: a day shift (8am–5pm)
and the existing after-hours shift. Extension 100 (fallback) is
excluded from pay calculations. Pickup buttons and schedule display
updated to handle both shift types.
2026-04-07 18:22:56 -04:00
Adam Moussa
e28f591816 Add /oncall rate command to manage shift pay rates from Slack
- /oncall rate — view current default and per-person rates
- /oncall rate default <amount> — set the global fallback rate
- /oncall rate <extension> <amount> — set a person-specific rate
2026-04-07 18:15:41 -04:00
Adam Moussa
1399be7e74 Support per-person shift pay rates
Each roster entry can now have its own shift_rate, falling back to the
global CONFIG rate when not set. Pay breakdowns show individual rates
per shift and per-person totals.
2026-04-07 18:12:32 -04:00
Adam Moussa
d569621c72 Add weekly pay calculation with configurable flat rate
Calculates after-hours pay per shift using a configurable rate stored
in DynamoDB CONFIG. Pay summaries are computed on Monday mornings for
the previous week, stored in DynamoDB (PK=PAY), and posted to Slack.
Adds /oncall pay command for on-demand viewing.

Closes #2
2026-04-07 18:09:19 -04:00
Adam Moussa
3a51b52ffc Extend schedule display to show 2 full weeks
Anchors to the current week's Monday and shows 14 consecutive days.
Updates /oncall next to jump forward by 2 weeks accordingly.

Closes #1
2026-04-07 18:01:10 -04:00
Adam Moussa
4d0cdb5cfb Initial commit: after-hours shift manager Slack bot
Slack Bolt app on Lambda for managing on-call shifts. Employees can
pick up, drop, and swap shifts via /oncall commands. Changes update
3CX ring group 800 routing in real time for same-day shifts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:32:32 -04:00