Bot handoff: the daily check pulls Ken's bot repo; route model updates go to the bot by pull request
CI / test (pull_request) Successful in 39s
CI / test (pull_request) Successful in 39s
- update-sources: download DragonKind/DragonKind (read with ATLAS_BOT_TOKEN, or DRAGONKIND_TOKEN if set) and import it as the bot source. Needs DK_ACCOUNT_SALT (the same salt as earlier imports, so accounts keep their keys); without it the bot source is skipped as before. - The bot load keeps one file, data/bot/trajectories-bot.jsonl: the bot's repo holds every account's full history, so each import is merged by attempt id (attempts already published stay; older per-import files are folded in). One copy of each attempt also keeps build-graph.js from counting an attempt twice. - New workflow push-policy: when policy.json, solver.js or graph.js change on main, open (or update) a pull request on DragonKind/DragonKind that replaces vendor/threshing-atlas/ with them. Ken merges it. - forge open-pr: --repo/--base for another repository, and reuse the open pull request for the same branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# When the route model changes on main, send it to the bot: open (or update) a pull request on the bot's repo,
|
||||
# DragonKind/DragonKind, that replaces vendor/threshing-atlas/{policy.json,solver.js,graph.js} with this repo's
|
||||
# data/public/policy.json, core/solver.js and core/graph.js. The three always travel together, so the policy and the
|
||||
# solver that reads it never get out of step. Ken reviews and merges it; the running bot reloads the files after a pull.
|
||||
#
|
||||
# Secrets: ATLAS_BOT_TOKEN (repository: read and write, with write access to DragonKind/DragonKind).
|
||||
name: Send the route model to the bot
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- data/public/policy.json
|
||||
- core/solver.js
|
||||
- core/graph.js
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
send:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.ATLAS_BOT_TOKEN }}
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- run: pip install pyyaml
|
||||
- name: Open or update the pull request on the bot's repo
|
||||
env:
|
||||
ATLAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
|
||||
run: |
|
||||
set -e
|
||||
dst="$RUNNER_TEMP/dragonkind"
|
||||
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.https://git.kenschiano.net/.extraheader" \
|
||||
GIT_CONFIG_VALUE_0="AUTHORIZATION: token $ATLAS_BOT_TOKEN"
|
||||
git clone --quiet --depth 1 https://git.kenschiano.net/DragonKind/DragonKind.git "$dst"
|
||||
mkdir -p "$dst/vendor/threshing-atlas"
|
||||
cp data/public/policy.json core/solver.js core/graph.js "$dst/vendor/threshing-atlas/"
|
||||
id=$(python3 -c "import json; print(json.load(open('data/public/policy.json')).get('id', ''))")
|
||||
sha=$(git rev-parse --short HEAD)
|
||||
cd "$dst"
|
||||
if [ -z "$(git status --porcelain -- vendor/threshing-atlas)" ]; then
|
||||
echo "The bot already has route model $id."; exit 0
|
||||
fi
|
||||
git config user.name "Atlas data bot"
|
||||
git config user.email "atlas-bot@noreply.localhost"
|
||||
git checkout -q -b atlas/route-model
|
||||
git add vendor/threshing-atlas
|
||||
git commit -q -m "Threshing Atlas route model $id (atlas $sha)"
|
||||
git push -q --force origin atlas/route-model
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
printf '%s\n' \
|
||||
"The Threshing Atlas route model changed (policy \`$id\`, atlas commit \`$sha\`)." \
|
||||
"" \
|
||||
"This replaces \`vendor/threshing-atlas/\` (policy.json, solver.js, graph.js) together, as \`npm run atlas:sync\` would." \
|
||||
"This pull request is updated in place each time the model changes. After merging, pull on the bot's machine:" \
|
||||
"the running bot reloads the files on its next decision." \
|
||||
"" \
|
||||
"Opened automatically by the Atlas's push-policy workflow." > "$RUNNER_TEMP/body.md"
|
||||
python -m collection forge open-pr --repo DragonKind/DragonKind --base main --head atlas/route-model \
|
||||
--title "Threshing Atlas route model update" --body-file "$RUNNER_TEMP/body.md"
|
||||
@@ -8,6 +8,9 @@
|
||||
# update branch and open the pull request; the built-in token cannot start the CI it needs.
|
||||
# RAW_ARCHIVE_KEY optional: encrypts the private raw store kept in the Actions cache between runs
|
||||
# REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET optional: read the megathreads through the Reddit API
|
||||
# DK_ACCOUNT_SALT the salt that turns bot account names into anonymous keys (keep it the same forever). With it,
|
||||
# the bot's private repo (DragonKind/DragonKind) is downloaded and imported; without it, skipped.
|
||||
# DRAGONKIND_TOKEN optional: a read-only token for the bot's repo (ATLAS_BOT_TOKEN is used otherwise)
|
||||
name: Check sources for new data
|
||||
on:
|
||||
schedule:
|
||||
@@ -41,9 +44,23 @@ jobs:
|
||||
if [ -n "$RAW_ARCHIVE_KEY" ] && [ -f "$f" ]; then
|
||||
openssl enc -d -aes-256-cbc -pbkdf2 -pass env:RAW_ARCHIVE_KEY -in "$f" | tar -xz -C data
|
||||
fi
|
||||
- name: Download the bot's data (DragonKind/DragonKind, private)
|
||||
env:
|
||||
DK_TOKEN: ${{ secrets.DRAGONKIND_TOKEN || secrets.ATLAS_BOT_TOKEN }}
|
||||
DK_ACCOUNT_SALT: ${{ secrets.DK_ACCOUNT_SALT }}
|
||||
run: |
|
||||
if [ -n "$DK_TOKEN" ] && [ -n "$DK_ACCOUNT_SALT" ]; then
|
||||
GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.https://git.kenschiano.net/.extraheader" \
|
||||
GIT_CONFIG_VALUE_0="AUTHORIZATION: token $DK_TOKEN" \
|
||||
git clone --quiet --depth 1 https://git.kenschiano.net/DragonKind/DragonKind.git "$RUNNER_TEMP/dragonkind"
|
||||
echo "DRAGONKIND_BOT_DIR=$RUNNER_TEMP/dragonkind" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "DK_ACCOUNT_SALT is not set: the bot source is skipped"
|
||||
fi
|
||||
- id: check
|
||||
env:
|
||||
ATLAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
|
||||
DK_ACCOUNT_SALT: ${{ secrets.DK_ACCOUNT_SALT }}
|
||||
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
|
||||
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
|
||||
run: python -m collection update --report "$RUNNER_TEMP/report.md"
|
||||
|
||||
Reference in New Issue
Block a user