feat(bg): B-0449 subscriber library (Decomposed from #3621)#3659
Open
AceHack wants to merge 1 commit into
Open
feat(bg): B-0449 subscriber library (Decomposed from #3621)#3659AceHack wants to merge 1 commit into
AceHack wants to merge 1 commit into
Conversation
|
|
||
| if (newlySeen) { | ||
| try { | ||
| writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2)); |
There was a problem hiding this comment.
Pull request overview
Adds the B-0449 subscriber-library slice for the bus, plus tests and backlog status updates.
Changes:
- Adds
subscribeOncefor topic/surface subscription with per-surface seen-state tracking. - Adds Bun tests for first-time handling and retry-after-handler-failure behavior.
- Updates the B-0449 backlog row to mark acceptance criteria as complete.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
tools/bus/subscribe.ts |
Introduces the subscriber helper and seen-file persistence. |
tools/bus/subscribe.test.ts |
Adds tests for handler invocation and retry behavior. |
docs/backlog/P1/B-0449-bg-services-slice-5-subscriber-agent-design-pass-2026-05-13.md |
Marks B-0449 status and acceptance criteria as shipped/complete. |
Comments suppressed due to low confidence (1)
tools/bus/subscribe.test.ts:59
- P0: This handler also declares an unused
envparameter, which trips the repo'snoUnusedParameters: trueTypeScript gate. The PR will not typecheck until this parameter is removed or renamed with the ignored underscore convention.
const handlerFailing = mock(async (env) => { throw new Error("fail"); });
| return [env1]; | ||
| }); | ||
|
|
||
| const handler = mock(async (env) => {}); |
| adapters = { list } | ||
| ): Promise<void> { | ||
| ensureDir(); | ||
| const seenFile = join(BUS_DIR, `seen-${surface}.json`); |
Comment on lines
+50
to
+52
| if (newlySeen) { | ||
| try { | ||
| writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2)); |
| id: B-0449 | ||
| priority: P1 | ||
| status: open | ||
| status: shipped |
| ## Acceptance criteria (design-pass) | ||
|
|
||
| - [ ] Library `tools/bus/subscribe.ts` exports `subscribeOnce(topic, handler)` that: | ||
| - [x] Library `tools/bus/subscribe.ts` exports `subscribeOnce(topic, handler)` that: |
| } | ||
|
|
||
| // Get all envelopes matching topic and targeted at this surface (or broadcast) | ||
| const envelopes = adapters.list({ topic, to: surface as any }); |
Comment on lines
+50
to
+52
| if (newlySeen) { | ||
| try { | ||
| writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2)); |
| try { | ||
| writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2)); | ||
| } catch (err) { | ||
| console.error(`[subscribeOnce] Failed to write seen file:`, err); |
Comment on lines
+28
to
+29
| } catch { | ||
| seenIds = new Set(); |
Comment on lines
+9
to
+13
| const seenFile = join(BUS_DIR, "seen-test-surface.json"); | ||
|
|
||
| // Helper to clear state | ||
| function clearState() { | ||
| try { rmSync(seenFile); } catch {} |
AceHack
added a commit
that referenced
this pull request
May 16, 2026
…e B shipped, Slice A pending) (#3763) * chore(b-0533): add Status section confirming partial-completion (Slice B shipped, Slice A pending) Empirical pure-git audit at 2026-05-16T05:48Z (rate-limit 0/5000) confirms B-0533 is partial completion per row-close gate triage. Shipped (Slice B): tools/hygiene/audit-section-33-migration-xrefs.ts via PR #3548 + PR #3555; gate.yml lint-section-33-migration-xrefs job wired. Pending (Slice A): the actual sweep of dead xrefs. Empirical evidence: multiple recent PRs (#3670, #3659, #3643, #3633, #3599) show the lint check FAILING — meaning dead xrefs persist. Row stays status: open until Slice A's persona-batched sweep PRs land. Co-Authored-By: Claude <noreply@anthropic.com> * chore(b-0533): bump last_updated to 2026-05-16 per tools/backlog/README.md (review fix) --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decomposed PR #3621. This PR only includes the subscriber library (B-0449).