The night watch
You will learn
What the night watch does in the morning with four card checks.
Every night four checks of the card chat run: the thread, the status door, the merges and the parity. night_verdict sums them up: any fail is a fail, else anything unmeasured is unmeasured, else it is a pass. night_report turns that into one act: a fail opens an issue or comments on the open one, a pass closes an open issue or stays silent, and an unmeasured night leaves everything as it is.
Try it
Make the night pass with the issue open; then make one check unmeasured.

Every night four card checks run. Tap each to pass, fail or unmeasured: night_verdict sums them up and night_report says whether to open an issue, comment, close it or stay silent.
specs/automation/card-chat-night-watch.t27
// SPDX-License-Identifier: Apache-2.0
// Card Chat Night Watch - verdict and reporting logic
// Part of EPIC #5388
module CardChatNightWatch {
// Verdict constants
const CHECK_PASS: u8 = 0
const CHECK_FAIL: u8 = 1
const CHECK_UNMEASURED: u8 = 2
// Report constants
const REPORT_SILENT: u8 = 0
const REPORT_OPEN_ISSUE: u8 = 1
const REPORT_COMMENT: u8 = 2
const REPORT_CLOSE_ISSUE: u8 = 3
const REPORT_LEAVE_AS_IS: u8 = 4
// Total number of card check verdicts (thread, status door, merges, parity)
const CARD_CHECK_VERDICTS: u8 = 4
// Determine night verdict based on failures and unmeasured checks
// Any fail -> FAIL; else any unmeasured -> UNMEASURED; else PASS
fn night_verdict(fails: u8, unmeasured: u8) -> u8 {
if fails > 0 {
return CHECK_FAIL
} else if unmeasured > 0 {
return CHECK_UNMEASURED
} else {
return CHECK_PASS
}
}
// Determine night report based on verdict and issue state
// FAIL and no open issue -> OPEN_ISSUE
// FAIL and an open issue -> COMMENT
// PASS and an open issue -> CLOSE_ISSUE
// PASS and none -> SILENT
// UNMEASURED -> LEAVE_AS_IS whatever the issue state
// a verdict above 2 -> LEAVE_AS_IS
fn night_report(verdict: u8, issue_open: bool) -> u8 {
if verdict > 2 {
return REPORT_LEAVE_AS_IS
}
if verdict == CHECK_FAIL {
if issue_open {
return REPORT_COMMENT
} else {
return REPORT_OPEN_ISSUE
}
} else if verdict == CHECK_PASS {
if issue_open {
return REPORT_CLOSE_ISSUE
} else {
return REPORT_SILENT
}
} else {
return REPORT_LEAVE_AS_IS
}
}
// Check if night counts are acceptable
// true when fails + unmeasured <= CARD_CHECK_VERDICTS
fn night_counts_ok(fails: u8, unmeasured: u8) -> bool {
let total = fails + unmeasured
return total <= CARD_CHECK_VERDICTS
}
// Tests
test night_verdict_all_pass
let result = night_verdict(0, 0)
assert result == CHECK_PASS
test night_verdict_any_fail
let result = night_verdict(1, 0)
assert result == CHECK_FAIL
test night_verdict_fail_beside_unmeasured
let result = night_verdict(1, 3)
assert result == CHECK_FAIL
test night_verdict_any_unmeasured_no_fail
let result = night_verdict(0, 1)
assert result == CHECK_UNMEASURED
test night_report_fail_no_issue
let result = night_report(CHECK_FAIL, false)
assert result == REPORT_OPEN_ISSUE
test night_report_fail_with_issue
let result = night_report(CHECK_FAIL, true)
assert result == REPORT_COMMENT
test night_report_pass_with_issue
let result = night_report(CHECK_PASS, true)
assert result == REPORT_CLOSE_ISSUE
test night_report_pass_no_issue
let result = night_report(CHECK_PASS, false)
assert result == REPORT_SILENT
test night_report_unmeasured_with_issue
let result = night_report(CHECK_UNMEASURED, true)
assert result == REPORT_LEAVE_AS_IS
test night_report_unmeasured_no_issue
let result = night_report(CHECK_UNMEASURED, false)
assert result == REPORT_LEAVE_AS_IS
test night_report_invalid_verdict
let result = night_report(5, true)
assert result == REPORT_LEAVE_AS_IS
test night_counts_ok_within_limit
let result = night_counts_ok(2, 2)
assert result == true
test night_counts_ok_at_limit
let result = night_counts_ok(4, 0)
assert result == true
test night_counts_ok_over_limit
let result = night_counts_ok(3, 2)
assert result == false
test night_counts_ok_zero
let result = night_counts_ok(0, 0)
assert result == true
// User scenario tests
test scenario_unmeasured_night_with_open_issue
// Given a night where the render answered 401 to every read
// when night_report(night_verdict(0, 4), true) is evaluated
// then it returns REPORT_LEAVE_AS_IS
let verdict = night_verdict(0, 4)
let result = night_report(verdict, true)
assert result == REPORT_LEAVE_AS_IS
test scenario_fail_night_no_open_issue
// Given a night where the parity check failed and nothing else did
// when night_report(night_verdict(1, 0), false) is evaluated
// then it returns REPORT_OPEN_ISSUE
let verdict = night_verdict(1, 0)
let result = night_report(verdict, false)
assert result == REPORT_OPEN_ISSUE
}All lessons
Module 1 · The task
An issue becomes work only once it is shaped: the sections it lacks are written or asked for, its boundary names real files, and one filter reads every kind of task.
Module 2 · Who goes next
The order the Queen takes issues in: a label ages one step, at most 3 criticals run as critical, and nothing new starts while finished work waits for review.
Module 3 · A bee's life
From candidate to done: twelve states and sixteen events, a ship in the game that flies home, and a deploy that does not cut a bee short.
Module 4 · The reviewer bee
Finished work is judged on its own clock: enough reviews at once to keep up, a pause that doubles for a row that waits, and a merge gate that zero checks cannot open.
Module 5 · The review jam
A pull request that will not move is in exactly one of ten cases, each with the Queen's move, and a red check is inherited only when master says so.
Module 6 · Keys
A bee's model key can be refused: the code in the body sorts the refusal, a transient one rests the key for seconds, and the bee moves on to the next free key.
Module 7 · Credit and money
Lending a key earns no credit, an operation is sold at twice its cost in half-cent tokens, and tokens burn 30 days after they land.
Module 8 · Agents among themselves
One bot per agent in one group: who is called, a chain three bot messages deep, and the clocks that keep agents from flooding a chat.
Module 9 · Night and the board
What the hive shows: a night watch that opens, comments on and closes issues, the columns of the public board, and the comb that flashes for each event.