Skip to content

feat(bg): B-0449 subscriber library (Decomposed from #3621)#3659

Open
AceHack wants to merge 1 commit into
mainfrom
lior/decompose-3621-part1-new
Open

feat(bg): B-0449 subscriber library (Decomposed from #3621)#3659
AceHack wants to merge 1 commit into
mainfrom
lior/decompose-3621-part1-new

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 16, 2026

Decomposed PR #3621. This PR only includes the subscriber library (B-0449).

Comment thread tools/bus/subscribe.ts

if (newlySeen) {
try {
writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2));
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the B-0449 subscriber-library slice for the bus, plus tests and backlog status updates.

Changes:

  • Adds subscribeOnce for 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 env parameter, which trips the repo's noUnusedParameters: true TypeScript 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) => {});
Comment thread tools/bus/subscribe.ts
adapters = { list }
): Promise<void> {
ensureDir();
const seenFile = join(BUS_DIR, `seen-${surface}.json`);
Comment thread tools/bus/subscribe.ts
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:
Comment thread tools/bus/subscribe.ts
}

// Get all envelopes matching topic and targeted at this surface (or broadcast)
const envelopes = adapters.list({ topic, to: surface as any });
Comment thread tools/bus/subscribe.ts
Comment on lines +50 to +52
if (newlySeen) {
try {
writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2));
Comment thread tools/bus/subscribe.ts
try {
writeFileSync(seenFile, JSON.stringify(Array.from(seenIds), null, 2));
} catch (err) {
console.error(`[subscribeOnce] Failed to write seen file:`, err);
Comment thread tools/bus/subscribe.ts
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants