Skip to content

Design + PoC: event-driven Slack collector (Socket Mode) to replace archer-slack-review polling #2137

Open

Description

@dezren39

archer-slack-review polls a watermark every 15 min (~100K input/run × ~96 runs/day ≈ 9.6M/day) and usually finds nothing. Replace the polling with an event-driven collector (Drew approved 2026-10-29):

  • A small service using Slack Socket Mode (outbound WebSocket — no public endpoint needed; Cloudflare Worker + Events API is the off-box alternative) appends messages, replies, and reactions from the watched channels to a local store.
  • The review job wakes ONLY when the store has new items (hook/signal), reads just the delta, and acts.
  • Placement per the flake rule (developing-today/code flake if on the laptop; sandbox systemd if on the sandbox). The service is deterministic — no LLM in the collection path.

PoC scope: the #alignment channel end-to-end (collect → store → wake → review). Success: quiet-day agent cost ~0; no missed Aster replies over a 3-day parallel run against the existing poller. Afterwards, generalize the pattern to other watermark polls.

Activity

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    TOP PRIORITY (Drew, 2026-10-29 01:23 CDT): Batch 3 fleet consolidation — pick this up in the next runs, ahead of routine work. Being enqueued to repo-health-code-pilot at top priority now.

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Oct 29, 2026
  4. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  5. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    Premise — verified against live state

    • archer-slack-review is enabled and running on a 15-minute interval (checked live: last run 2026-10-29 01:39 CDT, succeeded; next 01:53) — ~96 agent runs/day.
    • Token check-in Bump build/buck/preludes/buck2-prelude from 3a02ea3 to 370cd4d #5 (2026-10-28 23:56 CDT) measured its per-run floor at ~100K input/run, so ≈ 9.6M input/day, and the channel is quiet most of the day — the "usually finds nothing" claim holds.
    • The mechanism it uses is a watermark pull (puller.py + state DB) — collection and the LLM review are currently the same run, which is exactly the coupling this issue removes.

    Design / decisions

    1. Placement: the sandbox, as a systemd user service. Both the puller store (~/workspace/archer-slack/puller/state/archer-slack.db) and the review job live on the sandbox; the collector is an outbound WebSocket (no public endpoint, no laptop flake involvement). Per this issue's placement rule: sandbox systemd.
    2. No Slack app changes expected for the PoC. The Archer app manifest already has socket_mode_enabled: true and the needed bot events (message.channels/groups/im/mpim, app_mention), and the app-level token already exists in Bitwarden Secrets Manager as slack.archer-app-token (name verified; value not read). If connections:write turns out to be missing, the implementer stops and names the exact app change for Drew rather than widening scopes silently.
    3. Collector shape: a small deterministic Python service beside the puller. It appends messages, thread replies and reactions for the watched channel to the local store, deduplicated by (channel, ts) — so overlap with the watermark puller is safe and the puller remains the backfill safety net for any collector downtime. No LLM in the collection path.
    4. PoC = parallel run, no cadence change. For 3 days the collector runs alongside the untouched 15-min poller; fidelity is compared against the puller's history (zero missed messages; Aster replies checked explicitly — that is the channel's reason to exist). Quiet-day agent cost only reaches ~0 at cutover (signal-triggered review replacing the poll), and cutover is a separate decision gated on the parallel-run report — cadence changes stay Drew-approved, so the PoC itself changes no schedule.
    5. Wake mechanism at cutover (for the report to confirm): the review job fires from the store's new-item signal rather than the clock; the design in ~/workspace/archer-slack/slack-agent-design.md already sketches Socket Mode as the Phase-2 escape hatch from polling, and this implements it.

    Implementation routed: queue task 3176 (priority 10, per Drew's top-priority direction for Batch 3) carries the build + 3-day parallel run + report-back on this issue. Epic #2055 updated with this outcome.

    Labels updated to mirror the queued follow-up.

  6. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Oct 29, 2026
  7. 61 remaining items

  8. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  9. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 23, 2026
  10. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: still working

  11. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: still working

  12. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: progress — S2 picked up
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    S2 in progress: flake package for the collector (interpreter + websockets + a service launcher that fetches slack.archer-app-token by name via the fleet secrets route), a NixOS module (services.archer-slack-collector) declaring the laptop systemd user unit, host wiring for amd, and the Surface 2b registry row — one PR. Deployment in the same pass: the narrow unit-level install on the laptop (no full rebuild — other work is pending on it), which starts the 3-day parallel-run clock; the note recording the live start time, the rollback step, and what a later rebuild must preserve follows once the unit is verified connected.

  13. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: still working

  14. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: S2 landed — collector LIVE on the laptop; 3-day parallel run started
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    PR (unmerged, for Felix's review): #12763 — package (pkgs/fleet/archer-slack/collector/package.nix + launcher.sh, token by name via fleet secrets get), NixOS module (services.archer-slack-collector), amd host wiring, nix build .#archer-slack-collector flake surface, Surface 2b registry row, design-record S2 section.

    Live state (laptop amd-6, verified from the journal just now):

    • Unit archer-slack-collector.service: installed, enabled (default.target.wants), active, NRestarts=0. Started 2026-11-23T01:35:09Z.
    • First WebSocket handshake timed out (transient); the collector's own reconnect landed it: "socket connected", "hello received (connections=1)" at 2026-11-23T01:35:46Z.
    • Store created at /home/user/workspace/archer-slack/puller/state/archer-slack.db (the same store path the review job reads, laptop-local copy); collected_events table present, 0 events — #alignment is quiet, first event arrives with the next channel message.
    • The unit was deliberately NOT restart-tested after the hello, to keep the window clean.

    THE 3-DAY CLOCK: the parallel run runs 2026-11-23T01:35:46Z → ~2026-11-26T01:35:46Z, collector vs the untouched 15-minute puller. S4's fidelity report is due at window end (collector set vs puller seen-set, Aster replies explicit, uptime/restarts from this unit's journal).

    Deployment form, stated plainly: activation was the narrow unit-level install (the module-generated unit file, values from the evaluated amd host config, installed directly at ~/.config/systemd/user/archer-slack-collector.service) ahead of the merge, because a full ./rebuild has other work pending. A later rebuild from a main containing PR #12763 takes over that path (home-manager renames the hand file to *.backup) and must preserve the same unit + the store file (outside home-manager management) + verified-live state — re-check status and journal after that rebuild; a bad comeback breaks the window. Rollback: systemctl --user disable --now archer-slack-collector.service; remove the hand-installed unit file; daemon-reload (store file stays — it is data).

    Evidence: fail-before on main (flake provides no archer-slack-collector attribute); package built under the laptop build lock (/nix/store/in688y1nyp6sk9wr3yawclmwlpy9v6dn-archer-slack-collector-0.1.0; nixpkgs websockets 17.0.1 vs the 17.3 pip pin — same line, live connect is the proof); host config evaluates with the module enabled; collector tests 7/7 in the PR checkout.

    Remaining on #2137: S3 wake gate (owning seat), S4 fidelity report at window end, S5 cutover (earned by S4 only). The reaction gap stands, unchanged and still a workspace-owner action: the app manifest does not subscribe to reaction_added and lacks reactions:read — reaction capture is code-ready but event-starved until the manifest is amended and the app reinstalled. This run measures messages/mentions, which is what the app subscribes to today.

  15. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: done). S2 landed: PR #12763 (package + module + host wiring + registry row, unmerged for review); collector LIVE on the laptop — unit active/enabled, Socket Mode hello 2026-11-23T01:35:46Z, 3-day parallel run running to ~2026-11-26T01:35:46Z. Narrow unit-level install ahead of merge (rebuild pending other work); rollback + rebuild-preservation recorded on the issue. Remaining: S3 wake gate, S4 fidelity report at window end, S5 cutover; reaction manifest gap remains a workspace-owner action.

  16. added a commit that references this issue on Nov 23, 2026
  17. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: S2 merged; parallel run live
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Merged: PR #12763 — the collector packaged + the archer-slack-collector home-manager service + host wiring + the Surface 2b registry row. The unit is LIVE on the laptop ahead of this merge (narrow unit-level install, as the S2 record states): active + enabled, NRestarts=0, Socket Mode connected 2026-11-23T01:35:46Z — that timestamp starts the 3-day parallel run against the untouched 15-min puller (window ends ~2026-11-26T01:35:46Z; S4's fidelity report is due at window end). A later ./rebuild from main takes over the hand-installed unit path (home-manager renames it to *.backup) and must preserve the same unit + the store file; status and journal need a re-check after that rebuild — recorded here so the rebuild checklist carries it.

    Still open on #2137: S3 wake gate (owning seat), S4 fidelity report, S5 cutover (earned by S4 only), and the reaction gap — the app manifest doesn't subscribe to reaction_added and lacks reactions:read; that amendment is a workspace-owner action, and until it lands this run measures the message/mention subscriptions that exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic/fleet-orchestrationReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/highImportant and time-sensitivequeue/blockedQueue or user escalation statesource/creatorFiled by the new-issue-creator jobstatus/blockedQueue or user escalation statestatus:in-reviewtask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions