Skip to content

Adopt an existing 09:00 digest task instead of writing a second one (#1751) - #3172

Merged
Birfy merged 2 commits into
mainfrom
dev/3114-digest-adopt
Nov 18, 2026
Merged

Birfy merged 2 commits into
mainfrom
dev/3114-digest-adopt

Conversation

@Birfy

@Birfy Birfy commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Written-by: Dev

Fixes #3171
Part of #3114 (the umbrella stays open — this slice closes its own issue)

Owner: Dev
Reviewer: Reviewer
Tier: T2

What changed

plugins/project/src/project-assistant.js L224 scheduleDigest wrote a schedule-create on every retry. A Project whose assistant Session already held its 09:00 digest got a second one; when that first task had been paused by its owner, the retry wrote an active copy over the pause; and when the Project had lost its id it could store the id of a row that had already ended, after which reconcile (L263 typeof scheduleId === 'string') never tried again and the Project had no digest at all.

scheduleDigest now reads schedules before it writes and adopts a task that is already on the Session with the digest title and a daily rule. DSH's task states are active | inactive (a paused task is merged in by schedulesView as status: 'paused'), so the test is kind === 'daily' && status !== 'inactive': a paused digest is adopted and stays paused, only an ended row is replaced. Only a miss reaches schedule-create, and the row read back after the write is found by the same identity. Identity is title + daily rule, not daily.time, because DSH normalises the time string (09:00:00.000) and a string compare would break with the version — that trade is written down in docs/subsystems/project.md.

Four cases were added to the existing file (no new file, no scaffold change), one changelog fragment, one docs line. core/** was not touched: no generate, no client.js.

Verification at the tip

Tip SHA: 0accac2f9f2ad7b7259c9216cfe77bcaf965dca2 (base 25ab31c97c4fa57de2174fa6a676bd937066cb21)

Ran (red, tests only — commit f98969e15b4ec31ca97012ee167960e20425f4a7, implementation untouched):

$ cd plugins/project && TZ=UTC node --import ./test/resolve.mjs --test test/project-assistant.test.js
# tests 32
# pass 28
# fail 4
not ok 11 - reconcile adopts a 09:00 digest already on the Session and does not write a second (#1751)
  the digest already on the Session is adopted, not written again — 2 !== 1 (expected 1, actual 2)
not ok 12 - reconcile adopts a paused digest rather than writing an active second one (#1751)
  the owner paused this digest, so no active one replaces it — 1 !== 0 (expected 0, actual 1)
not ok 13 - an ended digest is replaced, and the Project stores the live task rather than the dead one (#1751)
  the stored id names a task that can still fire — expected 'schedule-2', actual 'schedule-1'
not ok 14 - a weekly task reusing the digest title is not the digest (#1751)
  the adopted task is the daily one, not the weekly — expected 'schedule-2', actual 'schedule-1'

Ran at this tip:

$ cd plugins/project && TZ=UTC node --import ./test/resolve.mjs --test test/project-assistant.test.js
# tests 32 / # pass 32 / # fail 0        exit 0

$ cd plugins/project && TZ=UTC node --import ./test/resolve.mjs --test "test/*.test.js"
# tests 151 / # pass 151 / # fail 0      exit 0   (main: 147/147)

$ node scripts/ds-bot-patches.mjs check
ok   ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5)
ok   10 patches apply cleanly in order
ok   core/ equals ds-bot/ + patches/ds-bot/

$ node scripts/ds-bot-patches.mjs canonical
ok   patches/ds-bot/ is what generate writes (generate is a no-op)

$ node core/scripts/build-client.mjs --check          exit 0
$ git diff --exit-code core/client.js                 exit 0 (empty)
$ git diff --name-only origin/main...HEAD -- core/ patches/   empty

$ node .github/scripts/changelog.mjs check
changelog: 9 fragment(s) in changelog.d/ are well formed

$ npm --prefix core run arch-docs
arch-docs: OK (4 changed file(s))

$ TZ=UTC TMPDIR=/data/flybot-tmp npm run verify
VERIFY_EXIT=0   (core 3312 tests, plugins: social 715, tree 149, timeline 172, project 151, workflow, plane, policy — all green)

$ git diff --name-only origin/main...HEAD
changelog.d/3114-digest-adopt.fixed.md
docs/subsystems/project.md
plugins/project/src/project-assistant.js
plugins/project/test/project-assistant.test.js
$ git diff --numstat origin/main...HEAD | awk '{a+=$1;d+=$2} END{print a"+"d" = "a+d}'
106+2 = 108   (T2 limit: 250 lines / 12 files)
$ git diff --name-only origin/main...HEAD | grep -E '^(\.github/|policy/|scripts/|core/scripts/|.*package\.json$|.*package-lock\.json$)'   → 0 hits
$ git diff -U0 origin/main...HEAD -- plugins/project/src/project-assistant.js | grep -c "scheduleEndpoint('schedules'"   → 1

Environment note: this box has no git in PATH, so the git-dependent gates above (canonical, arch-docs, the git diff lines) ran with the bundled git 2.53.0 at /data/dsh/bot/workspace/tools/git; origin/main is a local ref to the base commit, whose tree b331dea586143f99a9901f8d82b02424e55632f7 equals main's tree at 25ab31c97c. Nothing in this list was deferred to tip CI.

Not run: the smoke bench (dev/bench.sh — this change touches neither index.js nor src/host/), and the CI package job's pack check, typecheck and actionlint.

Checkpoint

{
  "pr": 3172,
  "claim": "Dev",
  "issue": 3171,
  "summary": "A Project whose assistant Session already holds its 09:00 digest now adopts that task instead of writing a second one. The digest is identified by the Session, the title and a daily rule, so a task its owner paused is adopted and stays paused, while an ended (inactive) row is replaced. Only a miss writes, and the row read back after the write is found by the same identity. The stored scheduleId therefore always names a task that can still fire.",
  "files": ["plugins/project/src/project-assistant.js", "plugins/project/test/project-assistant.test.js", "docs/subsystems/project.md", "changelog.d/3114-digest-adopt.fixed.md"],
  "checks": { "ran": "TZ=UTC TMPDIR=/data/flybot-tmp npm run verify", "result": "green", "at": "0accac2f9f2ad7b7259c9216cfe77bcaf965dca2" },
  "next": "none — ready for review"
}

Four cases drive what `reconcile` does today: it writes a second 09:00 task
beside the one the Session already holds, writes an active one over the digest
its owner paused, keeps the dead row's id when a task ended, and treats a
weekly task that reuses the digest title as the digest. They fail until the
assistant adopts the task that is already there.

Part of #3114 (the umbrella stays open - this slice closes its own issue).
`reconcile` and `project-create` retried the digest by writing a task, so a
Session that already held its 09:00 digest got a second one — and when the
first was paused, the retry wrote an active copy over the owner's pause; when
the Project had lost its id it could store the id of an ended row and never
schedule again.

`scheduleDigest` now reads `schedules` first and adopts a task on the Session
with the digest title and a daily rule (`status !== 'inactive'`, so a paused
one counts and an ended one does not). Only a miss writes, and the row read
back after the write is found by the same identity.

Fixes #3171
Part of #3114 (the umbrella stays open - this slice closes its own issue).
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 18, 2026
@Birfy Birfy self-assigned this Nov 18, 2026
@Birfy
Birfy marked this pull request as ready for review November 18, 2026 16:18
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 18, 2026
@Birfy

Birfy commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at 0accac2
Written-by: Reviewer
Attestation: 0accac2 role=Reviewer

Ran at this tip:

$ cd plugins/project && TZ=UTC node --import ./test/resolve.mjs --test test/project-assistant.test.js
# tests 32  # pass 32  # fail 0
$ cd plugins/project && TZ=UTC node --import ./test/resolve.mjs --test "test/*.test.js"
# tests 151  # pass 151  # fail 0
$ cd red/plugins/project && TZ=UTC node --import ./test/resolve.mjs --test test/project-assistant.test.js   # tip tests, project-assistant.js reverted to the base blob
# tests 32  # pass 28  # fail 4
$ node scripts/ds-bot-patches.mjs canonical
exit 0
$ node .github/scripts/changelog.mjs check
exit 0
$ node core/scripts/build-client.mjs --check
exit 0

Reviewed at tip 0accac2 (tip tarball; red run on a copy with plugins/project/src/project-assistant.js replaced by the base blob):

  • Files: exactly 4, +106/−2 = 108 hand-written lines (T2: 250 lines / 12 files), no .github/**, policy/**, scripts/**, core/scripts/**, **/package.json or lockfile; git diff origin/main...HEAD -- core/ patches/ empty.
  • Behaviour: scheduleDigest reads schedules before writing and adopts only when sessionId is this Session, title === DIGEST_TITLE, kind === 'daily' and status !== 'inactive'; the row read back after schedule-create uses the same four conditions. No finished predicate and no status === 'active' anywhere, so a paused digest is adopted and stays paused.
  • reconcile is unchanged: only Projects with typeof assistant.scheduleId !== 'string', and it removes nothing.
  • Tests: 4 new cases in the existing file with the names the spec requires; the existing 28 are untouched, no skip/todo. Red first: 32/28/4 with exactly those four failing (2 !== 1, 1 !== 0, expected 'schedule-2' actual 'schedule-1' twice); at the tip 32/32 and the package 151/151.
  • Body numbers match my own count (106−2, 32/32, 151/151); canonical, changelog check and build-client --check exit 0 here rather than being deferred to CI; the checkpoint parses with no reasons (enqueue-rules checkpointReasons → [], block 940 characters).
  • Tip check-runs: 22, every one terminal; the only failure is enqueue-guard with no Verifier report names the tip 0accac2f9f2a, which is what this report answers.

next: enqueue this tip.

@Birfy
Birfy added this pull request to the merge queue Nov 18, 2026
@github-actions github-actions Bot added the pass label Nov 18, 2026
Merged via the queue into main with commit b303da8 Nov 18, 2026
21 of 24 checks passed
@Birfy
Birfy deleted the dev/3114-digest-adopt branch November 18, 2026 16:30
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#3114] #1751 日报收养:已有 09:00 digest 任务时不再写第二条

1 participant