← Back to Pull requests

feat(gateway): store and show a person's quiet hours #1584

Closed
unknown closed this pull request without merging on Oct 20, 2026 12:01 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 07:50 UTC
Author

What a user gets

A person, or the operator agent acting for them, can now set quiet hours and read them back:

rig gateway human quiet set alice --daily 22:00-07:00 --tz Europe/Berlin
rig gateway human quiet set alice --until 09:00 --tz America/New_York
rig gateway human quiet show alice
rig gateway human quiet end alice      # "I'm back": ends the quiet that's on now; tomorrow's rule stays
rig gateway human quiet clear alice    # removes the rule

  • The read-back gives the rule, its timezone, who set it, whether quiet is on now, and the actual next

  • boundary
    , correct across midnight and daylight-saving changes. For example:
    alice quiet: on (every day 22:00-07:00 Europe/Berlin; set by operator, manual, revision 1; ends 2026-10-21T05:00:00.000Z).
  • rig gateway human list now shows the person's actual availability (available, focus, away or off;

  • before, it showed only away or available), plus a quiet line. If the daemon can't be reached, the quiet line says
    so rather than implying there's no window.

    This PR only stores and shows quiet hours. Delivery doesn't act on them yet: asks still go to the person exactly as
    before. Holding routine asks during quiet and releasing them afterwards come in later PRs.

    How

  • The store: one quiet window per person (migration 118) holds:

  • - a daily local rule (HH:MM-HH:MM, which may cross midnight) or an until-time;
    - an IANA timezone, a revision, a source (manual), who set it and when;
    - the occurrence that was ended early, if any.
  • Revisions: setting again (to extend or replace) or clearing bumps the revision, so later work can tell a stale

  • schedule from the current one. "End" closes only the occurrence that's on now.
  • The resolver gives, for a person and a time:

  • - whether quiet is on;
    - the window, occurrence and revision;
    - the next start or end.
  • Daylight saving, one convention:

  • - a local time skipped at the spring change means the next valid minute;
    - a time repeated in the autumn means its first occurrence.
  • --until takes HH:MM (its next occurrence in the timezone) or an ISO time with an offset. Without --tz, the

  • CLI sends the machine's own timezone, and the read-back shows it.
  • Routes:

  • - GET / PUT /api/gateway/human/:entityId/quiet;
    - POST …/quiet/end and POST …/quiet/clear.
  • Route rules:

  • - They work only for a registered person (404 otherwise).
    - They record the acting seat, or the named actor outside a seat.
    - They refuse an unknown timezone, a malformed time, an empty window or a time already passed, with a message saying
    what to give instead.

    Tests

  • The resolver (human-quiet-windows.test.ts, 19), on real SQLite with an injected clock:

  • - a daily window across midnight and within one day;
    - an until-time;
    - end-then-tomorrow, and "end" when quiet isn't on;
    - extend and replace bumping the revision, and a new revision undoing an earlier end;
    - clear, then set again, with revisions still counting;
    - a restart (a new store over the same database);
    - another person's window untouched;
    - invalid input;
    - in Europe/Berlin: the skipped spring hour and the repeated autumn hour, a ten-hour and an eight-hour night, and a
    window starting inside the skipped hour.
  • The routes (human-quiet-windows-route.test.ts, 5): set, show, end, clear and their refusals; a local HH:MM

  • until-time; the actor; an unregistered person.
  • The CLI (gateway-human-quiet-verb.test.ts, 9, over real HTTP to a recording stub): each verb's request and

  • read-back, an occurrence ended early named by its date (and an until-time one), a refusal's message and exit code, and list's availability and quiet lines (including when quiet can't be
    read).
  • Updated: one existing CLI test's stub daemon now also answers the quiet route that list reads.

  • Red first: on main's source, the CLI tests fail (6 of 6), and the two daemon files can't load, because the store

  • and migration don't exist there.
  • Delivery unchanged: the delivery rules, Slack posting, the digest and deferral policies, the wake ladder and the

  • stuck sweep are byte-identical to main. Their existing tests pass unchanged.

    Changes after review

  • The read-back names the occurrence that was ended early, by its date (for example, "the 2026-10-20 occurrence ended

  • early by alice"), or just "ended early" for an until-time window. It no longer says "tonight's", which was wrong the
    next day, and for a window that isn't overnight.
  • A night whose whole window falls in a skipped hour is empty, for example 02:10-02:20 in Berlin on the spring

  • change. It's no longer shown as the next start: the read-back names the next night that has quiet.
  • quiet set without --tz says which zone it stored, and that --tz gives the person's own.
  • Not in this PR

  • Holding asks during quiet, releasing them at the end, and how held asks show in the waiting views.

  • Setting quiet hours from a mode.

  • Any change to away, focus or off.

  • Any new refusal on a send.
  • Native: NOT RUN

    Everything here runs hermetically (temp homes, SQLite, a stub daemon). No real Slack and no installed daemon.

    🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added quiet-hours management for gateway humans, including daily schedules and one-time end times.
    Added CLI commands to set, view, end, and clear quiet hours with timezone and JSON support.
    Gateway listings now show quiet status, rules, boundaries, and effective availability.
    Added support for active periods, upcoming boundaries, midnight crossings, and daylight-saving transitions.
    Added validation and clear error reporting for invalid schedules, timezones, timestamps, and unavailable quiet-hours data.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvschwarz Review duration: 250m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1584"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%