-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (137 loc) · 6.79 KB
/
Copy pathclaude-wake.yml
File metadata and controls
148 lines (137 loc) · 6.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Wake workflow for Sigma at home (cn-sigma).
#
# Trigger: opening an issue whose title contains "claude-wake", and four
# scheduled crons at :12 :27 :42 :57 (staggered against cnos's :08 :23
# :38 :53 so the two wakes don't race the channel and no two bodies
# fire the same minute — combined ~7.5 min effective cadence at the
# channel level).
#
# Authority: CLAUDE_CODE_OAUTH_TOKEN (operator's Claude Pro/Max
# subscription token, generated via `claude setup-token`, stored as a
# repo secret). Same value the operator uses at cnos.
#
# Substrate: anthropics/claude-code-action@v1 — auth path verified
# end-to-end in cnos#435..#438; OIDC permission + token format both
# pinned in cnos commit a42b3d35 and round-4 green (cnos#438).
#
# Composition: "Activate and attach as <agent-home-url>" — invokes the
# two peer skills in cnos.core/skills/agent/{activate,attach}/SKILL.md.
# At cn-sigma's body, PWD origin matches the prompt URL → attach skill
# detects mode = home. Home procedure iterates over each registered
# activation in .cn-sigma/state/activations.md (currently cnos, bumpt), walks
# each foreign log from last_read_foreign_log to hub HEAD, writes one
# per-activation thread entry, and advances each cursor.
name: claude-wake
on:
issues:
types: [opened]
schedule:
# Four independently-scheduled hourly crons. Each cron line is
# scheduled separately by GH; partial slot drops don't open a full
# hour-long gap. Combined effect ~4 wakes/hour expected; with even
# 75% drop rate we still get ~1 wake/hour guaranteed. Minutes chosen
# complementary to cnos (:08/:23/:38/:53) — no two bodies fire the
# same minute, channel race-free, ~7.5 min effective cadence at the
# channel level. Per cnos directive 2026-06-02T21:57Z; RCA at
# 2026-06-02T20:35Z (off-peak avoids :00/:30 congestion).
- cron: '12 * * * *'
- cron: '27 * * * *'
- cron: '42 * * * *'
- cron: '57 * * * *'
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
# Serialize wakes — never run two in parallel. Concurrent wakes would
# race on the writer-surfaces (.cn-sigma/threads/activations/{name}/) and
# .cn-sigma/state/activations.md cursor advances, producing duplicate
# entries or push conflicts. cancel-in-progress: false queues new
# triggers behind any in-flight wake.
concurrency:
group: claude-wake
cancel-in-progress: false
jobs:
wake:
if: ${{ github.event_name == 'schedule' || contains(github.event.issue.title, 'claude-wake') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
show_full_output: true
bot_name: "sigma@cn-sigma.cnos"
bot_id: "41898282"
settings: |
{
"permissions": {
"allow": ["Read", "Write", "Edit", "MultiEdit", "Glob", "Grep", "Bash"]
}
}
prompt: |
Execute the activate + attach skills (cnos.core/skills/agent/{activate,attach}/SKILL.md) for hub https://github.com/usurobor/cn-sigma.
Required actions (do not skip even if cursors appear current):
1. Read .cn-sigma/state/activations.md.
2. For EACH registered activation (cnos, bumpt): fetch its foreign log at <hub>:.cn-sigma/logs/, walk commits from last_read_foreign_log to HEAD, append a per-activation thread entry at .cn-sigma/threads/activations/<name>/YYYYMMDD.md summarizing new commits, and update last_read_foreign_log in activations.md.
3. Commit + push all changes (per-activation entries + activations.md cursor updates) to main.
4. If a foreign-log HEAD equals last_read_foreign_log (no new commits), still append a heartbeat entry with class: heartbeat and cursor: holds.
Do not exit early. The walk is the work.
# Walk per-activation home channels for substantive events and post
# to Telegram via notify-telegram.sh. Runs AFTER Sigma's
# claude-code-action step (which wrote/committed today's channel
# entries). Cursor is per-activation in notification-cursors.yaml;
# only events newer than the cursor are emitted. Scans all sorted
# channel files (cross-day retry).
#
# Sync FIRST and only notify if sync succeeded — external POSTs
# must reflect current home channel state.
- name: Notify (wake-walker → Telegram)
if: always()
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
run: |
if git pull --rebase origin main; then
.cn-sigma/scripts/notify-walk.sh
else
echo "[notify] sync failed; skipping Telegram notify (external POSTs require synced state)"
fi
# Commit + push notification cursor advances. Separate step so the
# walker stays pure (state mutation only) and persistence is wake-yaml
# responsibility. If cursor push fails, the next wake's pull picks up
# the un-advanced cursor and the same entry posts again — at-least-once
# delivery semantics.
#
# Uses explicit GITHUB_TOKEN auth in the remote URL because checkout's
# default extraheader auth gets rejected on `git push` even though it
# works for `git pull/fetch` (GitHub no longer accepts basic password
# auth for pushes from Actions).
- name: Persist notification cursor
if: always()
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
if git diff --quiet .cn-sigma/state/notification-cursors.yaml; then
echo "[notify-cursor] no advance"
exit 0
fi
git -c user.email="sigma@cn-sigma.cnos" -c user.name="Sigma" \
add .cn-sigma/state/notification-cursors.yaml
git -c user.email="sigma@cn-sigma.cnos" -c user.name="Sigma" \
commit -m "notify-walk: advance notification cursors"
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:main || \
echo "[notify-cursor] push failed; cursor committed locally only; next wake may re-post (at-least-once)"
# Notify the coherer session that the wake completed.
# PR #9 (coherer-watch) is the long-lived notification surface;
# see .cn-sigma/state/coherer-watch.md for mechanism. PR comments fire
# PR-activity webhooks that surface to subscribe_pr_activity in
# the coherer's session.
- name: Notify coherer
if: always()
run: |
git fetch origin main --quiet || true
HEAD_SHA=$(git rev-parse --short=8 origin/main)
LAST_SUBJECT=$(git log -1 --pretty=%s origin/main)
gh pr comment 9 --body "wake @ ${HEAD_SHA}: ${LAST_SUBJECT}"
env:
GH_TOKEN: ${{ github.token }}