Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b8abd3509 | ||
|
|
7ebf842c5c | ||
|
|
74699fcd21 | ||
|
|
f8b061c314 | ||
|
|
c5158edb6c | ||
|
|
9ad270b9a4 | ||
|
|
51328c9585 | ||
|
|
aa1ca9e653 | ||
|
|
cb29967e7b | ||
|
|
474fd59759 | ||
|
|
40ee9ffafa | ||
|
|
939b912889 | ||
|
|
83aa17cf8b | ||
|
|
9cdae5642e | ||
|
|
dcf2972f26 | ||
|
|
f96c44d092 | ||
|
|
f537d5f8cd | ||
|
|
c833b651a9 | ||
|
|
062f5332a0 | ||
|
|
d9fe384fd9 | ||
|
|
8a7220f5e9 | ||
|
|
5b9ff6fa47 | ||
|
|
66b22f4833 | ||
|
|
acec5d392d | ||
|
|
59be81c7f6 | ||
|
|
c0ac39b8da | ||
|
|
7b19935a14 | ||
|
|
fa7d0d83c1 | ||
|
|
7542e3b15e | ||
|
|
6412e6d116 | ||
|
|
b1dbe519b0 | ||
|
|
3103f87b71 | ||
|
|
8664e8cd97 | ||
|
|
9e566e7278 | ||
|
|
f02a3b6d02 | ||
|
|
bf6f3512b1 | ||
|
|
00112ae205 | ||
|
|
8001c893bd | ||
|
|
0e25291d47 | ||
|
|
68fb3a7e19 | ||
|
|
541575a073 | ||
|
|
d4d24cb1db | ||
|
|
20cb2fd99d | ||
|
|
4fd6efb7f0 | ||
|
|
9eabc624ee | ||
|
|
01418b7e81 | ||
|
|
cac763a339 | ||
|
|
0dde93e57e | ||
|
|
7435b6efe5 | ||
|
|
796c7a711b | ||
|
|
4ac9fd852f | ||
|
|
06d6293a9d | ||
|
|
0c904fb9ef | ||
|
|
59645969ee | ||
|
|
acacdfdab5 | ||
|
|
2090c41960 | ||
|
|
e5a67b8ff0 | ||
|
|
8e6dfd785f | ||
|
|
b9547b01a8 | ||
|
|
0720e9629c | ||
|
|
bb67bd77f1 | ||
|
|
8ecda341e0 | ||
|
|
dee78a876a | ||
|
|
33ccfb2505 | ||
|
|
0330a65054 | ||
|
|
4eb9c20c0c | ||
|
|
1f4910a651 | ||
|
|
150bfd4605 | ||
|
|
3bf64933b0 | ||
|
|
94d2f98cc0 | ||
|
|
2df2f72fc2 | ||
|
|
8a3ba32c5a | ||
|
|
f34f60f9c7 | ||
|
|
8540c9f7c8 | ||
|
|
3014db85e7 | ||
|
|
aea7c5c9f1 | ||
|
|
c792c552cf | ||
|
|
a71f1e0817 | ||
|
|
76905c8ec6 | ||
|
|
85d8b771f0 | ||
|
|
d31a950daa | ||
|
|
f765e23812 | ||
|
|
d66dca44e0 | ||
|
|
b8f8f9a272 | ||
|
|
e128f82e11 | ||
|
|
daab5732e8 | ||
|
|
eb5703b7dd | ||
|
|
ce5fc3e226 | ||
|
|
c2a649ded4 | ||
|
|
1b0a89ca2e | ||
|
|
1441585e06 | ||
|
|
f3576342b6 | ||
|
|
ede2102c60 | ||
|
|
16d98dd47c | ||
|
|
7aca31b18f | ||
|
|
e97f1fa609 | ||
|
|
62f0baba36 | ||
|
|
40fa6f9d7d | ||
|
|
6ce605d6ea | ||
|
|
feba855326 | ||
|
|
47f75f71a7 | ||
|
|
4e060ce5ef | ||
|
|
e2e24f9d56 | ||
|
|
5aa5c2a6c8 | ||
|
|
41b2daed0c | ||
|
|
e0a79b3990 | ||
|
|
e2d6b75b10 | ||
|
|
b4be999777 | ||
|
|
5c3bf0b642 | ||
|
|
be2b897149 | ||
|
|
f5a39cfb9b | ||
|
|
f5a6fa5b32 | ||
|
|
93ec6d916b | ||
|
|
c36fb29683 | ||
|
|
cac0f43b58 | ||
|
|
805364f201 | ||
|
|
3b2a3a7630 | ||
|
|
bf29d3640e | ||
|
|
de15bffc2f | ||
|
|
1377e7ebf2 | ||
|
|
d53ebbda95 | ||
|
|
b227df3c3f | ||
|
|
a3e0e5c1bb | ||
|
|
116f8a10fb | ||
|
|
116b03534f | ||
|
|
b697a12b89 | ||
|
|
7b64699ff1 | ||
|
|
1598b3cc74 | ||
|
|
212742e880 | ||
|
|
6693e60f6f | ||
|
|
c097e50405 | ||
|
|
ccbc9c7844 | ||
|
|
948a8d34fd | ||
|
|
e078b5c4bc | ||
|
|
4a24c0b31f | ||
|
|
e988d3cc40 | ||
|
|
cd20aeadad | ||
|
|
1bb7ba1248 | ||
|
|
fdafec3d9d | ||
|
|
0fcf792db3 | ||
|
|
9cd52dd9aa | ||
|
|
5290dab199 | ||
|
|
e17c7895e4 | ||
|
|
e4ea2eaabc | ||
|
|
12b9a57404 | ||
|
|
514c6cf61c | ||
|
|
bef0ecea3a | ||
|
|
5bb5d9b660 | ||
|
|
f30405ea2b | ||
|
|
f9efae8a5e | ||
|
|
819cfc655b | ||
|
|
5afe5bcf99 | ||
|
|
0c25b2f4a6 | ||
|
|
252895e01c | ||
|
|
3ea49c7e07 | ||
|
|
66a27bd7ef | ||
|
|
b070ce4715 | ||
|
|
84b581fde6 | ||
|
|
af5e11a734 | ||
|
|
522ced45ff | ||
|
|
79d7f2fa68 | ||
|
|
eb3ee14a0e | ||
|
|
6ed6b28d02 | ||
|
|
2f4e9bbe14 | ||
|
|
3057f054b2 | ||
|
|
a4e7ea8cc3 | ||
|
|
c812192800 | ||
|
|
81121d03b0 | ||
|
|
e5f03587c9 | ||
|
|
c25e70a588 | ||
|
|
b97c79aa0b | ||
|
|
2d2c39f9e5 | ||
|
|
673a5bc2ce | ||
|
|
df5ee243b1 | ||
|
|
71fa670512 | ||
|
|
d91ab1ab0f | ||
|
|
1eb05f0d24 | ||
|
|
a49e939609 | ||
|
|
e76e2fd317 | ||
|
|
2418a81a9e | ||
|
|
c4a441d1c3 | ||
|
|
c5c145f325 | ||
|
|
3683ce9082 | ||
|
|
80dc6ec8d0 | ||
|
|
12d6585586 | ||
|
|
53916b0f96 | ||
|
|
badbbf84bd | ||
|
|
d98352d003 | ||
|
|
542bd88040 | ||
|
|
81384939a2 | ||
|
|
c8ed5619c6 | ||
|
|
3b79155602 | ||
|
|
552ee93a47 | ||
|
|
7bf429b599 | ||
|
|
0792f0ba84 | ||
|
|
02ab747ca9 | ||
|
|
c53a98ee87 | ||
|
|
1e4aa8badc | ||
|
|
1e76c99b48 | ||
|
|
ff9b6c7196 | ||
|
|
7680dc5079 | ||
|
|
d0370ed9f7 | ||
|
|
7e3b3dbd78 | ||
|
|
6b71dc8108 | ||
|
|
307f2fc9e2 | ||
|
|
455de3d799 | ||
|
|
4e74ed37b4 | ||
|
|
7ef58293be | ||
|
|
27c9647a13 | ||
|
|
89541eb3b0 | ||
|
|
3a3a714cc4 | ||
|
|
b107e4452a | ||
|
|
2b514cb526 | ||
|
|
630c30de79 | ||
|
|
a69b3455d3 | ||
|
|
ddf8383784 | ||
|
|
c1bbeba18f | ||
|
|
1f99fb592e | ||
|
|
aae01431b4 | ||
|
|
3c99f69fee | ||
|
|
b7fd13923a | ||
|
|
0a47a95cc3 | ||
|
|
ef8d9af469 | ||
|
|
549f36a1f2 | ||
|
|
187e6e81ee | ||
|
|
e60ad551f0 | ||
|
|
a0617ad437 | ||
|
|
411736fdaa | ||
|
|
bea6567933 | ||
|
|
d6b693a9b2 | ||
|
|
b8bedf4d7b | ||
|
|
5c53dfb91b | ||
|
|
e0cbbc0895 | ||
|
|
40dd546564 | ||
|
|
b89d8cbab2 | ||
|
|
4b62912343 | ||
|
|
8a8c8cf7e9 | ||
|
|
201529414b | ||
|
|
3da1f918a4 | ||
|
|
f8d8e5b1e2 | ||
|
|
826d4849df | ||
|
|
0a18bfe21b | ||
|
|
5976b94fbc |
No files matched your search
+13
-11
@@ -54,15 +54,15 @@
|
||||
# Disabled by default; enable only when an integration needs fresh .beads/issues.jsonl.
|
||||
# Use relative paths under .beads/ for JSONL import/export filenames.
|
||||
export:
|
||||
auto: false
|
||||
path: issues.jsonl
|
||||
interval: 60s
|
||||
# issues.jsonl/interactions.jsonl are .gitignore'd local-only files --
|
||||
# Dolt (synced via sync.remote) is the source of truth. Leave auto off
|
||||
# and git-add off; do not re-track these in git.
|
||||
git-add: false
|
||||
auto: false
|
||||
path: issues.jsonl
|
||||
interval: 60s
|
||||
# issues.jsonl/interactions.jsonl are .gitignore'd local-only files --
|
||||
# Dolt (synced via sync.remote) is the source of truth. Leave auto off
|
||||
# and git-add off; do not re-track these in git.
|
||||
git-add: false
|
||||
import:
|
||||
path: issues.jsonl
|
||||
path: issues.jsonl
|
||||
# Integration settings (access with 'bd config get/set')
|
||||
# Non-secret keys (stored in the database):
|
||||
# - jira.url, jira.project
|
||||
@@ -74,7 +74,9 @@ import:
|
||||
# - github.token → use GITHUB_TOKEN env var instead
|
||||
sync.remote: "git+https://github.com/samcharles93/archie-core.git"
|
||||
dolt:
|
||||
shared-server: false
|
||||
auto-commit: "on"
|
||||
shared-server: false
|
||||
auto-commit: "on"
|
||||
audit:
|
||||
enabled: true
|
||||
enabled: true
|
||||
agent:
|
||||
profile: team-maintainer
|
||||
@@ -30,7 +30,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
gate:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
outputs:
|
||||
archied_version: ${{ steps.release_tag.outputs.archied_version }}
|
||||
steps:
|
||||
@@ -66,29 +66,13 @@ jobs:
|
||||
|
||||
- name: Install quality tools
|
||||
run: |
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(cat .golangci-version)
|
||||
go install mvdan.cc/gofumpt@v0.11.0
|
||||
go install github.com/go-task/task/v3/cmd/task@v3.48.0
|
||||
|
||||
- name: Install protobuf tools
|
||||
run: bash tools/proto.sh install
|
||||
|
||||
# The backup/restore tests shell out to pg_dump/pg_restore against a
|
||||
# postgres:18 testcontainer; the runner's stock client is older and
|
||||
# refuses the server version.
|
||||
- name: Install PostgreSQL 18 client
|
||||
run: |
|
||||
sudo install -d /usr/share/postgresql-common/pgdg
|
||||
sudo curl --fail --silent --show-error --location \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc \
|
||||
--output /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc
|
||||
. /etc/os-release
|
||||
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" \
|
||||
| sudo tee /etc/apt/sources.list.d/pgdg.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends postgresql-client-18
|
||||
echo "/usr/lib/postgresql/18/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Ensure contract baseline ref
|
||||
run: |
|
||||
if ! git show-ref --verify --quiet refs/heads/main; then
|
||||
@@ -101,7 +85,17 @@ jobs:
|
||||
# Extensions run in an unprivileged user and network namespace, which
|
||||
# Ubuntu 24.04 runners forbid through AppArmor by default.
|
||||
- name: Allow unprivileged user namespaces
|
||||
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
run: |
|
||||
if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
|
||||
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
fi
|
||||
unshare --user --map-root-user --net true
|
||||
|
||||
# The gate's uncached `go test ./...` runs the Docker-backed tests that
|
||||
# -short skips, and those start a container from alpine:3. A fresh runner
|
||||
# has no such image, so the suite failed on "No such image: alpine:3".
|
||||
- name: Pull test container images
|
||||
run: docker pull alpine:3
|
||||
|
||||
- name: Quality gate
|
||||
run: |
|
||||
@@ -172,7 +166,7 @@ jobs:
|
||||
|
||||
archied-image:
|
||||
needs: gate
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -267,7 +261,7 @@ jobs:
|
||||
outputs:
|
||||
agent_digest: ${{ steps.agent.outputs.digest }}
|
||||
needs: gate
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -330,7 +324,7 @@ jobs:
|
||||
# the ref that won the race, and skip only when there is genuinely no
|
||||
# archied tag at HEAD.
|
||||
if: needs.gate.outputs.archied_version != ''
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
# Least privilege: the workflow default is contents:read, and only this
|
||||
# job needs to write, to create the Release and attach the zip to it.
|
||||
permissions:
|
||||
@@ -382,7 +376,6 @@ jobs:
|
||||
cp "dist/$cmd" "$name/"
|
||||
done
|
||||
cp deployments/INSTRUCTIONS.md CHANGELOG.md "$name/"
|
||||
cp scripts/archie-update-* "$name/"
|
||||
digest='${{ needs.agent-image.outputs.agent_digest }}'
|
||||
test -n "$digest"
|
||||
jq --arg image "ghcr.io/samcharles93/archie-agent@$digest" '. + {agent_image: $image}' release.json > "$name/release.json"
|
||||
@@ -415,7 +408,8 @@ jobs:
|
||||
# already guarantees it describes this version.
|
||||
- name: Publish GitHub Release with the distribution zip
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# GITHUB_TOKEN cannot write to another repository.
|
||||
GH_TOKEN: ${{ secrets.RELEASES_TOKEN }}
|
||||
run: |
|
||||
set -e
|
||||
tag="v${{ steps.version.outputs.version }}"
|
||||
@@ -441,12 +435,12 @@ jobs:
|
||||
# Idempotent: --clobber replaces the asset and leaves the notes
|
||||
# alone, so a re-run of this job (a retried or superseded deploy)
|
||||
# cannot fail on an existing Release or duplicate the zip.
|
||||
if gh release view "$tag" >/dev/null 2>&1; then
|
||||
gh release upload "$tag" "${{ steps.zip.outputs.name }}.zip" SHA256SUMS --clobber
|
||||
if gh release view "$tag" -R samcharles93/archie-releases >/dev/null 2>&1; then
|
||||
gh release upload "$tag" -R samcharles93/archie-releases "${{ steps.zip.outputs.name }}.zip" SHA256SUMS install.sh --clobber
|
||||
else
|
||||
gh release create "$tag" \
|
||||
gh release create "$tag" -R samcharles93/archie-releases \
|
||||
--title "archied v$version" \
|
||||
--notes-file "$notes" \
|
||||
"${{ steps.zip.outputs.name }}.zip" SHA256SUMS
|
||||
"${{ steps.zip.outputs.name }}.zip" SHA256SUMS install.sh
|
||||
fi
|
||||
echo "published $tag with ${{ steps.zip.outputs.name }}.zip"
|
||||
@@ -14,12 +14,19 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Verify extension namespace support
|
||||
run: |
|
||||
if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
|
||||
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
fi
|
||||
unshare --user --map-root-user --net true
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
@@ -33,28 +40,12 @@ jobs:
|
||||
- name: Install quality tools
|
||||
run: |
|
||||
go install github.com/go-task/task/v3/cmd/task@v3.48.0
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(cat .golangci-version)
|
||||
go install mvdan.cc/gofumpt@v0.11.0
|
||||
bash tools/proto.sh install
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends ripgrep
|
||||
sudo install -d /usr/share/postgresql-common/pgdg
|
||||
sudo curl --fail --silent --show-error --location \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc \
|
||||
--output /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc
|
||||
|
||||
. /etc/os-release
|
||||
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" \
|
||||
| sudo tee /etc/apt/sources.list.d/pgdg.list
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends postgresql-client-18
|
||||
|
||||
echo "/usr/lib/postgresql/18/bin" >> $GITHUB_PATH
|
||||
|
||||
pg_dump --version
|
||||
pg_restore --version
|
||||
|
||||
- name: Ensure contract baseline ref
|
||||
run: |
|
||||
@@ -62,12 +53,7 @@ jobs:
|
||||
git branch main origin/main
|
||||
fi
|
||||
|
||||
# Extensions run in an unprivileged user and network namespace, which
|
||||
# Ubuntu 24.04 runners forbid through AppArmor by default.
|
||||
- name: Allow unprivileged user namespaces
|
||||
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
|
||||
- name: Run definitive gate
|
||||
run: |
|
||||
task check
|
||||
task --concurrency 1 check
|
||||
git diff --exit-code
|
||||
@@ -0,0 +1 @@
|
||||
v2.14.0
|
||||
+141
@@ -5,6 +5,147 @@ release's per-component sections are labelled beneath its heading.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.55.0] - 2026-10-16
|
||||
|
||||
### archied
|
||||
|
||||
- Personas are gone: the Personas settings page, the chat Personality selector and `/personality`. A selected persona never changed what the model was told; SOUL (Settings → SOUL) is the one place to set Archie's identity and style. Stored persona settings are deleted on upgrade.
|
||||
- The shipped SOUL describes Archie as the assistant for an event-driven automation system rather than a coding assistant. A SOUL you have saved is kept as it is.
|
||||
|
||||
## [1.54.3] - 2026-10-16
|
||||
|
||||
### archied
|
||||
|
||||
- Chat can help write a workflow: it reads your workflows and the step catalog, writes a definition, and checks it the same way saving does, fixing what the check reports. It does not save; paste the YAML it gives you into the editor's YAML view and save there.
|
||||
|
||||
## [1.54.2] - 2026-10-16
|
||||
|
||||
### archied
|
||||
|
||||
- Tool calls from Gemini models (Interactions API) receive their arguments intact. Any tool that takes arguments, such as `dashboard_navigate` in chat, failed with "invalid character '{' after top-level value".
|
||||
|
||||
### archie-agent
|
||||
|
||||
- Agent steps on Gemini models (Interactions API) pass tools their arguments intact instead of failing to decode them.
|
||||
|
||||
## [1.54.1] - 2026-10-16
|
||||
|
||||
### archied
|
||||
|
||||
- Update checks, `archied update install` and `install.sh` find releases at `github.com/samcharles93/archie-releases`, so a host can update again. A host on 1.54.0 or earlier still looks in the old place and has to be upgraded to 1.54.1 by hand once.
|
||||
|
||||
## [1.54.0] - 2026-10-16
|
||||
|
||||
**Upgrade note:** services now authenticate each other with TLS certificates from your own CA instead of shared tokens. Before upgrading a host whose services listen on anything but loopback (any host running agent containers), issue a certificate per service (`archied`, `archie-gateway`, `archie-messaging`, `archie-state-store`, `archie-ui`, each with its name as the DNS SAN and both server and client auth), add `[tls] ca_file` and `cert_dir` to `config.toml`, and remove every `target_token`, the `*_TOKEN` service variables and the `--token`/`--*-token` flags, including archie-ui's `-token` and `-token-file`. A unit that still passes a removed flag fails to start. See `config.example.toml`.
|
||||
|
||||
### archied
|
||||
|
||||
- Services authenticate each other with mutual TLS. Each process presents `<cert_dir>/<service>.pem`, peers must chain to `ca_file`, and a caller is identified by its certificate rather than by what it claims. Renewed certificates are picked up without a restart. Without `[tls]`, services listen on and dial loopback only. The harness setup terminal requires `[tls]`.
|
||||
- Every gRPC service caps the streams a connection holds, times out stalled handshakes, releases a dead client's streams, and drains for at most 10 seconds on shutdown. Messaging exits when its listener fails instead of staying up without delivering.
|
||||
- The dashboard has user accounts. First run opens browser setup for the organisation, workspace and first administrator; people then sign in with a password, a passkey or your identity provider, and account administration lives under Access. The shared dashboard token is gone; reach the dashboard remotely through an HTTPS reverse proxy.
|
||||
- `archied update install` updates a host in one transaction: it verifies the release, stages every binary, pulls the agent image by digest and backs up the database, then restarts the services in order and rolls everything back if archied is not healthy for two minutes.
|
||||
- Each workflow runs as the identity it declares, checked on every attempt along with the identity that started it. A workflow that declares none is refused, a called workflow runs as its caller's declared identity, and shipped workflows run as the instance root.
|
||||
- Test-run a workflow draft before saving it, with forge and push writes suppressed and recorded per step. The History tab lists a workflow's revisions, diffs them as YAML and on the canvas, restores one into the editor, and shows which revision each run used.
|
||||
- Start a task from the dashboard. The dashboard home shows activity and setup, and a running task has a read-only Sandbox tab that follows its container.
|
||||
- The topbar's Jump to is a command palette, settings lists open as accordions that wait for a new item to be saved, and history restores land as a draft applied from the save bar.
|
||||
- Labels, hints, alerts and empty states say what is wrong and what to do, without tutorial or marketing prose.
|
||||
- Org isolation is tighter: harness secrets, identity writes, principals, playbook dispatch and model selections in chat stay in the caller's org, instance settings are written by the system org only, and creating a source or reloading a channel is authorized against the target.
|
||||
- Binding dispatch claims its capture and enqueues the task atomically, so a capture cannot start two runs, and the run-time workflow check sees the binding event's signature and address.
|
||||
- Service-unhealthy alerts count their grace from the last report and also cover a service that went silent, and a restart no longer clears an alert still inside its grace. An invalid stored access policy raises an alert until it validates.
|
||||
- A failed cancel of a called workflow no longer leaves the caller running, retention spares captures still waiting to be dispatched, and EDA playbooks load and report at start instead of on first dispatch.
|
||||
- Chat model selection works again for provider models.
|
||||
|
||||
### archie-agent
|
||||
|
||||
- Each run acts as its workflow's declared identity.
|
||||
- A task snapshot carries only the model limits its aliases resolve to.
|
||||
- A build step's "no changes" result comes from its writable stages and clears once a commit lands.
|
||||
- Test runs suppress forge and push writes and record what they would have done.
|
||||
- The default persona is a reporting-focused identity prompt, without the one-question limit in chat.
|
||||
|
||||
## [1.53.0] - 2026-10-11
|
||||
|
||||
### archied
|
||||
|
||||
- Every organisation's data is its own. Chats, tasks, events, transitions, steps, tool calls, run statistics, event sources, event types, mappings, bindings and agent memory are read and written in the org that owns them, and a request can no longer write into another org. Rows written before orgs existed move to their owner's org on upgrade.
|
||||
- An instance admin decides what each org may reach: the models it can use, and whether it may register providers under its own credentials. Org Settings gains a Models tab and instance Models gains Org access. The system org is never restricted; another org uses nothing until it is granted.
|
||||
- Models are addressed by alias. Aliases replace model roles, one resolver serves every purpose (agent steps, implement, PR review, MCP sampling, chat, embedding, transcription), and an unknown alias fails instead of falling back to a default. The step editor and the chat picker offer aliases, and a workflow naming one that does not exist is refused when saved.
|
||||
- Chat sessions belong to one org; a chat resolves its models in the caller's org and is billed to it, and a task run from chat posts its outcome back to that chat.
|
||||
- Add a member by provider subject, or by email as a placeholder that the first sign-in the provider vouches for claims.
|
||||
- The workflow canvas authors parallel branches as lanes, adds a switch step that runs the case matching a reference, and edits a call's interface. A step shows its role, its number and its run trace.
|
||||
- The workflows list shows each workflow's running count and latest run result, the canvas reveals its data-edge handles on hover, and restoring a version asks for confirmation.
|
||||
- Store packages can auto-update: a package given the policy is moved to the catalogue's newest digest by a State Store ticker. An update asking for more authority than was accepted waits as a pending update with the running version untouched; approving it accepts the new authority, and a rollback restores the previous version with the authority accepted against it.
|
||||
- Model provider keys never enter an agent container: the runtime reaches its providers through the egress proxy, which holds the keys. A task's own credential can no longer replace the workflow definition its run is pinned to, and a package workflow's triggers, tools and forge calls are bounded by the authority accepted for the package.
|
||||
- The dashboard warns when it is reachable from off-host over plain HTTP, and the wildcard listen address counts as off-host rather than loopback. Instance health, logs, config and identities, the setup checklist and the skill catalogue are system-org only, and API requests are refused until the access chain has loaded.
|
||||
- `/approve` reaches Telegram; the router served it but nothing published it.
|
||||
- A worktree a killed container left root-owned is taken back by the daemon, and a PR review's benchmark runner works again on configured models and public PRs.
|
||||
- An unserved `/api` path returns 404 instead of the dashboard page, and an input group's select no longer loses clicks to its addon.
|
||||
|
||||
### archie-agent
|
||||
|
||||
- The runtime reaches model providers through the egress proxy, so provider keys stay out of the container.
|
||||
- Agent steps resolve model aliases and their own org's models and credentials, failing on an unknown alias instead of falling back.
|
||||
- A switch step runs the case matching its reference.
|
||||
- A call waiting on another step is reconciled from durable steps, so it resumes after a daemon restart rather than stranding.
|
||||
|
||||
## [1.52.0] - 2026-10-09
|
||||
|
||||
### archied
|
||||
|
||||
- The harness page's setup terminal opens a real session: it starts an ephemeral container from a Kit profile, runs the CLI's own login and captures the OAuth tokens at the provider's token endpoint. Point the dashboard at the daemon with `[services.harness].target` and a `HARNESS_TOKEN` and it stops answering 503; the terminal is created at your browser's size. Takeover of a live task is not in this release.
|
||||
- A credential's token endpoint is refused when the run is not granted that service, instead of proxy-ing the provider's real tokens into the container.
|
||||
- Settings → Profiles, Credential bindings and Playbooks are editable from the dashboard, and curator definitions can be changed and applied without a restart.
|
||||
- Settings say whether each one applies live or needs a restart, show what is consuming resources, and report whether an apply landed.
|
||||
- Status shows each service's dependency checks, the agent workers and the broker.
|
||||
- The Logs page reads recent logs from every service, not just the daemon.
|
||||
- Captures and webhook sources are scoped to the org that owns them: the list, retention and delivery authorization all act in the right org, and a workflow definition resolves in its own org.
|
||||
- Chat settings are attributed to the signed-in user, and Settings → Tokens explains when a personal token cannot be created.
|
||||
- A channel enabled after Archie started works immediately; a channel that fails on its own recovers; a failed channel is no longer reported as enabled, and stored channel settings no longer save duplicate or unnormalized values.
|
||||
- The task table sorts, the command palette no longer scrolls sideways or loses its highlight, unknown routes render a not-found page, and configuration reload failures are shown instead of passing silently.
|
||||
- A scheduled job whose payload names a dangerous command is refused.
|
||||
- A disabled model provider is never served from the ambient API key.
|
||||
- `generate_video` is backed by ai-sdk's MiniMax video provider.
|
||||
- A dashboard token is no longer written to the startup log.
|
||||
|
||||
### archie-agent
|
||||
|
||||
- `workflow.call`: a call is keyed on its declared step path, its key is freed once the callee reaches a terminal state, and a caller waiting on a callee releases its capacity instead of holding it.
|
||||
- `command.run` honours step retry and `on_failure`.
|
||||
- A value passed between steps keeps its declared type, and optional result booleans are enforced only when the workflow declares them.
|
||||
- Capture tools have their results checked against the declared schema.
|
||||
- A single-cycle run waits for its in-flight tasks before exiting, and identity tasks inherit live settings.
|
||||
- Kit containers run Docker's init as PID 1, so orphaned processes are reaped instead of accumulating inside a long task.
|
||||
|
||||
## [1.51.1] - 2026-10-08
|
||||
|
||||
### archied
|
||||
|
||||
- Chat with OpenAI's gpt-6 models (gpt-6-luna and the rest) works with tools; a turn failed with "Function tools with reasoning_effort are not supported".
|
||||
|
||||
## [1.51.0] - 2026-10-08
|
||||
|
||||
### archied
|
||||
|
||||
- A secret engine enabled after Archie started (Bitwarden, for example) now supplies its keys straight away; providers that depended on it no longer stay disabled until a restart.
|
||||
- The dashboard chat has a microphone button: record a voice message and it is transcribed like a Telegram voice note. It shows only when a `transcription` model role is set under Settings → Models.
|
||||
- A file Archie sends in the dashboard chat is a download link for an hour, instead of a note that it can't be delivered.
|
||||
- Typing `/model` or `/personality` on its own in the dashboard chat offers the choices as buttons.
|
||||
|
||||
## [1.50.1] - 2026-10-08
|
||||
|
||||
### archied
|
||||
|
||||
- When an update is rolled back, the log names the health check that failed instead of only "unhealthy".
|
||||
|
||||
## [1.50.0] - 2026-10-08
|
||||
|
||||
### archied
|
||||
|
||||
- Tools that need your approval ask for it again, and Archie can ask you a question or offer choices mid-reply. Since the services were split these never reached Telegram or the dashboard: approval-gated tools failed and questions were never asked.
|
||||
- The dashboard chat shows approvals as Approve / Always this session / Deny, choices as buttons, and questions with a reply field.
|
||||
- `/update` in the dashboard chat lists what's available with Install and Not now.
|
||||
- Settings → Status → Versions installs the update it shows; its Install button sent an empty request.
|
||||
|
||||
## [1.49.4] - 2026-10-07
|
||||
|
||||
### archied
|
||||
|
||||
@@ -11,7 +11,7 @@ agent or tool in an isolated container, and the result lands somewhere for
|
||||
review or action. A repository is an optional input to a workflow, not the point
|
||||
of the product.
|
||||
|
||||
<temporary - this statement must be removed on 2026-10-10"> The product is
|
||||
<temporary - this statement must be removed on 2026-10-20"> The product is
|
||||
unfinished. Many features are half-built, and the codebase carries far more
|
||||
code, binaries, docs and tooling than it delivers. The job right now is to
|
||||
finish features and shrink the codebase, not to extend it. </temporary>
|
||||
@@ -27,6 +27,20 @@ When sources disagree, the higher one wins:
|
||||
5. Everything else (memories, comments, old docs) is a hint. Verify it against
|
||||
the code before acting on it.
|
||||
|
||||
## Working with the maintainer
|
||||
|
||||
- **A clear direction is the go-ahead.** Do it in the same turn. Do not restate
|
||||
the plan, offer options, or ask "shall I proceed?". Stop only for destructive
|
||||
or outward-facing actions (deleting data, pushing, touching a live host).
|
||||
- **Post outside the repo only when told.** Chat, tickets and any external
|
||||
service get a message only on the maintainer's instruction.
|
||||
- **Report, don't narrate.** Final replies say what changed, what was verified,
|
||||
and anything blocked, in a few lines. No preamble, no recap of the request, no
|
||||
closing offers of more help. Leave out what the maintainer can see or infer:
|
||||
a clean tree, unpushed commits, a passing gate (commits imply it), and steps
|
||||
skipped that the task never asked for. Name a skipped step only when the
|
||||
task required it.
|
||||
|
||||
## How to decide
|
||||
|
||||
- **Broken beats new.** A bug that blocks work gets fixed now, with the smallest
|
||||
@@ -83,7 +97,8 @@ The default for a change is no new test. Write one only when:
|
||||
|
||||
A test that exists must catch a real regression, survive refactoring, run fast,
|
||||
and be cheap to keep. Never test wiring, constants, defaults, struct shapes,
|
||||
fakes, or call order. One table-driven test per behaviour; extend the table
|
||||
fakes, or call order. No test opens a real database or needs Docker; test
|
||||
SQL semantics at the interceptor or domain level with fakes. One table-driven test per behaviour; extend the table
|
||||
instead of adding a second test. Prefer making an invalid state unrepresentable
|
||||
to testing that it is rejected. Test helpers live in `_test.go` files only.
|
||||
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
NOTICE
|
||||
|
||||
This product includes software derived from PR-AF
|
||||
(https://github.com/Agent-Field/pr-af), Copyright AgentField,
|
||||
licensed under the Apache License, Version 2.0.
|
||||
|
||||
Derived portions: internal/domain/workflow/prreview -- the unified diff
|
||||
parser, change clustering, blast radius, evidence extraction, scoring,
|
||||
deduplication, line mapping and review-event selection.
|
||||
|
||||
PR-AF declares the Apache License, Version 2.0 in its pyproject.toml and
|
||||
ships no license file. A copy of the License is available at
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
This product includes software from the Cedar project
|
||||
(https://github.com/cedar-policy/cedar), Copyright Amazon.com, Inc. or its
|
||||
affiliates, licensed under the Apache License, Version 2.0, as implemented by
|
||||
|
||||
@@ -58,8 +58,15 @@ task release:prepare VERSION=1.3.0 # write the section into CHANGELOG.md, un
|
||||
# edit CHANGELOG.md -- generated notes are a starting point, not the release
|
||||
task release VERSION=1.3.0 # commit + annotated tag
|
||||
git push --atomic origin main v1.3.0 # both refs or neither
|
||||
task release:publish VERSION=1.3.0 # images to GHCR, zip to archie-releases
|
||||
```
|
||||
|
||||
The source repository is private, so releases are published to the public
|
||||
`samcharles93/archie-releases` repository, where `install.sh` and the
|
||||
updater find them. `release:publish` builds from a clean worktree of the tag
|
||||
and needs `gh` and `docker` logged in with write access to that repository
|
||||
and to GHCR.
|
||||
|
||||
`release:prepare` emits bare commit subjects; they are a starting point. Rewrite
|
||||
them to say what a reader gets, per "What the notes are for" above.
|
||||
|
||||
|
||||
+63
-10
@@ -9,6 +9,35 @@ tasks:
|
||||
cmds:
|
||||
- task --list
|
||||
|
||||
setup:
|
||||
desc: Install the pinned tooling and dependencies a checkout needs
|
||||
cmds:
|
||||
# Report what this task cannot install for you, so a missing Go, Node or
|
||||
# Docker fails here by name rather than somewhere inside the gate.
|
||||
- |
|
||||
set -eu
|
||||
missing=
|
||||
for tool in go task node npm docker; do
|
||||
command -v "$tool" >/dev/null 2>&1 || missing="$missing $tool"
|
||||
done
|
||||
if [ -n "$missing" ]; then
|
||||
echo "warning: not installed (AGENTS.md, Build and gate):$missing" >&2
|
||||
fi
|
||||
# The pin is one file, read here and by .github/workflows, so the linter
|
||||
# running locally and the one running the gate cannot drift apart.
|
||||
- |
|
||||
set -eu
|
||||
want=$(cat {{.ROOT_DIR}}/.golangci-version)
|
||||
have=$(golangci-lint --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true)
|
||||
if [ "$have" = "${want#v}" ]; then
|
||||
echo "golangci-lint $want already installed"
|
||||
else
|
||||
echo "installing golangci-lint $want (have: ${have:-none})"
|
||||
GOBIN="$(go env GOPATH)/bin" go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$want"
|
||||
fi
|
||||
- task: proto:install
|
||||
- task: ui:deps
|
||||
|
||||
fmt:
|
||||
desc: Fix and format Go source with the gate's configured formatters
|
||||
cmds:
|
||||
@@ -96,11 +125,6 @@ tasks:
|
||||
cmds:
|
||||
- golangci-lint run ./...
|
||||
|
||||
lint:playbooks:
|
||||
desc: Validate playbook bindings
|
||||
cmds:
|
||||
- go run ./cmd/archied playbooks lint -dir ./playbooks
|
||||
|
||||
vuln:
|
||||
desc: Scan for known vulnerabilities (requires network access)
|
||||
cmds:
|
||||
@@ -118,7 +142,7 @@ tasks:
|
||||
run: once
|
||||
dir: ui
|
||||
cmds:
|
||||
- npm install --no-audit --no-fund
|
||||
- npm ci --no-audit --no-fund
|
||||
|
||||
ui:
|
||||
desc: Build the dashboard into ui/dist (committed; the Go build embeds it)
|
||||
@@ -146,6 +170,11 @@ tasks:
|
||||
cmds:
|
||||
- bash tools/webhook-send.sh {{.CLI_ARGS}}
|
||||
|
||||
bench:prreview:
|
||||
desc: Run the PR review benchmark on the configured models and write docs/benchmarks/pr-review-*.md (-- -model ALIAS -judge-model REF; --help for flags)
|
||||
cmds:
|
||||
- go run ./cmd/archied prbench {{.CLI_ARGS}}
|
||||
|
||||
dev:
|
||||
desc: Run development services and Vite at http://localhost:5173
|
||||
deps: [dev:daemon, dev:gateway, dev:messaging, dev:state-store, dev:dashboard, dev:ui]
|
||||
@@ -216,6 +245,22 @@ tasks:
|
||||
- npm install --no-audit --no-fund
|
||||
- npm run dev
|
||||
|
||||
e2e:up:
|
||||
desc: Start the local stack without Docker (PostgreSQL 18, services, Vite) and seed it
|
||||
cmds:
|
||||
- bash e2e/stack.sh start
|
||||
- bash e2e/seed.sh
|
||||
|
||||
e2e:down:
|
||||
desc: Stop the local e2e stack
|
||||
cmds:
|
||||
- bash e2e/stack.sh stop
|
||||
|
||||
e2e:check:
|
||||
desc: Run the browser checks against the running e2e stack (-- --record VERSION for release evidence)
|
||||
cmds:
|
||||
- node e2e/run.cjs {{.CLI_ARGS}}
|
||||
|
||||
dev:mobile:
|
||||
desc: Serve the dashboard on your LAN (token-protected) for phone viewing
|
||||
deps:
|
||||
@@ -244,6 +289,7 @@ tasks:
|
||||
-X github.com/samcharles93/archie-core/internal/buildinfo.Version={{.GATEWAY_VERSION}}
|
||||
-X github.com/samcharles93/archie-core/internal/buildinfo.Runtime={{.RUNTIME_VERSION}}
|
||||
sources:
|
||||
- Taskfile.yml
|
||||
- "**/*.go"
|
||||
- go.mod
|
||||
- go.sum
|
||||
@@ -256,11 +302,11 @@ tasks:
|
||||
- "{{.BIN_DIR}}/archie-messaging"
|
||||
- "{{.BIN_DIR}}/archie-agent"
|
||||
cmds:
|
||||
# One flag set for every service, matching scripts/archie-update-install
|
||||
# and the release workflow, so each binary reports the same version.
|
||||
# One flag set for every service, matching the release workflow, so each
|
||||
# binary reports the same version.
|
||||
- for: [archied, archie-gateway, archie-state-store, archie-ui, archie-messaging]
|
||||
cmd: go build -ldflags "{{.SERVICE_LDFLAGS}}" -o {{.BIN_DIR}}/{{.ITEM}} ./cmd/{{.ITEM}}
|
||||
- go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent
|
||||
cmd: go build -trimpath -ldflags "{{.SERVICE_LDFLAGS}}" -o {{.BIN_DIR}}/{{.ITEM}} ./cmd/{{.ITEM}}
|
||||
- go build -trimpath -ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent
|
||||
|
||||
test:
|
||||
desc: Run short Go tests with caching
|
||||
@@ -314,6 +360,13 @@ tasks:
|
||||
requires:
|
||||
vars: [VERSION]
|
||||
|
||||
release:publish:
|
||||
desc: Push the images and publish the pushed tag to the public releases repository (VERSION=1.2.0)
|
||||
cmds:
|
||||
- tools/publish.sh {{.VERSION}}
|
||||
requires:
|
||||
vars: [VERSION]
|
||||
|
||||
clean:
|
||||
desc: Remove build artifacts
|
||||
cmds:
|
||||
|
||||
+7
-4
@@ -21,7 +21,6 @@ steps:
|
||||
- id: plan
|
||||
type: agent.run
|
||||
settings:
|
||||
role: planner
|
||||
read_only: true
|
||||
mission: |
|
||||
Plan this change: {{ task.prompt }}
|
||||
@@ -135,7 +134,7 @@ _runs without a repository._
|
||||
| `protect_tests` | bool | Write-block the repository test files. |
|
||||
| `read_only` | bool | Restrict the agent to read-only tools. |
|
||||
| `result` | mapping | A JSON Schema object the agent must return; later steps read it as steps.<id>.result. |
|
||||
| `role` | text | Which configured model role runs the agent, e.g. builder or planner. Empty means builder. |
|
||||
| `model` | text | The model alias that runs the agent, e.g. default or fast. Empty means default. |
|
||||
|
||||
### `command.run`
|
||||
|
||||
@@ -247,11 +246,15 @@ _runs without a repository._
|
||||
|
||||
| Setting | Type | Meaning |
|
||||
|---|---|---|
|
||||
| `inputs` | mapping | |
|
||||
| `outputs` | mapping | |
|
||||
| `inputs` | mapping | Callee input names mapped to scalar literals or `inputs.<name>` references to caller inputs. |
|
||||
| `outputs` | mapping | Callee output names mapped to `outputs.<name>` references to caller outputs; requires `wait: true`. |
|
||||
| `wait` | bool | Wait for the child run to finish before continuing. |
|
||||
| `workflow` | text | The workflow to start as a child run. |
|
||||
|
||||
The step must declare an `id`: the step's id is the key of the call it starts,
|
||||
so a retry of that call site returns the child already started instead of
|
||||
starting a second one.
|
||||
|
||||
### `workflow.finish`
|
||||
|
||||
_runs without a repository._
|
||||
|
||||
@@ -15,10 +15,22 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/agentworker"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/egress"
|
||||
)
|
||||
|
||||
type workerRunner func(context.Context, agentworker.Settings, *slog.Logger) error
|
||||
|
||||
// runHold blocks until signalled and exits 0. It is the keepalive for a Kit
|
||||
// container that runs no worker: the agent binary is archie's own and is
|
||||
// mounted into every Kit, so the container needs no binary the image may not
|
||||
// ship, and holds no environment of its own.
|
||||
func runHold() int {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
<-ctx.Done()
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
os.Exit(run())
|
||||
}
|
||||
@@ -28,6 +40,9 @@ func run() int {
|
||||
}
|
||||
|
||||
func runCommand(args []string, getenv func(string) string, stderr io.Writer, runWorker workerRunner) int {
|
||||
if len(args) > 0 && args[0] == "hold" {
|
||||
return runHold()
|
||||
}
|
||||
if len(args) > 0 && args[0] == "relay" {
|
||||
return runRelay(args[1:], stderr, agentworker.RunRelay)
|
||||
}
|
||||
@@ -76,6 +91,10 @@ func runCommand(args []string, getenv func(string) string, stderr io.Writer, run
|
||||
NATSToken: natsToken,
|
||||
StateStoreTarget: stateStoreURL,
|
||||
StateStoreToken: stateStoreToken,
|
||||
StateStoreCA: []byte(getenv("STATE_STORE_CA")),
|
||||
ModelProxy: getenv(egress.ModelProxyEnv),
|
||||
ModelProxyHosts: egress.ParseHosts(getenv(egress.ModelProxyHostsEnv)),
|
||||
ModelProxyCA: getenv(egress.ModelProxyCAEnv),
|
||||
}, log); err != nil {
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ func run() int {
|
||||
flag.StringVar(&options.Config, "config", configuration.DefaultConfigPath(), "configuration file or directory")
|
||||
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
|
||||
flag.StringVar(&options.Listen, "listen", "", "gateway gRPC listen address (defaults to [services.gateway].listen, else 127.0.0.1:8585)")
|
||||
flag.StringVar(&options.Token, "token", "", "Bearer [REDACTED] required for a non-loopback listener (defaults to [services.gateway].target_token)")
|
||||
flag.Parse()
|
||||
showVersion()
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
@@ -23,11 +23,8 @@ func run() int {
|
||||
flag.StringVar(&options.Config, "config", configuration.DefaultConfigPath(), "configuration file or directory")
|
||||
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
|
||||
flag.StringVar(&options.Gateway.Target, "gateway-target", "", "archie-gateway gRPC address (defaults to [services.gateway].target, else 127.0.0.1:8585)")
|
||||
flag.StringVar(&options.Gateway.Token, "gateway-token", "", "bearer token presented to archie-gateway")
|
||||
flag.StringVar(&options.StateStore.Target, "state-store-target", "", "archie-state-store gRPC address (defaults to [services.state].target)")
|
||||
flag.StringVar(&options.StateStore.Token, "state-store-token", "", "bearer token presented to archie-state-store")
|
||||
flag.StringVar(&options.Listen, "listen", "", "MessagingService gRPC listen address (defaults to [services.messaging].listen)")
|
||||
flag.StringVar(&options.Token, "token", "", "bearer token required from MessagingService callers on a non-loopback listener")
|
||||
flag.DurationVar(&options.DependencyTimeout, "dependency-timeout", 0, "readiness probe timeout (default 5s)")
|
||||
flag.DurationVar(&options.ShutdownTimeout, "shutdown-timeout", 0, "shutdown timeout (default 5s)")
|
||||
flag.Parse()
|
||||
|
||||
@@ -34,7 +34,6 @@ func run() int {
|
||||
flag.StringVar(&options.Config, "config", configuration.DefaultConfigPath(), "configuration file or directory")
|
||||
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
|
||||
flag.StringVar(&options.Listen, "listen", "", "state store gRPC listen address (defaults to [services.state].listen, else 127.0.0.1:9090)")
|
||||
flag.StringVar(&options.Token, "token", "", "bearer token required for a non-loopback listener (defaults to [services.state].target_token)")
|
||||
flag.StringVar(&options.ReadyAddr, "ready-addr", "", "optional readiness HTTP listen address (e.g. 127.0.0.1:9091)")
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(flag.CommandLine.Output(), "usage: archie-state-store [flags] # serve the State Store gRPC contract\n\noffline recovery: archie-state-store <backup|restore|validate|rollback> -h | access reset -h\n\n")
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// This file enforces the dashboard's process boundary
|
||||
// (docs/prds/external-agent-harness.md, "Session contract", Transport): the
|
||||
// dashboard must not link the container or daemon internals, because only the
|
||||
// daemon owns containers. Go imports are atomic, so a single reference
|
||||
// relinks a runtime, and the boundary holds only while something re-measures
|
||||
// it. archie-core-h3s0 names this check; it was purged with the test suite and
|
||||
// is restored here.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDashboardDoesNotLinkContainerRuntime(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
out, err := exec.CommandContext(ctx, "go", "list", "-deps", ".").Output()
|
||||
if err != nil {
|
||||
t.Fatalf("go list -deps .: %v", err)
|
||||
}
|
||||
linked := map[string]bool{}
|
||||
for line := range strings.SplitSeq(strings.TrimSpace(string(out)), "\n") {
|
||||
linked[line] = true
|
||||
}
|
||||
for _, pkg := range []string{
|
||||
"github.com/samcharles93/archie-core/internal/container",
|
||||
"github.com/samcharles93/archie-core/internal/app/archied",
|
||||
"github.com/samcharles93/archie-core/internal/agentexec",
|
||||
} {
|
||||
t.Run(pkg, func(t *testing.T) {
|
||||
if linked[pkg] {
|
||||
t.Errorf("cmd/archie-ui links %s: only the daemon owns containers", pkg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -27,17 +27,14 @@ func run() int {
|
||||
flag.StringVar(&options.Config, "config", configuration.DefaultConfigPath(), "configuration file or directory (only [services.*] targets and [web] are read)")
|
||||
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
|
||||
flag.StringVar(&options.Listen, "listen", "", "dashboard HTTP listen address (defaults to [web].listen, else 127.0.0.1:8484)")
|
||||
flag.StringVar(&options.Token, "token", "", "dashboard token; required for a non-loopback listener")
|
||||
flag.StringVar(&options.TokenFile, "token-file", "", "file holding the dashboard token, minted on first use")
|
||||
flag.StringVar(&options.OidcIssuer, "oidc-issuer", "", "identity provider issuer URL; requests must then carry a token it signed")
|
||||
flag.StringVar(&options.OidcAudience, "oidc-audience", "", "audience (resource identifier) this dashboard accepts tokens for; required with -oidc-issuer")
|
||||
flag.StringVar(&options.OidcClientID, "oidc-client-id", "", "provider client id for browser sign-in; omitted means no sign-in flow")
|
||||
flag.StringVar(&options.OidcClientSecretEnv, "oidc-client-secret-env", "", "name of the environment variable holding the sign-in client secret")
|
||||
flag.StringVar(&options.OidcRedirectURL, "oidc-redirect-url", "", "callback URL registered at the provider (path must be /oauth2/callback)")
|
||||
flag.StringVar(&options.Gateway.Target, "gateway-target", "", "archie-gateway gRPC address (defaults to [services.gateway].target)")
|
||||
flag.StringVar(&options.Gateway.Token, "gateway-token", "", "bearer token presented to archie-gateway")
|
||||
flag.StringVar(&options.State.Target, "state-target", "", "archie-state-store gRPC address (defaults to [services.state].target)")
|
||||
flag.StringVar(&options.State.Token, "state-token", "", "bearer token presented to archie-state-store")
|
||||
flag.StringVar(&options.Harness.Target, "harness-target", "", "archied harness session gRPC address (defaults to [services.harness].target); empty leaves the setup terminal unwired")
|
||||
flag.DurationVar(&options.DependencyTimeout, "dependency-timeout", 0, "per-dependency readiness probe timeout (default 5s)")
|
||||
flag.DurationVar(&options.EventPollInterval, "event-poll-interval", 0, "how often the activity feed polls the State Store for new events (default 1s)")
|
||||
// BoolFunc rather than BoolVar so an unset flag stays distinguishable
|
||||
|
||||
+4
-6
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/archied"
|
||||
"github.com/samcharles93/archie-core/internal/app/archieplaybooks"
|
||||
"github.com/samcharles93/archie-core/internal/app/prbench"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -19,15 +20,12 @@ func main() {
|
||||
if len(args) > 0 && args[0] == "update" {
|
||||
os.Exit(archied.RunUpdate(args[1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
if len(args) > 0 && args[0] == "update-image" {
|
||||
os.Exit(archied.RunUpdateImage(args[1:], os.Stderr))
|
||||
}
|
||||
if len(args) > 0 && args[0] == "update-topology" {
|
||||
os.Exit(archied.RunUpdateTopology(args[1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
if len(args) > 0 && args[0] == "status" {
|
||||
os.Exit(archied.RunStatus(args[1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
if len(args) > 0 && args[0] == "prbench" {
|
||||
os.Exit(prbench.Main(args[1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
if len(args) > 0 && args[0] == "playbooks" {
|
||||
os.Exit(archieplaybooks.Run(args[1:], os.Stderr))
|
||||
}
|
||||
|
||||
+29
-19
@@ -17,9 +17,6 @@
|
||||
# database_url = "postgres://archie:archie@127.0.0.1:5432/archie?sslmode=disable"
|
||||
|
||||
# skills_dir = "~/.local/share/archie/skills" # SKILL.md search path; defaults under work_dir when unset
|
||||
# workflow_routing_file = "~/.local/share/archie/workflow-routing.yaml" # kind->workflow rebinding (bug/feature)
|
||||
# workflow_labels_file = "~/.local/share/archie/workflow-labels.yaml" # arbitrary forge label -> workflow (EDA playbook slice 2)
|
||||
# playbook_dirs = ["~/.local/share/archie/workflows"] # list of dirs of *.yaml binding files, merged with the two above (slice 3); a key bound twice across sources is a load failure
|
||||
|
||||
poll_interval = "60s"
|
||||
label = "archie"
|
||||
@@ -63,7 +60,8 @@ token = { engine = "env", key = "ARCHIE_GITHUB_TOKEN" }
|
||||
# intake per identity is a pending migration, not a setting.
|
||||
|
||||
# [[identities]] runs more than one bot identity from a single daemon, each
|
||||
# with its own forge/dispatch/models/providers/budgets/notify. Intake
|
||||
# with its own forge account and repository membership. Runtime settings
|
||||
# are shared and edited through the control plane. Intake
|
||||
# settings are rejected per identity, and [forge].intake = "webhook"/"both"
|
||||
# is rejected alongside [[identities]]. Minimal shape:
|
||||
# [[identities]]
|
||||
@@ -248,12 +246,14 @@ listen = "127.0.0.1:8484"
|
||||
# [memory]
|
||||
# engine = "builtin" # "builtin" is the only engine implemented so far
|
||||
|
||||
# Notifications for human-in-the-loop moments
|
||||
# (approval requests, gate failures, parked tasks).
|
||||
# Archie POSTs a JSON payload to the webhook
|
||||
# wire it to n8n, email, Slack, or any HTTP endpoint.
|
||||
# Operator alerts (parked tasks, failed runs, unhealthy services, missing
|
||||
# credentials) are listed in the dashboard. Archie also POSTs each raised and
|
||||
# resolved alert as JSON to the webhook: wire it to n8n, email, Slack, or any
|
||||
# HTTP endpoint. Failed deliveries are retried and recorded on the alert.
|
||||
[notify]
|
||||
# webhook = "https://n8n.example.com/webhook/archie"
|
||||
# min_severity = "warning" # info, warning or action: the lowest severity delivered
|
||||
# secret = {engine = "env", key = "ARCHIE_NOTIFY_SECRET"} # signs X-Archie-Signature (HMAC-SHA256)
|
||||
|
||||
[budgets]
|
||||
max_steps = 60
|
||||
@@ -261,6 +261,18 @@ wall_clock = "30m" # one agent call
|
||||
gate_max_failures = 5
|
||||
task_wall_clock = "4h" # a whole task run; keep containers.max_uptime at or above it
|
||||
|
||||
# TLS: every gRPC hop between services uses certificates from your own CA
|
||||
# (step-ca, cert-manager, Vault, openssl). Each process loads
|
||||
# cert_dir/<service>.pem and cert_dir/<service>-key.pem, whose DNS SAN is its
|
||||
# service name: archied, archie-gateway, archie-messaging, archie-state-store,
|
||||
# archie-ui. Every peer must chain to ca_file. Certificates are reloaded when
|
||||
# they change. Without [tls], services may only listen on and dial loopback
|
||||
# addresses, task containers cannot reach the State Store, and the harness
|
||||
# setup terminal is off.
|
||||
# [tls]
|
||||
# ca_file = "/etc/archie/tls/ca.pem"
|
||||
# cert_dir = "/etc/archie/tls"
|
||||
|
||||
# Services selects contract adapters at composition time.
|
||||
[services.gateway]
|
||||
target = "127.0.0.1:8585" # archie-gateway's gRPC address (always remote once set)
|
||||
@@ -269,11 +281,6 @@ target = "127.0.0.1:8585" # archie-gateway's gRPC address (always remot
|
||||
# # to the target above, so a default deployment's client and
|
||||
# # server cannot drift onto different ports. Set it when the
|
||||
# # host already owns that port.
|
||||
# target_token = "..." # Bearer [REDACTED] for a NON-loopback listener. A loopback listener
|
||||
# # (127.0.0.1/::1/localhost) needs no token. A non-loopback
|
||||
# # listener without a token fails closed, as does a
|
||||
# # non-loopback dial without one. The same token is
|
||||
# # presented as GATEWAY_TOKEN by remote consumers.
|
||||
|
||||
[services.state]
|
||||
target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address archied and
|
||||
@@ -285,12 +292,15 @@ target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address arch
|
||||
# # above, so a default deployment's client and server cannot
|
||||
# # drift onto different ports. Move it when a port is already
|
||||
# # taken on the host.
|
||||
# target_token = "..." # bearer token for a NON-loopback target. A loopback target
|
||||
# # (127.0.0.1/::1/localhost) needs no token. A non-loopback
|
||||
# # target without a token fails closed. The same token is injected as STATE_STORE_TOKEN into
|
||||
# # archie-agent containers so the agent authenticates to the
|
||||
# # same remote store. See deployments/README.md for how to
|
||||
# # start archie-state-store.
|
||||
|
||||
# The daemon's harness session contract: the dashboard's setup terminal opens
|
||||
# a PTY into an ephemeral Kit container over it. Both ends are optional and
|
||||
# the dashboard's setup terminal degrades to 503 without them: the daemon
|
||||
# serves the contract only when [tls] is configured, and archie-ui dials it
|
||||
# only when a target is set.
|
||||
# [services.harness]
|
||||
# target = "127.0.0.1:8587" # The address archie-ui dials. Empty leaves the
|
||||
# # setup terminal unwired.
|
||||
|
||||
# NATS is the sole autonomous workflow handoff. mode changes only where the
|
||||
# broker runs; every workflow still runs in a managed task container:
|
||||
|
||||
+32
-33
@@ -55,14 +55,9 @@ as a host binary. Pull it from GHCR: `ghcr.io/samcharles93/archie-agent`.
|
||||
./archied -config ~/.config/archie/config.toml
|
||||
```
|
||||
|
||||
Dashboard reachability comes from `[web].listen` (default
|
||||
`127.0.0.1:8484`, which needs no dashboard token). For a non-loopback
|
||||
bind pass `-listen` with `-token` or `-token-file` to mint and persist
|
||||
one. `archie-ui` reads `GATEWAY_TOKEN` / `STATE_STORE_TOKEN` from its
|
||||
process environment only — it has no secret registry, so when those
|
||||
tokens live in a secret manager, whatever starts `archie-ui` must export
|
||||
them into its environment (the `[services.*].target_token` values in
|
||||
`config.toml` are the other supported source).
|
||||
Open `[web].listen` (default `127.0.0.1:8484`) to configure the organisation,
|
||||
workspace and first administrator account. Remote access requires an HTTPS
|
||||
reverse proxy. Complete setup before exposing the dashboard publicly.
|
||||
|
||||
4. For a persistent, 24/7 deployment instead of a foreground run, follow the
|
||||
systemd user-unit runbook:
|
||||
@@ -90,12 +85,14 @@ an install (or an upgrade across v1.30.0) needs its unit as well -- see
|
||||
|
||||
### Native self-update
|
||||
|
||||
`archie-update-install` downloads the approved release's Linux/amd64 archive
|
||||
and verifies its `SHA256SUMS` entry before executing or installing it. Releases
|
||||
must include `release.json`, all host binaries, and the two updater scripts.
|
||||
Older releases without this contract cannot be installed through the artifact
|
||||
path. `--from-source` (or `ARCHIE_UPDATE_SOURCE_BUILD=1`) explicitly clones and
|
||||
builds the selected release instead.
|
||||
Install on Settings → Status runs `archied update install -version X`, which
|
||||
downloads the release's Linux/amd64 zip and verifies it against `SHA256SUMS`
|
||||
before unpacking it. Every host binary in the zip must report `X`. It then pulls
|
||||
the agent image `release.json` pins by digest, backs up the database to
|
||||
`db.pre-update.dump` in the state directory, stages the new binaries beside the
|
||||
live ones and hands the transaction to `archied update watchdog` in a process of
|
||||
its own (a transient systemd user unit). Nothing that runs changes until the
|
||||
watchdog takes over.
|
||||
|
||||
`archied update check` finds the newest GitHub release with a linux-amd64 zip on
|
||||
the channel chosen under Settings → Status → Updates: stable, next (includes
|
||||
@@ -103,30 +100,32 @@ prereleases) or a pinned version. From a shell it reads
|
||||
`ARCHIE_UPDATE_RELEASE_CHANNEL` and `ARCHIE_UPDATE_PIN`, or `-channel` and `-pin`.
|
||||
The notification destination remains separate from the release channel.
|
||||
|
||||
For scheduled, unattended runs, `archie-update-install --auto` discovers the
|
||||
selected release and refuses if the daemon reports work in flight. It checks
|
||||
again immediately before promotion. A scheduler can set
|
||||
`ARCHIE_UPDATE_RELEASE_CHANNEL` and `ARCHIE_UPDATE_PIN`; nothing schedules updates
|
||||
by default. All services stop through their ordinary graceful shutdown path.
|
||||
|
||||
`release.json` supplies the service order and required config sections to both
|
||||
first-install and self-update. A missing unit or config section produces an
|
||||
ordered migration plan and refuses installation. Apply that plan before retrying.
|
||||
Automatic topology edits are intentionally unsupported.
|
||||
|
||||
The watchdog switches staged executables by rename, restarts services, and
|
||||
requires the candidate daemon's existing readiness registry to remain healthy
|
||||
for 120 seconds. Agent images come from the release manifest by digest. The
|
||||
image switch updates the control-plane policy, preserving other settings;
|
||||
rollback restores the prior image policy with conflict detection. Source builds
|
||||
use the built image's immutable image ID.
|
||||
The watchdog stops the units in reverse `release.json` order, switches the
|
||||
staged executables by rename, switches the control-plane image policy (only the
|
||||
image field, with conflict detection), and restarts the units in order through
|
||||
`systemctl --user`. archied must report the new version and stay healthy for
|
||||
120 seconds. Otherwise the watchdog restores the previous binaries and image
|
||||
policy. Data is not rolled back unless the new release migrated the database:
|
||||
then the previous binaries cannot serve it, so the pre-update backup is restored
|
||||
and the outcome report says that every write since the update began is gone.
|
||||
Without a systemd user manager the watchdog switches binaries and image policy
|
||||
but restarts nothing, and the install reports that the services need a manual
|
||||
restart.
|
||||
|
||||
Transactions live in `${XDG_STATE_HOME:-~/.local/state}/archie/update`, outside
|
||||
the binary directory. `phase`, `environment`, `image.json` (when applicable),
|
||||
and `previous/` describe the transaction. A lock reports the owning process.
|
||||
On daemon boot, an interrupted transaction schedules independent recovery before
|
||||
normal startup. To recover manually, run `transaction/watchdog --recover` from
|
||||
that state directory. A failed recovery keeps the journal for another attempt.
|
||||
the binary directory: `transaction/journal.json`, `transaction/previous/`, and
|
||||
`transaction/archied`, the frozen copy of the archied that wrote the journal. On
|
||||
daemon boot, an interrupted transaction is
|
||||
handed to that frozen watchdog with `-recover` before normal startup: a
|
||||
transaction that never started is discarded, one that was switching or observing
|
||||
is rolled back, and a decided one is finished. To recover manually, run
|
||||
`transaction/archied update watchdog -recover -bin-dir ~/.local/bin` from that
|
||||
state directory. A failed recovery keeps the journal for another attempt.
|
||||
|
||||
Database snapshots remain available for manual recovery. Schema migrations and
|
||||
PostgreSQL data are never automatically reversed.
|
||||
The database backup stays in the state directory after a committed update for
|
||||
manual recovery with `archie-state-store restore`.
|
||||
+18
-13
@@ -52,10 +52,10 @@ PostgreSQL database `database_url` names and serves the `StateStore` gRPC
|
||||
contract. BOTH `archied` and `archie-gateway` dial it via
|
||||
`[services.state].target` and never open the task tables themselves. The templates set
|
||||
`[services.state]` accordingly: a host-only agent reaches a loopback bind
|
||||
(`127.0.0.1:9090`) with no token, while a container-mode agent needs the
|
||||
Docker bridge gateway address plus a matching bearer token (`target_token` /
|
||||
`--token` / `STATE_STORE_TOKEN`), because a container cannot reach the host's
|
||||
loopback.
|
||||
(`127.0.0.1:9090`), while a container-mode agent needs the Docker bridge
|
||||
gateway address, because a container cannot reach the host's loopback. A
|
||||
non-loopback address needs `[tls]` certificates from your own CA; see
|
||||
`config.example.toml`.
|
||||
|
||||
## Running the dashboard
|
||||
|
||||
@@ -69,24 +69,29 @@ default). Start it after the Gateway and the State Store:
|
||||
archie-ui -config ~/.config/archie/config.toml
|
||||
```
|
||||
|
||||
A non-loopback `[web].listen` requires a dashboard token (`-token`, or
|
||||
`-token-file` to mint and persist one); a loopback bind needs none.
|
||||
Open the dashboard to configure the organisation, workspace and first administrator account.
|
||||
Use HTTPS through a reverse proxy for remote access, and complete setup before exposing it publicly.
|
||||
`archied` runs no dashboard listener at all, so webhook capture
|
||||
(`POST /webhooks/capture/{source}`) is received by archie-ui and the
|
||||
binding-dispatch loop in `archied` consumes what arrives from the shared
|
||||
State Store.
|
||||
|
||||
Auth note: unlike `archied`, archie-ui has no secret registry --
|
||||
`GATEWAY_TOKEN`/`STATE_STORE_TOKEN` resolve from its process environment
|
||||
only (or from `[services.*].target_token` in `config.toml`), so whatever
|
||||
starts archie-ui must export those tokens into its environment. See the UI
|
||||
Service unit in `systemd-user-service.md` for the worked example.
|
||||
The dashboard speaks plain HTTP. A non-loopback bind therefore carries the
|
||||
session cookie and the provider token in clear over the network, and
|
||||
archie-ui warns about exactly that at startup. Terminate TLS in front of it
|
||||
(a reverse proxy or the tunnel itself) and set
|
||||
`[web].trust_forwarded_headers = true` to declare the proxy and silence the
|
||||
warning; leaving it off while exposing the port directly is the case the
|
||||
warning names.
|
||||
|
||||
Auth note: archie-ui authenticates to its dependencies with its `[tls]`
|
||||
certificate (`archie-ui.pem`).
|
||||
|
||||
```bash
|
||||
# loopback (host-only agent)
|
||||
archie-state-store -config ~/.config/archie/config.toml -listen 127.0.0.1:9090
|
||||
# or container-mode: bind the bridge gateway with a token
|
||||
archie-state-store -config ~/.config/archie/config.toml -listen 172.17.0.1:9090 -token <token>
|
||||
# or container-mode: bind the bridge gateway ([tls] required)
|
||||
archie-state-store -config ~/.config/archie/config.toml -listen 172.17.0.1:9090
|
||||
```
|
||||
|
||||
## Verifying the daemon
|
||||
|
||||
@@ -26,13 +26,15 @@ target = "127.0.0.1:8585"
|
||||
|
||||
# The State Store gRPC service owns the PostgreSQL task data; archied and
|
||||
# archie-gateway dial it and never open those tables themselves.
|
||||
# This deployment runs the agent in containers, so target is the Docker bridge
|
||||
# gateway (172.17.0.1) the container can reach, with a matching target_token
|
||||
# that archie-state-store validates. Host-only agent: use 127.0.0.1:9090 with
|
||||
# no token.
|
||||
# This deployment runs the agent in containers, so the target is the Docker
|
||||
# bridge gateway (172.17.0.1) the container can reach. A non-loopback address
|
||||
# needs [tls]; see config.example.toml.
|
||||
[services.state]
|
||||
target = "172.17.0.1:9090"
|
||||
target_token = "change-me-state-store-token"
|
||||
|
||||
[tls]
|
||||
ca_file = "/etc/archie/tls/ca.pem"
|
||||
cert_dir = "/etc/archie/tls"
|
||||
|
||||
[forge]
|
||||
type = "gitea"
|
||||
|
||||
@@ -18,13 +18,11 @@ target = "127.0.0.1:8585"
|
||||
|
||||
# The State Store gRPC service owns the PostgreSQL task data; archied and
|
||||
# archie-gateway dial it and never open those tables themselves.
|
||||
# This deployment runs the agent in containers, so target is the Docker bridge
|
||||
# gateway (172.17.0.1) the container can reach, with a matching target_token
|
||||
# that archie-state-store validates. Host-only agent: use 127.0.0.1:9090 with
|
||||
# no token.
|
||||
# This deployment runs the agent in containers, so the target is the Docker
|
||||
# bridge gateway (172.17.0.1) the container can reach. A non-loopback address
|
||||
# needs [tls]; see config.example.toml.
|
||||
[services.state]
|
||||
target = "172.17.0.1:9090"
|
||||
target_token = "change-me-state-store-token"
|
||||
|
||||
[models]
|
||||
triage = "openai/gpt-6-luna"
|
||||
|
||||
@@ -25,16 +25,11 @@ target = "127.0.0.1:8585"
|
||||
|
||||
# The State Store gRPC service owns the PostgreSQL task data. archied and
|
||||
# archie-gateway dial it here and never open those tables themselves.
|
||||
# This deployment runs the
|
||||
# agent in containers, so the target must be the Docker bridge gateway address
|
||||
# (172.17.0.1) that the container can reach, and a non-loopback target requires
|
||||
# a matching target_token that archie-state-store validates -- start it with the
|
||||
# same token (e.g. `archie-state-store ... -listen 172.17.0.1:9090 -token
|
||||
# change-me-state-store-token`). For a host-only agent (no [containers]) use the
|
||||
# loopback target 127.0.0.1:9090 with no token.
|
||||
# This deployment runs the agent in containers, so the target is the Docker
|
||||
# bridge gateway (172.17.0.1) the container can reach. A non-loopback address
|
||||
# needs [tls]; see config.example.toml.
|
||||
[services.state]
|
||||
target = "172.17.0.1:9090"
|
||||
target_token = "change-me-state-store-token"
|
||||
|
||||
[forge]
|
||||
type = "github"
|
||||
|
||||
@@ -20,10 +20,9 @@ The State Store unit is `archie-state-store.service`. It owns the task data in
|
||||
PostgreSQL and serves the `StateStore` gRPC contract. BOTH `archied` and
|
||||
`archie-gateway` dial it via `[services.state].target` (see the `archied`
|
||||
config below) and never open the task tables themselves. A
|
||||
host-only agent uses the loopback bind with no token below; a container-mode
|
||||
agent needs the Docker bridge gateway address plus a bearer token via
|
||||
`--token`/`STATE_STORE_TOKEN` or `[services.state].target_token`, and a
|
||||
non-loopback bind fails closed without one:
|
||||
host-only agent uses the loopback bind below; a container-mode agent needs the
|
||||
Docker bridge gateway address, and a non-loopback bind needs `[tls]` (see
|
||||
`config.example.toml`):
|
||||
|
||||
`install.sh` writes `archie-state-store.service` with that loopback bind.
|
||||
|
||||
@@ -36,14 +35,12 @@ by `archied`, since the v1.30.0 extraction. `archied` starts no gateway for them
|
||||
and logs nothing when one is absent, so a host that updates across v1.30.0
|
||||
without this unit runs on with dead channels and a daemon that looks perfectly
|
||||
healthy. `install.sh` writes this unit on a fresh install;
|
||||
`scripts/archie-update-install` refuses an
|
||||
`archied update install` refuses an
|
||||
update when a host is missing a unit and names what is missing, which now fires
|
||||
for a host that drifted or predates this release rather than the normal path.
|
||||
|
||||
It dials the Gateway for the chat contract and the State Store for the stored
|
||||
channel settings, and reads the same `config.toml`. Like `archie-ui` it resolves
|
||||
`GATEWAY_TOKEN` and `STATE_STORE_TOKEN` from its process environment, hence the
|
||||
`EnvironmentFile`:
|
||||
channel settings, and reads the same `config.toml`, including `[tls]`.
|
||||
|
||||
`install.sh` writes `archie-messaging.service`. Its `After=` and `Wants=`
|
||||
lines only tidy the start sequence: nothing depends on that order, because
|
||||
@@ -53,46 +50,26 @@ each service waits for the peers it needs.
|
||||
|
||||
The dashboard is served by the standalone UI Service, not by `archied`. It reads the same `config.toml`, dials
|
||||
the Gateway and State Store targets already in it, and binds `[web].listen`.
|
||||
A non-loopback bind requires a dashboard token (`-token`, or `-token-file` to
|
||||
mint and persist one);
|
||||
Open the dashboard to configure the organisation, workspace and first administrator account.
|
||||
Complete setup before exposing it publicly; remote access requires an HTTPS reverse proxy.
|
||||
|
||||
**Auth note:** unlike `archied`,
|
||||
`archie-ui` has no secret registry — it resolves `GATEWAY_TOKEN` and
|
||||
`STATE_STORE_TOKEN` from its **process environment only** (or from the
|
||||
`target_token` values in `config.toml`). Whatever starts `archie-ui` is
|
||||
therefore responsible for exporting those tokens into its environment: keep
|
||||
them in `~/.config/archie/env` (loaded by the `EnvironmentFile` line below),
|
||||
not only in a secret manager. A deployment that authenticates `archied`
|
||||
through bws/Vault but exports nothing for `archie-ui` leaves the dashboard
|
||||
unable to dial its dependencies.
|
||||
**Auth note:** `archie-ui` authenticates to the Gateway, State Store and
|
||||
harness with its `[tls]` certificate (`archie-ui.pem`) from `config.toml`.
|
||||
|
||||
For supervision, `GET /healthz` on `[web].listen` is the process's liveness
|
||||
probe (token-free by design); the authenticated readiness surface lives at
|
||||
the dashboard's health endpoint behind the token. A watchdog can curl
|
||||
the dashboard's health endpoint behind account authentication. A watchdog can curl
|
||||
`/healthz` without credentials.
|
||||
|
||||
`install.sh` writes `archie-ui.service`. It has no secret registry of its own,
|
||||
so its token handling is the `EnvironmentFile` note above.
|
||||
|
||||
Concretely, for a deployment whose dependency tokens live outside
|
||||
`config.toml`, `~/.config/archie/env` carries the two names and the unit
|
||||
loads it; the dashboard token itself comes from `-token-file` (there is no
|
||||
environment variable for it):
|
||||
|
||||
```bash
|
||||
# ~/.config/archie/env
|
||||
GATEWAY_TOKEN=... # presented to archie-gateway
|
||||
STATE_STORE_TOKEN=... # presented to archie-state-store
|
||||
```
|
||||
`install.sh` writes `archie-ui.service`. Browser accounts are configured through the dashboard.
|
||||
|
||||
`After=` orders the start, it does not wait for the store to bind. The UI
|
||||
process closes that gap itself: its event pump retries priming with backoff
|
||||
until the State Store answers, so the activity feed goes live once the store
|
||||
is up rather than staying history-only until the next restart.
|
||||
|
||||
For a non-loopback bind, override the installed unit's `ExecStart` with
|
||||
`-token-file %h/.local/share/archie/web-token` (or `-token`) in a drop-in rather
|
||||
than editing the installer's copy in place.
|
||||
For remote access, configure a TLS reverse proxy and the instance public URL in
|
||||
Access → Authentication. Enrol passkeys from Your account on HTTPS or localhost.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+10
-2
@@ -44,10 +44,18 @@ services:
|
||||
# ── NATS JetStream ────────────────────────────────────────────────
|
||||
nats:
|
||||
image: nats:2.14-alpine3.22
|
||||
command: -js -m 8222
|
||||
# The client port is published on every interface (agent containers reach
|
||||
# it over the bridge), so it refuses to start without a token. Set
|
||||
# NATS_TOKEN here and name the same value in [nats] token_env.
|
||||
entrypoint:
|
||||
- sh
|
||||
- -c
|
||||
- '[ -n "$$NATS_TOKEN" ] || { echo "NATS_TOKEN is required" >&2; exit 1; }; exec nats-server -js -m 8222 --auth "$$NATS_TOKEN"'
|
||||
environment:
|
||||
NATS_TOKEN: ${NATS_TOKEN:-}
|
||||
ports:
|
||||
- "4222:4222" # client
|
||||
- "8222:8222" # monitoring (http://localhost:8222)
|
||||
- "127.0.0.1:8222:8222" # monitoring (http://localhost:8222)
|
||||
volumes:
|
||||
- nats_data:/data
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# PR review benchmark
|
||||
|
||||
```
|
||||
task bench:prreview
|
||||
```
|
||||
|
||||
Reviews the 38 runnable Martian pull requests once each at `deep` depth with
|
||||
the production pipeline, judges the posted comments against the golden
|
||||
comments in `internal/app/prbench/martian.json`, and writes
|
||||
`docs/benchmarks/pr-review-<timestamp>.md` (recall per PR, overall recall,
|
||||
precision, models, archie version). Commit that file with the run.
|
||||
|
||||
- Models come from the config at `~/.config/archie/config.toml`: the reviewer
|
||||
and judge both default to its `default` alias. Override with
|
||||
`task bench:prreview -- -model ALIAS_OR_PROVIDER/MODEL -judge-model ALIAS_OR_PROVIDER/MODEL`.
|
||||
Pick a judge other than the reviewer's model for an independent judgement.
|
||||
Aliases set only in the dashboard are not in the file; pass a
|
||||
`provider/model` ref instead.
|
||||
- Pull requests are public, so no credential is needed. `GH_TOKEN` or
|
||||
`GITHUB_TOKEN`, if set, only raises the GitHub API rate limit.
|
||||
- `-problems ID,ID` runs a partial smoke run; its report says it is not the
|
||||
acceptance run. A full run reports PASS when nothing failed and golden
|
||||
micro-recall is at least 0.70.
|
||||
- It is not part of `task test` and posts nothing to any pull request.
|
||||
@@ -73,6 +73,17 @@
|
||||
"/news/archie/1.49.3/": "/news/1.49.3/",
|
||||
"/news/archie/1.49.4/": "/news/1.49.4/",
|
||||
"/news/archie/1.5.0/": "/news/1.5.0/",
|
||||
"/news/archie/1.50.0/": "/news/1.50.0/",
|
||||
"/news/archie/1.50.1/": "/news/1.50.1/",
|
||||
"/news/archie/1.51.0/": "/news/1.51.0/",
|
||||
"/news/archie/1.51.1/": "/news/1.51.1/",
|
||||
"/news/archie/1.52.0/": "/news/1.52.0/",
|
||||
"/news/archie/1.53.0/": "/news/1.53.0/",
|
||||
"/news/archie/1.54.0/": "/news/1.54.0/",
|
||||
"/news/archie/1.54.1/": "/news/1.54.1/",
|
||||
"/news/archie/1.54.2/": "/news/1.54.2/",
|
||||
"/news/archie/1.54.3/": "/news/1.54.3/",
|
||||
"/news/archie/1.55.0/": "/news/1.55.0/",
|
||||
"/news/archie/1.6.0/": "/news/1.6.0/",
|
||||
"/news/archie/1.7.0/": "/news/1.7.0/",
|
||||
"/news/archie/1.8.0/": "/news/1.8.0/",
|
||||
@@ -162,6 +173,17 @@
|
||||
"/news/archied/1.49.3/": "/news/1.49.3/",
|
||||
"/news/archied/1.49.4/": "/news/1.49.4/",
|
||||
"/news/archied/1.5.0/": "/news/1.5.0/",
|
||||
"/news/archied/1.50.0/": "/news/1.50.0/",
|
||||
"/news/archied/1.50.1/": "/news/1.50.1/",
|
||||
"/news/archied/1.51.0/": "/news/1.51.0/",
|
||||
"/news/archied/1.51.1/": "/news/1.51.1/",
|
||||
"/news/archied/1.52.0/": "/news/1.52.0/",
|
||||
"/news/archied/1.53.0/": "/news/1.53.0/",
|
||||
"/news/archied/1.54.0/": "/news/1.54.0/",
|
||||
"/news/archied/1.54.1/": "/news/1.54.1/",
|
||||
"/news/archied/1.54.2/": "/news/1.54.2/",
|
||||
"/news/archied/1.54.3/": "/news/1.54.3/",
|
||||
"/news/archied/1.55.0/": "/news/1.55.0/",
|
||||
"/news/archied/1.6.0/": "/news/1.6.0/",
|
||||
"/news/archied/1.7.0/": "/news/1.7.0/",
|
||||
"/news/archied/1.8.0/": "/news/1.8.0/",
|
||||
|
||||
@@ -1,4 +1,59 @@
|
||||
[
|
||||
{
|
||||
"version": "1.55.0",
|
||||
"date": "2026-10-16",
|
||||
"body": "### archied\n\n- Personas are gone: the Personas settings page, the chat Personality selector and `/personality`. A selected persona never changed what the model was told; SOUL (Settings → SOUL) is the one place to set Archie's identity and style. Stored persona settings are deleted on upgrade.\n- The shipped SOUL describes Archie as the assistant for an event-driven automation system rather than a coding assistant. A SOUL you have saved is kept as it is."
|
||||
},
|
||||
{
|
||||
"version": "1.54.3",
|
||||
"date": "2026-10-16",
|
||||
"body": "### archied\n\n- Chat can help write a workflow: it reads your workflows and the step catalog, writes a definition, and checks it the same way saving does, fixing what the check reports. It does not save; paste the YAML it gives you into the editor's YAML view and save there."
|
||||
},
|
||||
{
|
||||
"version": "1.54.2",
|
||||
"date": "2026-10-16",
|
||||
"body": "### archied\n\n- Tool calls from Gemini models (Interactions API) receive their arguments intact. Any tool that takes arguments, such as `dashboard_navigate` in chat, failed with \"invalid character '{' after top-level value\".\n\n### archie-agent\n\n- Agent steps on Gemini models (Interactions API) pass tools their arguments intact instead of failing to decode them."
|
||||
},
|
||||
{
|
||||
"version": "1.54.1",
|
||||
"date": "2026-10-16",
|
||||
"body": "### archied\n\n- Update checks, `archied update install` and `install.sh` find releases at `github.com/samcharles93/archie-releases`, so a host can update again. A host on 1.54.0 or earlier still looks in the old place and has to be upgraded to 1.54.1 by hand once."
|
||||
},
|
||||
{
|
||||
"version": "1.54.0",
|
||||
"date": "2026-10-16",
|
||||
"body": "**Upgrade note:** services now authenticate each other with TLS certificates from your own CA instead of shared tokens. Before upgrading a host whose services listen on anything but loopback (any host running agent containers), issue a certificate per service (`archied`, `archie-gateway`, `archie-messaging`, `archie-state-store`, `archie-ui`, each with its name as the DNS SAN and both server and client auth), add `[tls] ca_file` and `cert_dir` to `config.toml`, and remove every `target_token`, the `*_TOKEN` service variables and the `--token`/`--*-token` flags, including archie-ui's `-token` and `-token-file`. A unit that still passes a removed flag fails to start. See `config.example.toml`.\n\n### archied\n\n- Services authenticate each other with mutual TLS. Each process presents `<cert_dir>/<service>.pem`, peers must chain to `ca_file`, and a caller is identified by its certificate rather than by what it claims. Renewed certificates are picked up without a restart. Without `[tls]`, services listen on and dial loopback only. The harness setup terminal requires `[tls]`.\n- Every gRPC service caps the streams a connection holds, times out stalled handshakes, releases a dead client's streams, and drains for at most 10 seconds on shutdown. Messaging exits when its listener fails instead of staying up without delivering.\n- The dashboard has user accounts. First run opens browser setup for the organisation, workspace and first administrator; people then sign in with a password, a passkey or your identity provider, and account administration lives under Access. The shared dashboard token is gone; reach the dashboard remotely through an HTTPS reverse proxy.\n- `archied update install` updates a host in one transaction: it verifies the release, stages every binary, pulls the agent image by digest and backs up the database, then restarts the services in order and rolls everything back if archied is not healthy for two minutes.\n- Each workflow runs as the identity it declares, checked on every attempt along with the identity that started it. A workflow that declares none is refused, a called workflow runs as its caller's declared identity, and shipped workflows run as the instance root.\n- Test-run a workflow draft before saving it, with forge and push writes suppressed and recorded per step. The History tab lists a workflow's revisions, diffs them as YAML and on the canvas, restores one into the editor, and shows which revision each run used.\n- Start a task from the dashboard. The dashboard home shows activity and setup, and a running task has a read-only Sandbox tab that follows its container.\n- The topbar's Jump to is a command palette, settings lists open as accordions that wait for a new item to be saved, and history restores land as a draft applied from the save bar.\n- Labels, hints, alerts and empty states say what is wrong and what to do, without tutorial or marketing prose.\n- Org isolation is tighter: harness secrets, identity writes, principals, playbook dispatch and model selections in chat stay in the caller's org, instance settings are written by the system org only, and creating a source or reloading a channel is authorized against the target.\n- Binding dispatch claims its capture and enqueues the task atomically, so a capture cannot start two runs, and the run-time workflow check sees the binding event's signature and address.\n- Service-unhealthy alerts count their grace from the last report and also cover a service that went silent, and a restart no longer clears an alert still inside its grace. An invalid stored access policy raises an alert until it validates.\n- A failed cancel of a called workflow no longer leaves the caller running, retention spares captures still waiting to be dispatched, and EDA playbooks load and report at start instead of on first dispatch.\n- Chat model selection works again for provider models.\n\n### archie-agent\n\n- Each run acts as its workflow's declared identity.\n- A task snapshot carries only the model limits its aliases resolve to.\n- A build step's \"no changes\" result comes from its writable stages and clears once a commit lands.\n- Test runs suppress forge and push writes and record what they would have done.\n- The default persona is a reporting-focused identity prompt, without the one-question limit in chat."
|
||||
},
|
||||
{
|
||||
"version": "1.53.0",
|
||||
"date": "2026-10-11",
|
||||
"body": "### archied\n\n- Every organisation's data is its own. Chats, tasks, events, transitions, steps, tool calls, run statistics, event sources, event types, mappings, bindings and agent memory are read and written in the org that owns them, and a request can no longer write into another org. Rows written before orgs existed move to their owner's org on upgrade.\n- An instance admin decides what each org may reach: the models it can use, and whether it may register providers under its own credentials. Org Settings gains a Models tab and instance Models gains Org access. The system org is never restricted; another org uses nothing until it is granted.\n- Models are addressed by alias. Aliases replace model roles, one resolver serves every purpose (agent steps, implement, PR review, MCP sampling, chat, embedding, transcription), and an unknown alias fails instead of falling back to a default. The step editor and the chat picker offer aliases, and a workflow naming one that does not exist is refused when saved.\n- Chat sessions belong to one org; a chat resolves its models in the caller's org and is billed to it, and a task run from chat posts its outcome back to that chat.\n- Add a member by provider subject, or by email as a placeholder that the first sign-in the provider vouches for claims.\n- The workflow canvas authors parallel branches as lanes, adds a switch step that runs the case matching a reference, and edits a call's interface. A step shows its role, its number and its run trace.\n- The workflows list shows each workflow's running count and latest run result, the canvas reveals its data-edge handles on hover, and restoring a version asks for confirmation.\n- Store packages can auto-update: a package given the policy is moved to the catalogue's newest digest by a State Store ticker. An update asking for more authority than was accepted waits as a pending update with the running version untouched; approving it accepts the new authority, and a rollback restores the previous version with the authority accepted against it.\n- Model provider keys never enter an agent container: the runtime reaches its providers through the egress proxy, which holds the keys. A task's own credential can no longer replace the workflow definition its run is pinned to, and a package workflow's triggers, tools and forge calls are bounded by the authority accepted for the package.\n- The dashboard warns when it is reachable from off-host over plain HTTP, and the wildcard listen address counts as off-host rather than loopback. Instance health, logs, config and identities, the setup checklist and the skill catalogue are system-org only, and API requests are refused until the access chain has loaded.\n- `/approve` reaches Telegram; the router served it but nothing published it.\n- A worktree a killed container left root-owned is taken back by the daemon, and a PR review's benchmark runner works again on configured models and public PRs.\n- An unserved `/api` path returns 404 instead of the dashboard page, and an input group's select no longer loses clicks to its addon.\n\n### archie-agent\n\n- The runtime reaches model providers through the egress proxy, so provider keys stay out of the container.\n- Agent steps resolve model aliases and their own org's models and credentials, failing on an unknown alias instead of falling back.\n- A switch step runs the case matching its reference.\n- A call waiting on another step is reconciled from durable steps, so it resumes after a daemon restart rather than stranding."
|
||||
},
|
||||
{
|
||||
"version": "1.52.0",
|
||||
"date": "2026-10-09",
|
||||
"body": "### archied\n\n- The harness page's setup terminal opens a real session: it starts an ephemeral container from a Kit profile, runs the CLI's own login and captures the OAuth tokens at the provider's token endpoint. Point the dashboard at the daemon with `[services.harness].target` and a `HARNESS_TOKEN` and it stops answering 503; the terminal is created at your browser's size. Takeover of a live task is not in this release.\n- A credential's token endpoint is refused when the run is not granted that service, instead of proxy-ing the provider's real tokens into the container.\n- Settings → Profiles, Credential bindings and Playbooks are editable from the dashboard, and curator definitions can be changed and applied without a restart.\n- Settings say whether each one applies live or needs a restart, show what is consuming resources, and report whether an apply landed.\n- Status shows each service's dependency checks, the agent workers and the broker.\n- The Logs page reads recent logs from every service, not just the daemon.\n- Captures and webhook sources are scoped to the org that owns them: the list, retention and delivery authorization all act in the right org, and a workflow definition resolves in its own org.\n- Chat settings are attributed to the signed-in user, and Settings → Tokens explains when a personal token cannot be created.\n- A channel enabled after Archie started works immediately; a channel that fails on its own recovers; a failed channel is no longer reported as enabled, and stored channel settings no longer save duplicate or unnormalized values.\n- The task table sorts, the command palette no longer scrolls sideways or loses its highlight, unknown routes render a not-found page, and configuration reload failures are shown instead of passing silently.\n- A scheduled job whose payload names a dangerous command is refused.\n- A disabled model provider is never served from the ambient API key.\n- `generate_video` is backed by ai-sdk's MiniMax video provider.\n- A dashboard token is no longer written to the startup log.\n\n### archie-agent\n\n- `workflow.call`: a call is keyed on its declared step path, its key is freed once the callee reaches a terminal state, and a caller waiting on a callee releases its capacity instead of holding it.\n- `command.run` honours step retry and `on_failure`.\n- A value passed between steps keeps its declared type, and optional result booleans are enforced only when the workflow declares them.\n- Capture tools have their results checked against the declared schema.\n- A single-cycle run waits for its in-flight tasks before exiting, and identity tasks inherit live settings.\n- Kit containers run Docker's init as PID 1, so orphaned processes are reaped instead of accumulating inside a long task."
|
||||
},
|
||||
{
|
||||
"version": "1.51.1",
|
||||
"date": "2026-10-08",
|
||||
"body": "### archied\n\n- Chat with OpenAI's gpt-6 models (gpt-6-luna and the rest) works with tools; a turn failed with \"Function tools with reasoning_effort are not supported\"."
|
||||
},
|
||||
{
|
||||
"version": "1.51.0",
|
||||
"date": "2026-10-08",
|
||||
"body": "### archied\n\n- A secret engine enabled after Archie started (Bitwarden, for example) now supplies its keys straight away; providers that depended on it no longer stay disabled until a restart.\n- The dashboard chat has a microphone button: record a voice message and it is transcribed like a Telegram voice note. It shows only when a `transcription` model role is set under Settings → Models.\n- A file Archie sends in the dashboard chat is a download link for an hour, instead of a note that it can't be delivered.\n- Typing `/model` or `/personality` on its own in the dashboard chat offers the choices as buttons."
|
||||
},
|
||||
{
|
||||
"version": "1.50.1",
|
||||
"date": "2026-10-08",
|
||||
"body": "### archied\n\n- When an update is rolled back, the log names the health check that failed instead of only \"unhealthy\"."
|
||||
},
|
||||
{
|
||||
"version": "1.50.0",
|
||||
"date": "2026-10-08",
|
||||
"body": "### archied\n\n- Tools that need your approval ask for it again, and Archie can ask you a question or offer choices mid-reply. Since the services were split these never reached Telegram or the dashboard: approval-gated tools failed and questions were never asked.\n- The dashboard chat shows approvals as Approve / Always this session / Deny, choices as buttons, and questions with a reply field.\n- `/update` in the dashboard chat lists what's available with Install and Not now.\n- Settings → Status → Versions installs the update it shows; its Install button sent an empty request."
|
||||
},
|
||||
{
|
||||
"version": "1.49.4",
|
||||
"date": "2026-10-07",
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
# External agent harnesses
|
||||
|
||||
**Status:** Approved
|
||||
**Scope:** the harness model and, in "Session contract", the duplex session
|
||||
that the setup terminal and the run-scoped live view both use. Code cites
|
||||
this file for both (`ui/src/harness/SetupTerminal.vue`,
|
||||
`internal/infrastructure/postgres/queries/harness_secrets.sql`).
|
||||
|
||||
## Decision
|
||||
|
||||
A workflow stage can run on an external coding-agent CLI instead of the
|
||||
built-in agent loop: Claude Code, Codex, Pi, OMP, GitHub Copilot CLI, or any
|
||||
other CLI packaged as a Docker Sandbox Kit v3. Each authenticates with an API
|
||||
key or the operator's subscription login, and can carry the operator's own
|
||||
skills, plugins, subagents and instructions.
|
||||
|
||||
Two boundaries hold regardless of what the harness does:
|
||||
|
||||
- **The real credential never enters the container.** The container sees
|
||||
sentinel values; archie's egress proxy substitutes the real credential on
|
||||
outbound requests and performs OAuth refresh on the host.
|
||||
- **Archie's workflow guarantees are enforced outside the harness.** Git,
|
||||
protected paths, read-only stages, gates and budgets are checked by archie
|
||||
around the process and against the worktree afterwards.
|
||||
|
||||
## Kits
|
||||
|
||||
A harness is packaged as a Kit v3 image: an OCI image whose
|
||||
`vnd.docker.sandbox.kit.descriptor` manifest annotation declares what the
|
||||
harness needs. Archie reads descriptors with the published
|
||||
`github.com/docker/sandbox-kit-spec/v3/spec` package and does not maintain
|
||||
its own descriptor format. Published Kits run unmodified.
|
||||
|
||||
Archie is a partial Kit runtime. It implements these capability types:
|
||||
|
||||
| Type | Archie behaviour |
|
||||
| ------------------- | ----------------------------------------------------------------------------------------- |
|
||||
| `credential@1` | Proxy-managed only, described below. |
|
||||
| `network-policy@1` | Enforced by the egress proxy. |
|
||||
| `volume@1` | A Docker volume keyed by WorkflowExecution, deleted with it. |
|
||||
| `lifecycle@1` | Install and startup hooks run on container create. |
|
||||
| `agent-sessions@1` | The headless `prompt` and `resume` invocations for the stage. |
|
||||
| `agent-skills@1` | The operator's skills store (`skills_dir`), mounted read-only whatever the Kit asks. |
|
||||
| `agent-context@1` | The workload's profile file beside the workspace, indexing each Kit's guidance. |
|
||||
| `resources@1` | Container CPU and memory limits. |
|
||||
|
||||
Every other type fails closed: a required entry refuses the launch, an
|
||||
optional one is skipped and recorded on the step. `credential@1` with
|
||||
`passthrough: true` and any credential for a forge service are refused.
|
||||
|
||||
The operator's own setup (plugins, subagents, instructions, settings) is a
|
||||
mixin Kit, published with the harness Kit as a Kit set: the set merges their
|
||||
layers into one image. It is versioned image content, rewritten on every
|
||||
create, never state a run can modify.
|
||||
|
||||
## Contract
|
||||
|
||||
A harness run is a second implementation of `agentexec.Runner`. It takes the
|
||||
same `Request` and returns the same `Result`, so workflows, the daemon and
|
||||
the State Store do not know which runner ran a stage.
|
||||
|
||||
`agent-sessions@1` supplies the invocation. Archie supplies, per CLI, an
|
||||
output adapter that translates the CLI's JSON output stream into
|
||||
`ToolCallReporter` calls, `Usage` and a session ID. A CLI with no adapter can
|
||||
run stages with no capture tools, reporting no usage; its token budget falls
|
||||
back to wall clock.
|
||||
|
||||
Workflow definition validation rejects, at load time, a stage whose needs the
|
||||
selected harness cannot meet: capture tools without an adapter, or a gate
|
||||
retry without a `resume` verb.
|
||||
|
||||
## Selection
|
||||
|
||||
A harness is an agent profile. `docs/prds/event-automation.md` defines a
|
||||
profile as the execution environment a workflow selects; a harness profile
|
||||
names one Kit pinned by digest, a workload Kit or a published Kit set, in
|
||||
place of a container image. Archie runs that Kit's image and composes no Kits
|
||||
itself; a bare mixin is refused. Everything else about profiles
|
||||
holds: a workflow names its profile, a stage may name a different one, and a
|
||||
profile holds no secrets.
|
||||
|
||||
`archie-agent` builds the stage's runner from the stage's profile: the
|
||||
ai-sdk agent loop for an image profile, the harness runner for a Kit
|
||||
profile. Image profiles, and every workflow already written against them,
|
||||
are unchanged. A Kit profile named by no workflow is a validation error.
|
||||
|
||||
A stage naming a different profile than its workflow's is a separate run,
|
||||
not a mid-container runner switch: a Kit task runs in one container
|
||||
provisioned for one profile (Container layout), so a stage that needs a
|
||||
different one is its own callee, started the way `workflow.call` already
|
||||
starts one (`docs/prds/event-automation.md` "Workflows call workflows"),
|
||||
with its own agent profile resolved off its own task row. This needs no
|
||||
mechanism beyond `workflow.call` plus per-task profile resolution
|
||||
(`daemon.pinTaskProfile`), both of which already treat every task's
|
||||
profile independently of any caller's -- see
|
||||
`TestWorkflowCallerConformance` (staterpc) for the callee's independent
|
||||
`Workflow` field and `TestWorkflowCallGivesACalleeItsOwnProfile` (daemon)
|
||||
for the Kit-vs-image runner selection that independence produces.
|
||||
|
||||
Profiles are org resources in the State Store, so a Kit profile belongs to
|
||||
one org, is granted to its workspaces like any profile, and applies without
|
||||
a restart.
|
||||
|
||||
## Organisations
|
||||
|
||||
`docs/prds/orgs-and-access.md` is the boundary; a harness adds nothing that
|
||||
crosses it.
|
||||
|
||||
- A Kit profile, its credential bindings and its OAuth tokens belong to one
|
||||
org. No record is shared between orgs.
|
||||
- A harness run is a run like any other: it acts as the workflow's identity,
|
||||
under the run credential issued at dispatch.
|
||||
- The egress proxy injects a credential only when the run credential carries
|
||||
the secret the binding names. A Kit that declares a service the identity is
|
||||
not granted gets no credential: a required one refuses the launch, an
|
||||
optional one is skipped.
|
||||
- A Kit's network policy is what the Kit asks for; the identity's network
|
||||
grants are what the org allows. The proxy enforces the intersection.
|
||||
- Concurrency slots are counted per binding within its org.
|
||||
|
||||
## Credentials
|
||||
|
||||
A credential binding maps a Kit's `credential@1` `service` name to an org
|
||||
secret, which the org grants to identities like any secret. The secret holds
|
||||
one of:
|
||||
|
||||
- **API key:** a value in the org's secret store.
|
||||
- **OAuth:** tokens captured by the setup terminal, stored in the State Store
|
||||
under the at-rest envelope of `binding-secret-encryption.md` with its own
|
||||
domain separator.
|
||||
|
||||
The egress proxy resolves the binding for each request against the run
|
||||
credential. The container gets the Kit's sentinel in the named variable or
|
||||
credential file. OAuth refresh happens at the proxy, which intercepts the
|
||||
Kit's `tokenEndpoint`, so a refreshed token is written to the State Store and
|
||||
never returned to the container.
|
||||
|
||||
Runs sharing an OAuth binding share its subscription's rate limit.
|
||||
`max_concurrent` on the binding (default 1) caps its simultaneous runs. A
|
||||
stage waiting for a slot is `pending`, not `running`.
|
||||
|
||||
## Session contract
|
||||
|
||||
A **session** is a duplex PTY into a Kit container the daemon owns. One
|
||||
concept covers both targets; only the address, the lifetime and the
|
||||
established egress phase differ.
|
||||
|
||||
| | Setup session | Run session (deferred) |
|
||||
| --- | --- | --- |
|
||||
| Address | `{org, profile}` | `{org, task, attempt}` |
|
||||
| Container | ephemeral, from the profile's Kit | the task's running container |
|
||||
| Purpose | run the CLI's own login so the proxy captures the tokens | watch and optionally take over |
|
||||
| Lifetime | bounded by the session TTL; the container is removed on close | bounded by the task |
|
||||
|
||||
- **Transport.** The daemon serves `harness.v1.HarnessService`, a bidi gRPC
|
||||
stream, and the dashboard implements its `HarnessTerminal` interface
|
||||
(`internal/webui`) over that client; the browser's WebSocket route is
|
||||
unchanged. The contract lives on the daemon because the daemon owns
|
||||
containers: the dashboard process must not link `internal/container`,
|
||||
`internal/app/archied` or `internal/agentexec`.
|
||||
- **Authorisation.** Opening a session is the `update` action on the secret,
|
||||
decided by the dashboard's authorizer before the route runs
|
||||
(`internal/webui/authorize.go`). The dashboard then dials the daemon with
|
||||
the harness service token. The daemon does not re-authorise a human; it
|
||||
trusts the asserted `{org, profile}` exactly as the task-action RPC trusts
|
||||
an asserted actor. Because that authority is a shell in a container holding
|
||||
an org's credential, the harness listener requires `HARNESS_TOKEN` even on
|
||||
loopback, unlike the State Store's loopback convention.
|
||||
- **Egress phase.** Token interception is filtered by phase
|
||||
(`oauth.go`'s `rule.runtime == atRun`), and `EnterRuntime` is one-way. A
|
||||
setup session therefore follows a run's lifecycle exactly: install hooks at
|
||||
the install phase, `EnterRuntime` before the shell. A credential whose
|
||||
token endpoint must be captured declares `phase: runtime`; a credential
|
||||
capturing at install phase is captured by the install hooks that run before
|
||||
the switch.
|
||||
- **Credentials.** Capture is gated: the proxy intercepts a token endpoint
|
||||
only for a service the session is granted (`Proxy.granted`). A setup session
|
||||
has no task, so the daemon registers a session grant: its proxy token
|
||||
resolves to `{org, the Kit's declared credential services the org binds}`.
|
||||
That is the intersection the `update`-on-secret authorisation covers. The
|
||||
real token never enters the container: the response is sentinelized and
|
||||
stored as the org's harness secret.
|
||||
- **Container discipline.** The setup container runs a keepalive entrypoint
|
||||
with an empty `Config.Env`; the PTY is an exec as the Kit's harness user
|
||||
with the harness env and nothing inherited from any worker. No worktree is
|
||||
mounted. It is acquired through the container pool, so it carries the
|
||||
`archie-daemon` label, the concurrency cap and the max-uptime reaper; the
|
||||
session TTL is the smaller bound. Closing revokes the egress session,
|
||||
removes the sandbox network and the Kit volumes, then releases the
|
||||
container.
|
||||
- **Kit unavailable.** The daemon serves the contract only when it has a
|
||||
container pool and a Kit launcher; otherwise there is no listener, and a
|
||||
client's refused connection is gRPC's `Unavailable`. The dashboard's
|
||||
existing failure surface is the honest degrade; `/api/harness`'s `terminal`
|
||||
field means "a client is configured", not "the daemon can run a Kit".
|
||||
- **Run target.** `RunTarget{task_id, attempt}` opens a read-only view of a
|
||||
running task's sandbox; it ships as the peek. The daemon resolves the pair
|
||||
itself, so the dashboard never learns a container name: the task store says
|
||||
whether the task is `running` and which attempt is current, and the Kit
|
||||
launcher names the container `kitrun.TaskContainer(task_id, attempt)` (one
|
||||
container per attempt, removed when the run ends; volumes remain task-scoped
|
||||
for retries). A finished or unknown task, a task that is not running, an
|
||||
attempt other than the running one, or a container that is gone is
|
||||
`NotFound` with the reason in the message; an unreachable task store or
|
||||
container engine is `Unavailable`. The view follows the container's stdout
|
||||
and stderr, including the harness output forwarded by the worker, carries
|
||||
no stdin and no exec, and
|
||||
ends when the task's container ends or the client leaves, so it confers no
|
||||
authority over the container. A read-only tail of the existing per-attempt
|
||||
logs was rejected: those refresh only on task state changes and are the
|
||||
daemon's account, not the sandbox's.
|
||||
Mid-stream failures are shown as a reason in the terminal before it closes.
|
||||
- **Authorisation.** The dashboard route `GET /api/tasks/{id}/sandbox` is
|
||||
decided as `read-logs` on the task before the handler runs, so a caller
|
||||
sees a sandbox exactly when they may read that task's log. The daemon
|
||||
checks that the task belongs to the asserted org before following output.
|
||||
- **Grants.** The view takes no grant of its own. The run's egress session
|
||||
(its proxy token, install then `EnterRuntime`) already belongs to the run
|
||||
and is revoked by `Launcher.Release` when the task ends; the view reads
|
||||
after that phase switch and dies with the container.
|
||||
- **Credentials.** The sandbox holds sentinels, never real credentials:
|
||||
API keys are `egress.Sentinel` (`credentials.go`), and an OAuth token set
|
||||
is sentinelised in the response and swapped back by the proxy only on a
|
||||
granted service's resource host in the matching phase (`oauth.go`,
|
||||
`injectOAuth`). The proxy runs in the daemon outside the container, so a
|
||||
shell in the container sees only sentinels.
|
||||
- **Takeover (interactive PTY into a running task) is out of scope for this
|
||||
bead.** It needs the dangerous-command authority (`archie-core-sod1`) to
|
||||
gate it, and that authority is not wired for it: the harness listener has
|
||||
no approval step; `ToolSetOptions.Approval` in `internal/agentexec/modelloop`
|
||||
is never set by a caller, so task runs never build approval-required tools;
|
||||
approvals reach a human only on the chat paths (dashboard ask, Telegram,
|
||||
Gateway). Takeover would also need an audit record naming the actor, task,
|
||||
attempt and open/close times, and revocation tied to task end (the exec is
|
||||
closed with the container). Those follow the setup session's shape
|
||||
(`harnesssession.Session`, `container.ExecPTY`) once the authority exists.
|
||||
- **Audit.** Opening and closing a session and a successful capture are
|
||||
recorded with the asserted org and profile. A run view's open and close are
|
||||
logged with the task and attempt; it reads output only, so it has no
|
||||
takeover record.
|
||||
|
||||
Each session is the only interactive path into a harness container.
|
||||
|
||||
## Egress
|
||||
|
||||
Only Kit profiles run on the egress path. An image profile keeps the network
|
||||
access its identity is granted, because workflows such as a network
|
||||
investigator need raw DNS, ICMP and arbitrary TCP that no HTTP proxy
|
||||
carries.
|
||||
|
||||
- **Sandbox network.** Each Kit run gets its own internal Docker bridge on
|
||||
which the host holds no address. Host services, including those listening
|
||||
on every interface, are unreachable from it by any address.
|
||||
- **Relay.** One relay container, `archie-agent relay`, sits on the sandbox
|
||||
networks under a fixed alias and on the host-reachable network. It
|
||||
forwards three fixed ports, to the proxy, NATS and the State Store, and can
|
||||
reach nothing else. It holds no secrets.
|
||||
- **Proxy.** The proxy runs inside `archied`, listening on the host gateway
|
||||
of the host-reachable network. It terminates TLS with a per-daemon CA
|
||||
installed into the container at create, identifies the container by a
|
||||
per-run proxy token, and applies that run's network policy and credential
|
||||
inject rules. Upstream dials refuse loopback, and refuse internal addresses
|
||||
unless the policy names the exact IP, so an allowed name cannot resolve
|
||||
back into the host.
|
||||
|
||||
## Container layout
|
||||
|
||||
A Kit task runs in one container, from the Kit composition's image, on the
|
||||
task's sandbox network. The worker and every harness invocation share it;
|
||||
they are separated by user, not by container, so a run's cost scales with
|
||||
the run and not with how many agents it fans out to.
|
||||
|
||||
- **Worker.** Archie mounts its own `archie-agent` binary read-only and runs
|
||||
it as the container's entrypoint, as root. It holds the task's NATS and
|
||||
State Store credentials in its own environment and in root-only files,
|
||||
runs the workflow, and serves `archie-agent mcp`. The Kit image's
|
||||
entrypoint is not PID 1.
|
||||
- **Harness.** Every invocation runs as the Kit's user (the image's `User`,
|
||||
default uid 1000) with an explicit environment: the Kit's variables, the
|
||||
proxy environment and the credential sentinels, and nothing inherited from
|
||||
the worker. That user cannot read the worker's environment or files, or
|
||||
trace it. Sibling invocations in one run share the user and the worktree.
|
||||
- **Hooks.** `lifecycle@1` install and startup hooks run as the user each
|
||||
declares, before the worker accepts work.
|
||||
- **Mounts.** The task worktree at the Kit's workspace directory, owned by the
|
||||
Kit's user, and the read-only skills store. Nothing else from the host.
|
||||
- **Network.** The relay forwards three fixed ports on the sandbox network:
|
||||
the egress proxy, NATS and the State Store. The worker reaches NATS and the
|
||||
State Store with its credentials; a harness can open those ports but holds
|
||||
no credential either accepts.
|
||||
- **Volumes.** `volume@1` paths persist for the life of the
|
||||
WorkflowExecution, which covers session resume across gate iterations and
|
||||
retries. They are not shared between executions.
|
||||
|
||||
## Archie tools inside the harness
|
||||
|
||||
Capture tools, which are how a stage returns structured results, are served
|
||||
by `archie-agent mcp`, a stdio MCP server registered through the Kit's MCP
|
||||
configuration or the adapter's flags. It serves the stage's `CaptureTools`
|
||||
and the central tools the agent profile's `AllowTools` permits, never the
|
||||
`workspace` toolset. The runner's `ToolLimits` bound its results; the
|
||||
harness's own built-in tools are outside archie's limits.
|
||||
|
||||
## Enforcement around the harness
|
||||
|
||||
| Property | Enforcement |
|
||||
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Model never runs git | No forge credential can be bound. Archie records `HEAD` and every ref before the run; any change fails the step (`failed`, policy class). The workflow commits the stage's changes. |
|
||||
| Protected paths | A diff touching a `Protection` path fails the step. |
|
||||
| Read-only stage | Any worktree diff fails the step. |
|
||||
| Gate | Archie runs the stage's gate after the harness exits. On failure it resumes the session with the gate output, up to the stage's iteration budget. |
|
||||
| Budget | Archie kills the process on wall-clock timeout, or when streamed usage passes the token budget. |
|
||||
| Cancellation | Cancelling the step kills the process group, then the container. |
|
||||
| Egress | Only the proxy is reachable; the Kit's network policy decides the rest. |
|
||||
|
||||
Harness settings that deny git or protected paths are added where the CLI
|
||||
supports them, to save wasted turns. They are never the enforcement.
|
||||
|
||||
## Execution tree
|
||||
|
||||
A harness run is one `agent` StepExecution. Subagents the harness spawns
|
||||
internally are not recorded as children. Their usage is included in the
|
||||
step's `tokens_used` when the adapter reports it.
|
||||
|
||||
## Agents never hold a harness
|
||||
|
||||
An Agent reaches a harness only by invoking a Workflow whose stage names it.
|
||||
No Agent tool, chat tool or capability exposes a harness, its setup terminal
|
||||
or its credential. The stage boundary is what carries the container, the git
|
||||
and path checks, the gate and the budget; a harness outside a stage has none
|
||||
of them.
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Chat through a harness. The gateway chat loop stays on the built-in
|
||||
runtime.
|
||||
- `network-policy@2` HTTP method and path rules; a Kit requiring it is
|
||||
refused.
|
||||
- Recording the harness's internal subagents as StepExecutions.
|
||||
- Cost in currency.
|
||||
- Choosing a harness automatically per task.
|
||||
|
||||
## Plan
|
||||
|
||||
1. Descriptor resolution with the Kit spec package; capability support
|
||||
table and fail-closed refusal.
|
||||
2. Egress proxy: internal network, per-daemon CA, per-container token,
|
||||
`network-policy@1`.
|
||||
3. `credential@1`: API-key bindings, sentinel rendering, inject rules.
|
||||
4. Harness `Runner`: container create with worktree, volumes, lifecycle
|
||||
hooks and the mounted `archie-agent`; `agent-sessions@1` invocation;
|
||||
worktree checks for git, protected paths and read-only; budget and
|
||||
cancellation.
|
||||
5. Claude Code output adapter; `archie-agent mcp`; gate-and-resume loop.
|
||||
6. Kit profiles, runner selection from the stage's profile, and definition
|
||||
validation.
|
||||
7. OAuth bindings as org secrets: token-endpoint interception, encrypted
|
||||
storage, per-binding concurrency; dashboard setup terminal.
|
||||
8. Output adapters for Codex, Pi, OMP and GitHub Copilot CLI.
|
||||
|
||||
## Verification
|
||||
|
||||
- The same workflow definition completes on `builtin` and on the Claude Code
|
||||
Kit with the same `Result` shape and captures.
|
||||
- After `/login` in the setup terminal, the container's credential file holds
|
||||
only sentinels, the State Store holds the encrypted token, and a task run
|
||||
authenticates.
|
||||
- A real API key or OAuth token never appears in the container environment,
|
||||
filesystem, worktree, task log or event stream.
|
||||
- A request to a host outside the Kit's runtime allow list fails, including a
|
||||
direct connection that bypasses the proxy settings.
|
||||
- A harness instructed to `git commit` fails its step, and the task branch is
|
||||
unchanged.
|
||||
- A harness edit to a protected test file fails the step in a TDD fix stage.
|
||||
- A read-only feasibility stage that writes a file fails.
|
||||
- A file a run writes into a Kit-managed path such as the CLI's settings file
|
||||
is gone on the next execution.
|
||||
- A Kit requiring an unsupported capability is refused at launch with the
|
||||
capability named.
|
||||
- A stage with a failing gate resumes the same session with the gate output,
|
||||
then succeeds or exhausts its iterations.
|
||||
- Two tasks sharing an OAuth binding with `max_concurrent = 1` run one at a
|
||||
time; the second waits as `pending`.
|
||||
- Stopping a run kills the harness process and removes the container.
|
||||
- A harness invocation cannot read the worker's NATS or State Store
|
||||
credential from its environment, its files or `/proc`.
|
||||
- A run fanning out to many agent invocations uses one container.
|
||||
- A Kit profile in org A cannot be selected, and its binding cannot be
|
||||
resolved, by a workflow in org B.
|
||||
- A harness run whose identity is not granted a Kit's required credential is
|
||||
refused at launch; the proxy never injects a secret outside the run
|
||||
credential.
|
||||
- The firewall investigation example runs unchanged on an image profile with
|
||||
direct network access.
|
||||
@@ -0,0 +1,239 @@
|
||||
# User authorization boundaries
|
||||
|
||||
Archie separates authentication (which person or service is calling) from
|
||||
permission to act on a resource. This inventory follows the [OWASP
|
||||
Authentication Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html)
|
||||
and [Authorization Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html),
|
||||
including its guidance on attributes and relationships. It describes concrete
|
||||
enforcement points and their regression tests; it is not a compliance certification.
|
||||
|
||||
## Transport and authority
|
||||
|
||||
The browser uses HTTP/JSON and SSE to the UI service. The UI service calls
|
||||
State Store, Gateway, Messaging and Harness through their gRPC contracts.
|
||||
Only the State Store opens the task/control-plane/account database; Gateway
|
||||
owns conversation storage. Browser HTTP handlers never open either database.
|
||||
|
||||
Instance service credentials are administrative authority. They are not user
|
||||
sessions and must never reach a browser, model, or agent container. A service
|
||||
forwarding a principal preserves attribution and tenant scope; forwarding alone
|
||||
does not mean every internal RPC evaluates Cedar. Most internal RPCs trust the
|
||||
authenticated service and enforce their own resource scope. The public HTTP
|
||||
boundary evaluates Cedar before invoking them. Task credentials have a separate,
|
||||
explicit RPC allowlist and cannot call account or identity administration.
|
||||
|
||||
Local service listeners are trusted process boundaries. Loopback is not a
|
||||
substitute for authentication on a remotely reachable listener. OIDC credentials,
|
||||
local browser sessions, personal API tokens, service credentials, and task grants
|
||||
must remain distinct.
|
||||
|
||||
## Policy and relationship model
|
||||
|
||||
`internal/domain/access` defines actions, resources, principals and memberships.
|
||||
`internal/infrastructure/access` assembles Cedar entities and evaluates the
|
||||
instance → organization → workspace → object chain. A forbid wins; each applicable
|
||||
level must permit the operation. Missing or invalid policy chains fail closed.
|
||||
|
||||
The default policies grant actions through scoped roles. Policies can also
|
||||
restrict a named identity, workspace environment, owner, state, source address,
|
||||
signature, run or step. HTTP task decisions now include the stored initiating identity and task state; binding decisions include the stored binding state. The HTTP source address is the actual connection peer, not an unverified forwarded header. Membership and resource attributes must come from stored
|
||||
records or authenticated context, never a request's assertion about itself.
|
||||
|
||||
Cedar permission is not ownership of another person's private data. Conversation
|
||||
history, passkeys, recovery codes and personal tokens are bound to the person.
|
||||
An organization or instance admin role does not override those relationships.
|
||||
Account creation uses `manage_members` policy rather than a hard-coded admin
|
||||
role. Authenticating through OIDC does not automatically grant membership, link
|
||||
accounts by unverified email, or create an administrator.
|
||||
|
||||
## Enforcement inventory
|
||||
|
||||
| Location | Enforcement | Regression evidence |
|
||||
| --- | --- | --- |
|
||||
| Browser credential gate: `webui/auth.go`, `accounts.go` | Account session or verified provider identity; shared dashboard token is not a person when accounts are enabled. No API data before authentication. | `TestAccountBoundary`, `TestAccountSessionFailureIsClosed` |
|
||||
| Browser policy gate: `webui/authorize.go` | Resolve principal from stored identity; evaluate action against stored org/workspace and resource kind before handler. Missing chain refuses. | `TestHTTPPolicyCannotBeBypassed`, `TestAuthorizeRefusesWithoutAChain`, `TestAuthorizeRecord`, `TestTaskAuthorizationUsesStoredAttributes`, `TestAuthorizeCreateIn` |
|
||||
| Instance-only HTTP surfaces: `webui/instance_only.go`, server route registration | Hide instance-owned configuration and diagnostics from another org; policy still applies first. | `TestInstanceOnlyHidesTheInstanceFromOtherOrgs`, `TestInstanceAdminOrgs` |
|
||||
| First setup: `webui/accounts.go`, `postgres/accounts.go` | Initial organization, workspace, instance URL, admin identity and password commit together. Transaction lock closes bootstrap after first account; later requests require `manage_members`. | Disposable PostgreSQL smoke verification for bootstrap race and rollback; account policy tests below |
|
||||
| Account creation: `webui/accounts.go`, `staterpc/accounts.go`, `postgres/accounts.go` | Cedar `manage_members` at HTTP and RPC; target org is authenticated context. New local accounts cannot request owner role. | `TestAccountManagementUsesPolicy`, `TestAccountBoundary` |
|
||||
| Local passwords and sessions: `identity/password.go`, `postgres/accounts.go` | Argon2id, independent salts, length/common-password checks, generic login refusal, account throttling, session hashes and expiry, revocation on logout/password change/suspension. | `TestPasswordVerification`, `TestAccountBoundary`; disposable PostgreSQL session verification |
|
||||
| Transport and CSRF: `webui/accounts.go`, `api_tasks.go` | Password/account mutations require HTTPS or localhost development, JSON, custom CSRF header and same-origin requests. Forwarded headers require explicit trusted-proxy configuration. | `TestAuthenticationTransport`, existing mutation security tests |
|
||||
| Personal account routes: `webui/accounts.go` | Active signed-in person; principal supplied by server. Password change verifies current password. Sensitive authenticator changes require recent sign-in. No caller-supplied target identity. | `TestAccountBoundary` |
|
||||
| Recovery: `postgres/account_security.go`, `webui/accounts.go` | Fresh authenticated owner generates a hashed, one-use recovery secret. Redemption replaces password and revokes all sessions atomically. No email-existence disclosure. | Disposable PostgreSQL recovery verification |
|
||||
| Passkeys: `postgres/passkeys.go`, `webui/passkeys.go` | Configured RP origin, browser-bound one-use expiring challenge, verified credential signature and user verification. Enrollment/management belong to caller. Credential counters persist under a row lock. | Disposable browser virtual-authenticator verification; task-grant denial tests |
|
||||
| OIDC: `infrastructure/oidc`, `archieui/account_oidc.go`, `webui/auth.go` | Discovery and signed ID token with issuer/client audience/expiry, PKCE, state and nonce. Verified subject resolves to active identity. Browser-local session cannot outlive provider token, and provider credential remains checked. | `TestBrowserFlowVerifiesIDToken`, `TestProviderOutageIsUnavailableThenRecovers`, subject-claim tests; no external provider acceptance implied |
|
||||
| OIDC settings: `webui/accounts.go`, `postgres/authentication.go` | Instance ownership plus policy; recent sign-in for changes. Public URL cannot change while enrolled passkeys would be orphaned. | `TestAccountBoundary`, `TestAuthenticationSettingsRejectUntrustedOrigins` |
|
||||
| Org membership/workspaces/agent assignment: `webui/api_orgs.go`, `staterpc/orgs.go`, `postgres/orgs.go` | Own org or instance-owner relationship, allowed role vocabulary, membership escalation/last-owner guards, tenant-scoped SQL. | `TestOrgRPCsActInTheCallersOrg`, `TestSetMembershipRefusesUnknownRole`, org HTTP tests |
|
||||
| Personal API tokens: `webui/api_personal_tokens.go`, `staterpc/personal_tokens.go`, `postgres/personal_tokens.go` | Token owner comes from principal; store only token hash; revoke only caller's binding. | `TestPersonalTokensWithoutPerson`, `TestPersonalTokenOwner` |
|
||||
| gRPC caller attribution: `rpcidentity/identity.go` | Authenticated service may forward a principal; State Store resolves memberships/org itself. Task grant metadata is stripped. | `TestCallerAttribution` |
|
||||
| Agent/task gRPC: `staterpc/task_grants.go` | Durable task-scoped grant, explicit allowed RPC and target task, no definition-pin replacement, no account RPCs. | `TestTaskCredentialsCannotManageAccounts`, `TestTaskCredentialCannotReplaceItsPin`, `TestRecordUsageAuthority`, `TestWorkerPresenceAuthority` |
|
||||
| Chat HTTP: `webui/api_chat.go` | Server stamps sender and person thread; lists/read/turns/cancel/persona verify session ownership. Browser cannot submit another sender identity. | `TestWebChatOwnership`, `TestWebChatSenderCannotBeSuppliedByBrowser`; HTTP deny matrix |
|
||||
| Chat history, slash commands and model session tools: `gateway/session_store_postgres.go` | Store filters `Get`, `List`, `GetByChannel`; shared read/write guards check person ownership as well as org. A saved session cannot change its conversation source to claim another person's history. Service curation runs without a person principal. | `TestSessionVisibility`; PostgreSQL smoke for history isolation |
|
||||
| Chat questions/approvals: `webui/api_chat_ask.go` | Waiting question is bound to the initiating person, in addition to its unguessable ID. | `TestChatQuestionBelongsToInitiatingPerson` |
|
||||
| Chat downloads: `webui/api_chat_files.go` | Offered file token expires and is bound to the initiating person; requests cannot supply a filesystem path. | `TestChatFileDownload` |
|
||||
| Per-person memory: `archiegateway/chat_identity.go`, gateway memory tools, `sessioncurator` | Verified web sender identity scopes reads/writes. Curator refuses unidentified or mixed participants instead of guessing a person. | Gateway memory and session-curator tests |
|
||||
| Workflow/task actions: `webui/api_tasks.go`, `domain/taskactions`, `staterpc` | Policy and stored workspace before action; domain transition, authority and durable dispatch guards remain in force. | HTTP deny matrix, task action/domain tests, task grant tests |
|
||||
| Incoming webhooks: `forge/webhook`, `captureintake`, access delivery engine | Verify HMAC before parsing; derive source/org from stored source; evaluate source delivery policies and egress rules. No browser-user credential is inferred. | Webhook/capture tests, `TestAuthorizeDelivery` |
|
||||
| Control-plane configuration, secrets, harness and extensions | Browser policy and instance-only restrictions where registered; service contracts carry principal/org; task grants cannot invoke administrative RPCs. | HTTP deny matrix, `TestAdministrationRoutes`, `TestChannelReloadRoute`, `TestConfineHarnessOrg` |
|
||||
| Live HTTP/SSE and diagnostics | Authenticated policy gate applies before stream creation; org-scoped event reads; instance logs require administrative visibility. | HTTP deny matrix, instance-only tests, `TestServiceLogsRequireInstanceCredential` |
|
||||
| Background schedules, dispatch, curation | Service/agent authority, not an implicit browser user. Task-scoped grants and org scopes remain distinct from initiating human attribution. | Existing dispatch, grant, memory and org-scope tests |
|
||||
|
||||
The policy HTTP matrix enumerates each registered protected route. It checks
|
||||
both anonymous refusal and refusal by an explicit Cedar forbid, using the real
|
||||
handler stack. Separate tests exercise allowed requests and personal ownership;
|
||||
a denied-request matrix alone is not proof that a workflow works end to end.
|
||||
|
||||
## Public and personal routes
|
||||
|
||||
Public protocol entry points are `GET /api/auth/status`, `POST /api/auth/setup`,
|
||||
`POST /api/auth/login`, `POST /api/auth/logout`, `POST /api/auth/recover`,
|
||||
`POST /api/auth/passkey/begin`, `POST /api/auth/passkey/finish`,
|
||||
`GET /oauth2/login`, `GET /oauth2/callback`, health probes and signed webhook
|
||||
intake. Each has its own protocol checks. Static embedded app assets are public;
|
||||
they do not contain user data. `/health/detailed` remains protected.
|
||||
|
||||
Personal routes under `/api/account/` require an active signed-in person and
|
||||
server-derived ownership: password change, recovery-secret generation, passkey
|
||||
begin/finish/list/delete. They do not require an organization administrator role.
|
||||
`POST /api/accounts` and `/api/authentication` are administrative policy routes.
|
||||
|
||||
## HTTP route inventory
|
||||
|
||||
The following routes are covered by `TestHTTPPolicyCannotBeBypassed` in
|
||||
`internal/webui/authorization_surfaces_test.go`. `authorize.go` maps each to its
|
||||
action/resource; the handler may impose a stricter record or instance boundary.
|
||||
|
||||
| Method | Route example |
|
||||
| --- | --- |
|
||||
| DELETE | `/api/access/policies` |
|
||||
| DELETE | `/api/bindings/7` |
|
||||
| DELETE | `/api/event-types/7` |
|
||||
| DELETE | `/api/extensions/sample` |
|
||||
| DELETE | `/api/mappings/7` |
|
||||
| DELETE | `/api/orgs/7/members/sample` |
|
||||
| DELETE | `/api/sources/sample` |
|
||||
| DELETE | `/api/tokens/7` |
|
||||
| GET | `/api/access/policies` |
|
||||
| GET | `/api/alerts` |
|
||||
| GET | `/api/authentication` |
|
||||
| GET | `/api/bindings` |
|
||||
| GET | `/api/bindings/7` |
|
||||
| GET | `/api/bindings/7/dispatches` |
|
||||
| GET | `/api/capabilities` |
|
||||
| GET | `/api/captures` |
|
||||
| GET | `/api/captures/7/dispatches` |
|
||||
| GET | `/api/channels` |
|
||||
| GET | `/api/chat/file/sample` |
|
||||
| GET | `/api/chat/sessions` |
|
||||
| GET | `/api/chat/sessions/7/messages` |
|
||||
| GET | `/api/chat/sessions/7/turns` |
|
||||
| GET | `/api/chat/update` |
|
||||
| GET | `/api/config` |
|
||||
| GET | `/api/control-plane/apply-status` |
|
||||
| GET | `/api/control-plane/audit` |
|
||||
| GET | `/api/control-plane/catalog` |
|
||||
| GET | `/api/control-plane/resources/sample` |
|
||||
| GET | `/api/control-plane/resources/sample/history` |
|
||||
| GET | `/api/curators` |
|
||||
| GET | `/api/event-types` |
|
||||
| GET | `/api/extensions` |
|
||||
| GET | `/api/extensions/catalogue` |
|
||||
| GET | `/api/harness/bindings` |
|
||||
| GET | `/api/harness/terminal` |
|
||||
| GET | `/api/identities` |
|
||||
| GET | `/api/logs` |
|
||||
| GET | `/api/mappings` |
|
||||
| GET | `/api/mappings/7` |
|
||||
| GET | `/api/orgs` |
|
||||
| GET | `/api/orgs/7` |
|
||||
| GET | `/api/orgs/7/members` |
|
||||
| GET | `/api/orgs/7/workspaces` |
|
||||
| GET | `/api/secret-engines` |
|
||||
| GET | `/api/services` |
|
||||
| GET | `/api/setup` |
|
||||
| GET | `/api/skills` |
|
||||
| GET | `/api/sources` |
|
||||
| GET | `/api/stream` |
|
||||
| GET | `/api/summary` |
|
||||
| GET | `/api/task-meta` |
|
||||
| GET | `/api/tasks` |
|
||||
| GET | `/api/tasks/7` |
|
||||
| GET | `/api/tasks/7/attempts` |
|
||||
| GET | `/api/tasks/7/changes` |
|
||||
| GET | `/api/tasks/7/debug` |
|
||||
| GET | `/api/tasks/7/dispatches` |
|
||||
| GET | `/api/tasks/7/logs` |
|
||||
| GET | `/api/tasks/7/logs/download` |
|
||||
| GET | `/api/tasks/7/sandbox` |
|
||||
| GET | `/api/tokens` |
|
||||
| GET | `/api/version` |
|
||||
| GET | `/api/workflows` |
|
||||
| PATCH | `/api/bindings/7` |
|
||||
| PATCH | `/api/mappings/7` |
|
||||
| POST | `/api/accounts` |
|
||||
| POST | `/api/alerts/7/dismiss` |
|
||||
| POST | `/api/bindings` |
|
||||
| POST | `/api/bindings/7/approve` |
|
||||
| POST | `/api/bindings/7/pause` |
|
||||
| POST | `/api/bindings/7/resume` |
|
||||
| POST | `/api/channels/7/reload` |
|
||||
| POST | `/api/chat/answer` |
|
||||
| POST | `/api/chat/cancel` |
|
||||
| POST | `/api/chat/message` |
|
||||
| POST | `/api/chat/persona` |
|
||||
| POST | `/api/chat/stream` |
|
||||
| POST | `/api/chat/update/defer` |
|
||||
| POST | `/api/chat/update/install` |
|
||||
| POST | `/api/control-plane/resources/sample/commands/sample` |
|
||||
| POST | `/api/event-types` |
|
||||
| POST | `/api/extensions` |
|
||||
| POST | `/api/extensions/catalogue/sample/install` |
|
||||
| POST | `/api/extensions/sample/accept` |
|
||||
| POST | `/api/extensions/sample/approve-update` |
|
||||
| POST | `/api/extensions/sample/rollback` |
|
||||
| POST | `/api/extensions/sample/update` |
|
||||
| POST | `/api/identities` |
|
||||
| POST | `/api/identities/7/sample` |
|
||||
| POST | `/api/mappings` |
|
||||
| POST | `/api/mappings/preview` |
|
||||
| POST | `/api/orgs` |
|
||||
| POST | `/api/orgs/7/members` |
|
||||
| POST | `/api/orgs/7/workspaces` |
|
||||
| POST | `/api/secret-references/check` |
|
||||
| POST | `/api/sources` |
|
||||
| POST | `/api/sources/sample/approve-unsigned` |
|
||||
| POST | `/api/sources/sample/secret` |
|
||||
| POST | `/api/sources/sample/signing` |
|
||||
| POST | `/api/tasks/7/action` |
|
||||
| POST | `/api/tokens` |
|
||||
| POST | `/api/work-requests` |
|
||||
| PUT | `/api/access/policies` |
|
||||
| PUT | `/api/authentication` |
|
||||
| PUT | `/api/event-types/7` |
|
||||
| PUT | `/api/extensions/sample/enabled` |
|
||||
| PUT | `/api/extensions/sample/update-policy` |
|
||||
| PUT | `/api/orgs/7/agents/sample` |
|
||||
| PUT | `/api/orgs/7/members/sample` |
|
||||
| PUT | `/api/sources/sample/delivery-header` |
|
||||
| PUT | `/api/sources/sample/name` |
|
||||
| PUT | `/api/workflows/7/enabled` |
|
||||
|
||||
## Verification limits
|
||||
|
||||
A synthetic browser authenticator verifies protocol behavior, not a physical
|
||||
security key or every operating system. An OIDC unit test is not acceptance
|
||||
against a deployed provider. Disposable PostgreSQL smoke checks verify real SQL
|
||||
without putting database-dependent tests in the fast unit suite.
|
||||
|
||||
Existing anonymous conversations are retained but are not silently assigned to
|
||||
a new person. Existing service credentials remain privileged; this inventory
|
||||
does not claim that all internal gRPC methods have independent Cedar gates.
|
||||
|
||||
When changing a user-facing operation, update its inventory entry and its
|
||||
allow/deny behavior cases. Include another user in the same organization, a
|
||||
caller in another organization, a missing principal, unavailable policy storage,
|
||||
and the applicable owner/workspace/instance restrictions.
|
||||
|
||||
Bootstrap is unauthenticated until the first administrator is created. Complete
|
||||
setup before exposing a new installation to untrusted users. Last-active-owner
|
||||
protection for identity suspension/retirement is tracked separately as
|
||||
`archie-core-d7avc`; membership-policy guards are not that lifecycle guard.
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
out/
|
||||
@@ -0,0 +1,61 @@
|
||||
# e2e
|
||||
|
||||
Validation of the whole stack, run by hand or by an agent, never by
|
||||
`task check` or CI. It needs PostgreSQL 18, five services, Vite and a browser,
|
||||
which the gate must not. Docker is not needed: without it tasks queue and
|
||||
park, which is useful data for the dashboard.
|
||||
|
||||
| File | What it does |
|
||||
| --- | --- |
|
||||
| `stack.sh` | Starts PostgreSQL 18 (port 55432) and the five services as local processes, then Vite on 5173 |
|
||||
| `seed.sh` | Seeds the stack through the dashboard API; safe to rerun |
|
||||
| `run.cjs` | Runs `checks/*.cjs` in headless Chromium; screenshots to `out/` |
|
||||
| `checks/` | One module per behaviour |
|
||||
| `results/` | One committed report per release |
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
task e2e:up # build, start everything, seed
|
||||
task e2e:check # all checks; or: node e2e/run.cjs routes
|
||||
task e2e:down # stop; e2e/stack.sh reset also deletes the data
|
||||
```
|
||||
|
||||
Nothing reads the installed config: `stack.sh` points the XDG directories at
|
||||
`${ARCHIE_DEV_DIR:-~/.local/state/archie-dev}` and writes its overlay from
|
||||
`deployments/dev.toml`. Logs are in its `logs/`. `e2e/stack.sh restart archied`
|
||||
restarts one service.
|
||||
|
||||
The first run needs `npm ci --prefix e2e` and `npx --prefix e2e playwright
|
||||
install chromium`. In the cloud environment, Chromium and Playwright are
|
||||
preinstalled; run with `NODE_PATH=$(npm root -g)`.
|
||||
|
||||
## Release evidence
|
||||
|
||||
```bash
|
||||
node e2e/run.cjs --record v1.54.0
|
||||
```
|
||||
|
||||
writes `results/v1.54.0.md`, the pass or fail of every check for that
|
||||
release. Commit it with the release. Screenshots stay in `out/`.
|
||||
|
||||
## Writing a check
|
||||
|
||||
A module in `checks/` exports `async ({ page, go, shot, fail })`. `go(path)`
|
||||
loads a dashboard route, `shot(label)` saves a screenshot, `fail(msg)` records
|
||||
a problem without stopping. A throw, a `fail`, or any console or page error
|
||||
fails the check. Wait for elements, never for `networkidle`: the event stream
|
||||
never goes idle.
|
||||
|
||||
`routes` loads every static route and flags text with stray leading,
|
||||
trailing or doubled spaces. `seeded` checks the seed is visible.
|
||||
|
||||
## Pitfalls
|
||||
|
||||
| Symptom | Cause | Fix |
|
||||
| --- | --- | --- |
|
||||
| State Store exits: server is older than PostgreSQL 18 | another server answered | `stack.sh` uses port 55432; set `ARCHIE_DEV_PGPORT` if that is taken |
|
||||
| Work request: repository is not configured | archied reads repository policies only at boot | `seed.sh` restarts it; do the same after changing policies |
|
||||
| Your own shell is killed (exit 144) | `pkill -f` matched its own command line | `stack.sh stop` or `restart`, which kill by PID |
|
||||
| `npx shadcn-vue add` cannot fetch the registry | Node's fetch ignores the cloud agent proxy | `curl` the registry JSON and copy the files |
|
||||
| Postgres aborts in the cloud | `/tmp/claude-0` is reset to mode 700 | `stack.sh` keeps the root cluster in `/var/lib/archie-dev` |
|
||||
@@ -0,0 +1,36 @@
|
||||
// Every static route loads without errors, renders, and shows no text with
|
||||
// stray leading, trailing or doubled spaces.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function routes() {
|
||||
const src = fs.readFileSync(path.join(__dirname, '../../ui/src/router/index.ts'), 'utf8');
|
||||
const out = [];
|
||||
for (const line of src.split('\n')) {
|
||||
if (/redirect:/.test(line)) continue;
|
||||
const m = line.match(/path: "([^"]*)"/);
|
||||
if (!m || m[1].includes(':')) continue;
|
||||
if (m[1].startsWith('/')) out.push(m[1]);
|
||||
else if (m[1]) out.push('/org/' + m[1]);
|
||||
}
|
||||
return [...new Set(out)];
|
||||
}
|
||||
|
||||
module.exports = async ({ page, go, shot, fail }) => {
|
||||
const stray = new Map();
|
||||
for (const r of routes()) {
|
||||
await go(r);
|
||||
await shot(r);
|
||||
// Log lines are data, not copy.
|
||||
if (r === '/logs') continue;
|
||||
const bad = await page.evaluate(() => [...document.querySelectorAll('body *')]
|
||||
.filter((el) => !el.children.length && !el.closest('pre,code,textarea,.xterm') && el.getClientRects().length && !getComputedStyle(el).whiteSpace.startsWith('pre'))
|
||||
.map((el) => el.textContent)
|
||||
.filter((t) => t.trim() && (t !== t.trim() || / /.test(t.trim()))));
|
||||
for (const t of bad) {
|
||||
const key = JSON.stringify(t.length > 60 ? t.slice(0, 60) + '…' : t);
|
||||
stray.set(key, (stray.get(key) || new Set()).add(r));
|
||||
}
|
||||
}
|
||||
for (const [text, where] of stray) fail(`stray whitespace ${text} on ${[...where].join(', ')}`);
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
// The seed (e2e/seed.sh) is visible where an operator would look for it.
|
||||
module.exports = async ({ page, go, shot }) => {
|
||||
await go('/tasks');
|
||||
await page.getByText('Fix flaky login test').first().waitFor({ timeout: 10000 });
|
||||
await shot('tasks');
|
||||
await go('/events');
|
||||
await page.getByText('e2e-hook').first().waitFor({ timeout: 10000 });
|
||||
await shot('events');
|
||||
};
|
||||
Generated
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "archie-e2e",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "archie-e2e",
|
||||
"devDependencies": {
|
||||
"playwright": "1.64.0"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.64.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.0.tgz",
|
||||
"integrity": "sha512-kVzTnYFYEyQ9RGzBjNCd2+yEqWmVbxl3AHPynv3qQ6JTjv4a+kwRcnqQwIpuP3NnrnIrE/Q6wWAIAvMfIE2/Yg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.64.0"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.64.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.0.tgz",
|
||||
"integrity": "sha512-T9r+MZkTECl2+oUcZ26YgZzTrYidTsIhYYkJix+6iDOymOb1FB2RLLSOxRGnZGv5DStt+aduIVbt+E8WygXYpg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "archie-e2e",
|
||||
"private": true,
|
||||
"description": "Validation of a running local stack; never part of the gate",
|
||||
"scripts": {
|
||||
"check": "node run.cjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"playwright": "1.64.0"
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
// Drive the dashboard of a running local stack (e2e/stack.sh) in headless
|
||||
// Chromium. Each module in checks/ exports async ({ page, go, shot, fail }).
|
||||
// A check fails on a thrown error or any console or page error.
|
||||
//
|
||||
// node e2e/run.cjs [--record VERSION] [check ...]
|
||||
//
|
||||
// Screenshots and results.json go to e2e/out/<stamp>/. --record also writes
|
||||
// e2e/results/VERSION.md, the committed evidence for a release.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
const base = process.env.ARCHIE_E2E_URL || 'http://localhost:5173';
|
||||
const args = process.argv.slice(2);
|
||||
let record = '';
|
||||
if (args[0] === '--record') { record = args[1]; args.splice(0, 2); }
|
||||
const names = args.length ? args : fs.readdirSync(path.join(__dirname, 'checks')).filter((f) => f.endsWith('.cjs')).map((f) => f.slice(0, -4)).sort();
|
||||
const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const out = path.join(__dirname, 'out', stamp);
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch();
|
||||
const results = [];
|
||||
for (const name of names) {
|
||||
const check = require(path.join(__dirname, 'checks', name + '.cjs'));
|
||||
// A fresh page per check: open event streams pile up across navigations.
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
||||
const errors = [];
|
||||
const notes = [];
|
||||
page.on('pageerror', (e) => errors.push(String(e)));
|
||||
page.on('console', (m) => m.type() === 'error' && errors.push(m.text()));
|
||||
// Wait for load, never networkidle: the event stream never goes idle.
|
||||
const go = async (p) => { await page.goto(base + p, { waitUntil: 'load' }); await page.waitForTimeout(1200); };
|
||||
const shot = (label) => page.screenshot({ path: path.join(out, `${name}-${label.replace(/[^a-z0-9-]+/gi, '_') || 'root'}.png`) });
|
||||
const fail = (msg) => notes.push(msg);
|
||||
const started = Date.now();
|
||||
let error = '';
|
||||
try { await check({ page, go, shot, fail }); } catch (e) { error = String(e && e.message || e); }
|
||||
await page.close();
|
||||
const problems = [error, ...notes, ...errors].filter(Boolean);
|
||||
results.push({ check: name, ok: problems.length === 0, ms: Date.now() - started, problems });
|
||||
console.log(`${problems.length ? 'FAIL' : 'ok '} ${name}${problems.length ? '\n ' + problems.join('\n ') : ''}`);
|
||||
}
|
||||
await browser.close();
|
||||
fs.writeFileSync(path.join(out, 'results.json'), JSON.stringify(results, null, 2));
|
||||
if (record) writeRecord(record, results);
|
||||
console.log(`evidence: ${out}`);
|
||||
process.exit(results.every((r) => r.ok) ? 0 : 1);
|
||||
})().catch((e) => { console.error(e); process.exit(2); });
|
||||
|
||||
function writeRecord(version, results) {
|
||||
const dir = path.join(__dirname, 'results');
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
const rows = results.map((r) => `| ${r.check} | ${r.ok ? 'pass' : 'fail'} | ${r.problems.join('<br>').replace(/\|/g, '\\|') || ''} |`);
|
||||
const passed = results.filter((r) => r.ok).length;
|
||||
fs.writeFileSync(path.join(dir, `${version}.md`), [
|
||||
`# ${version}`, '',
|
||||
`Run ${new Date().toISOString()} against ${base}: ${passed} of ${results.length} checks passed.`, '',
|
||||
'| Check | Result | Problems |', '| --- | --- | --- |', ...rows, '',
|
||||
].join('\n'));
|
||||
}
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# Seed a running local stack (e2e/stack.sh) through the dashboard's own HTTP
|
||||
# API, so the seed exercises real validation. Safe to run again: each step
|
||||
# skips what already exists.
|
||||
set -euo pipefail
|
||||
|
||||
base=${ARCHIE_E2E_API:-http://localhost:8484}
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
H=(-H 'Content-Type: application/json' -H 'X-Archie-CSRF: 1' -H "Origin: $base")
|
||||
|
||||
get() { curl -fsS "$base$1"; }
|
||||
post() { curl -fsS -X POST "$base$1" "${H[@]}" -d "$2"; }
|
||||
# jq-free JSON reads: py EXPR, with the parsed body as d.
|
||||
py() { python3 -c "import sys, json; d = json.load(sys.stdin); print($1)"; }
|
||||
|
||||
# Repository policy. archied applies it live; the pause lets the watch publish it.
|
||||
if ! get /api/control-plane/resources/repository-policies | grep -q '"widgets"'; then
|
||||
version=$(get /api/control-plane/resources/repository-policies | py 'd["resource"]["version"]')
|
||||
post /api/control-plane/resources/repository-policies/commands/replace \
|
||||
"{\"value\":[{\"owner\":\"acme\",\"name\":\"widgets\",\"base\":\"main\"}],\"expected_version\":$version}" >/dev/null
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Work requests. Without Docker they park within a minute, which fills
|
||||
# Needs you, Quality gates and the task pages.
|
||||
tasks=$(get /api/tasks)
|
||||
for t in "Fix flaky login test" "Add retry to webhook sender" "Document the gate" "Speed up the CI cache"; do
|
||||
grep -qF "\"$t\"" <<<"$tasks" && continue
|
||||
post /api/work-requests "{\"identity\":\"archie-dev\",\"repository\":\"acme/widgets\",\"workflow\":\"triage\",\"title\":\"$t\",\"instructions\":\"Do it.\"}" >/dev/null
|
||||
done
|
||||
|
||||
# An unsigned capture source with one delivery, an event type, a mapping and
|
||||
# a binding left pending approval.
|
||||
src=e2e-hook
|
||||
if ! get /api/sources | grep -q "\"$src\""; then
|
||||
post /api/sources "{\"path\":\"$src\"}" >/dev/null
|
||||
post "/api/sources/$src/signing" '{"signed":false}' >/dev/null
|
||||
post "/api/sources/$src/approve-unsigned" '{}' >/dev/null
|
||||
bash "$here/../tools/webhook-send.sh" --url "$base" --source "$src" --kind github-issue >/dev/null
|
||||
fi
|
||||
et=$(get /api/event-types | py '"".join(t["id"] for t in (d.get("event_types", []) if isinstance(d, dict) else d) if t["name"] == "issue-opened")')
|
||||
if [ -z "$et" ]; then
|
||||
et=$(post /api/event-types "{\"source\":\"$src\",\"name\":\"issue-opened\",\"rule\":{\"headers\":[],\"payload\":[{\"path\":\"action\",\"op\":\"equals\",\"value\":\"opened\"}]},\"example\":{\"headers\":{},\"body\":\"{\\\"action\\\":\\\"opened\\\",\\\"issue\\\":{\\\"title\\\":\\\"x\\\"}}\"}}" | py 'd["id"]')
|
||||
fi
|
||||
if ! get /api/bindings | grep -q '"e2e-binding"'; then
|
||||
mapping=$(post /api/mappings "{\"name\":\"e2e-issue\",\"source_hint\":\"$src\",\"event_type_id\":\"$et\",\"fields\":[{\"name\":\"title\",\"path\":\"issue.title\",\"type\":\"string\",\"required\":true}]}" | py 'd["id"]')
|
||||
post /api/bindings "{\"name\":\"e2e-binding\",\"matcher\":{\"source\":\"$src\"},\"mapping_id\":\"$mapping\",\"workflow\":\"feasibility\",\"owner\":\"acme\",\"repo\":\"widgets\"}" >/dev/null
|
||||
fi
|
||||
|
||||
echo "seeded: $(get /api/tasks | py 'len(d.get("tasks", d) if isinstance(d, dict) else d)') tasks"
|
||||
Executable
+140
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the whole stack as local processes against a throwaway PostgreSQL 18,
|
||||
# for manual and scripted checks. Never part of the gate. Nothing here reads
|
||||
# the installed config: XDG paths point into the dev directory.
|
||||
#
|
||||
# e2e/stack.sh start | stop | restart <service> | status | reset
|
||||
set -euo pipefail
|
||||
|
||||
repo=$(cd "$(dirname "$0")/.." && pwd)
|
||||
dir=${ARCHIE_DEV_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/archie-dev}
|
||||
pgport=${ARCHIE_DEV_PGPORT:-55432}
|
||||
services=(archie-state-store archie-gateway archied archie-messaging archie-ui)
|
||||
|
||||
# initdb refuses root, and postgres cannot traverse root's home.
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
pgdata=/var/lib/archie-dev/pg
|
||||
as_pg() { runuser -u postgres -- "$@"; }
|
||||
else
|
||||
pgdata=$dir/pg
|
||||
as_pg() { "$@"; }
|
||||
fi
|
||||
|
||||
export XDG_CONFIG_HOME=$dir/config XDG_DATA_HOME=$dir/data XDG_STATE_HOME=$dir/state
|
||||
|
||||
pgbin() {
|
||||
local d
|
||||
for d in /usr/lib/postgresql/18/bin "$(dirname "$(command -v postgres 2>/dev/null || echo /x/x)")"; do
|
||||
if [ -x "$d/postgres" ] && "$d/postgres" --version | grep -q ' 18\.'; then
|
||||
echo "$d"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "PostgreSQL 18 server not found" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
wait_port() {
|
||||
for _ in $(seq 1 "${3:-60}"); do
|
||||
(echo >"/dev/tcp/127.0.0.1/$1") 2>/dev/null && return 0
|
||||
sleep 1
|
||||
done
|
||||
echo "$2 did not listen on $1; see $dir/logs/$2.log" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
start_pg() {
|
||||
local bin
|
||||
bin=$(pgbin)
|
||||
if [ ! -f "$pgdata/PG_VERSION" ]; then
|
||||
mkdir -p "$pgdata"
|
||||
[ "$(id -u)" -ne 0 ] || chown postgres "$pgdata"
|
||||
as_pg "$bin/initdb" -D "$pgdata" -U archie --auth=trust >/dev/null
|
||||
fi
|
||||
if ! as_pg "$bin/pg_ctl" -D "$pgdata" status >/dev/null 2>&1; then
|
||||
as_pg "$bin/pg_ctl" -D "$pgdata" -w -l "$pgdata/server.log" \
|
||||
-o "-p $pgport -k $pgdata -c listen_addresses=127.0.0.1" start >/dev/null
|
||||
fi
|
||||
"$bin/psql" -h 127.0.0.1 -p "$pgport" -U archie -d postgres -qtAc \
|
||||
"SELECT 1 FROM pg_database WHERE datname = 'archie'" | grep -q 1 ||
|
||||
"$bin/createdb" -h 127.0.0.1 -p "$pgport" -U archie archie
|
||||
}
|
||||
|
||||
prepare() {
|
||||
mkdir -p "$dir"/{bin,logs,pids} "$XDG_CONFIG_HOME/archie" "$XDG_DATA_HOME" "$XDG_STATE_HOME"
|
||||
[ -f "$XDG_CONFIG_HOME/archie/config.toml" ] || cp "$repo/config.example.toml" "$XDG_CONFIG_HOME/archie/config.toml"
|
||||
sed "s#^database_url = .*#database_url = \"postgres://archie@127.0.0.1:$pgport/archie?sslmode=disable\"#" \
|
||||
"$repo/deployments/dev.toml" >"$dir/dev.toml"
|
||||
local s
|
||||
for s in "${services[@]}"; do
|
||||
(cd "$repo" && go build -o "$dir/bin/$s" "./cmd/$s")
|
||||
done
|
||||
}
|
||||
|
||||
# spawn NAME DIR CMD...: a detached session leader, so stop takes its children.
|
||||
spawn() {
|
||||
local name=$1 cwd=$2
|
||||
shift 2
|
||||
setsid -f bash -c 'cd "$1" && echo $$ >"$2" && shift 2 && exec "$@"' _ "$cwd" "$dir/pids/$name" "$@" \
|
||||
</dev/null >"$dir/logs/$name.log" 2>&1
|
||||
}
|
||||
|
||||
start_service() {
|
||||
spawn "$1" "$repo" "$dir/bin/$1" -config-overlay "$dir/dev.toml"
|
||||
}
|
||||
|
||||
stop_pid() {
|
||||
local f=$1 pid
|
||||
[ -f "$f" ] || return 0
|
||||
pid=$(cat "$f")
|
||||
if kill -- "-$pid" 2>/dev/null; then
|
||||
for _ in $(seq 1 20); do kill -0 "$pid" 2>/dev/null || break; sleep 0.5; done
|
||||
kill -9 -- "-$pid" 2>/dev/null || true
|
||||
fi
|
||||
rm -f "$f"
|
||||
}
|
||||
|
||||
start() {
|
||||
prepare
|
||||
start_pg
|
||||
start_service archie-state-store
|
||||
wait_port 9091 archie-state-store 90
|
||||
local s
|
||||
for s in archie-gateway archied archie-messaging archie-ui; do start_service "$s"; done
|
||||
wait_port 8484 archie-ui
|
||||
[ -d "$repo/ui/node_modules" ] || (cd "$repo/ui" && npm ci --no-audit --no-fund >/dev/null)
|
||||
spawn vite "$repo/ui" npx vite --host 127.0.0.1 --port 5173 --strictPort
|
||||
wait_port 5173 vite
|
||||
echo "dashboard: http://localhost:5173 logs: $dir/logs"
|
||||
}
|
||||
|
||||
stop() {
|
||||
local f
|
||||
for f in "$dir"/pids/*; do stop_pid "$f"; done
|
||||
if [ -f "$pgdata/PG_VERSION" ]; then
|
||||
as_pg "$(pgbin)/pg_ctl" -D "$pgdata" -m fast stop >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
case ${1:-} in
|
||||
start) start ;;
|
||||
stop) stop ;;
|
||||
restart)
|
||||
stop_pid "$dir/pids/${2:?service}"
|
||||
start_service "$2"
|
||||
;;
|
||||
status)
|
||||
for f in "$dir"/pids/*; do
|
||||
[ -f "$f" ] || continue
|
||||
if kill -0 "$(cat "$f")" 2>/dev/null; then echo "up $(basename "$f")"; else echo "down $(basename "$f")"; fi
|
||||
done
|
||||
;;
|
||||
reset)
|
||||
stop
|
||||
rm -rf "$dir" "$pgdata"
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 start | stop | restart <service> | status | reset" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -1,130 +1,113 @@
|
||||
module github.com/samcharles93/archie-core
|
||||
|
||||
go 1.27.0
|
||||
go 1.27.2
|
||||
|
||||
require (
|
||||
cel.dev/expr v0.25.3 // indirect
|
||||
dario.cat/mergo v1.0.2 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20260917205352-e937bb47801a // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.5.1 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.4 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.5.2 // indirect
|
||||
github.com/antithesishq/antithesis-sdk-go v0.8.0 // indirect
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudflare/circl v1.6.5 // indirect
|
||||
github.com/containerd/errdefs v1.0.0 // indirect
|
||||
github.com/containerd/errdefs/pkg v0.3.0 // indirect
|
||||
github.com/containerd/log v0.2.0 // indirect
|
||||
github.com/containerd/platforms v1.0.0-rc.5 // indirect
|
||||
github.com/cpuguy83/dockercfg v0.3.2 // indirect
|
||||
github.com/distribution/reference v0.6.0 // indirect
|
||||
github.com/docker/go-connections v0.8.1 // indirect
|
||||
github.com/docker/go-connections v0.8.2 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/dustin/go-humanize v1.1.0 // indirect
|
||||
github.com/ebitengine/purego v0.11.1 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fatih/color v1.19.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.1.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.9.4 // indirect
|
||||
github.com/go-git/gcfg/v2 v2.0.2 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.1.5 // indirect
|
||||
github.com/go-json-experiment/json v0.0.0-20260820222146-c27c302e5fc3 // indirect
|
||||
github.com/go-logr/logr v1.4.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||
github.com/go-webauthn/x v0.3.1 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/go-tpm v0.9.8 // indirect
|
||||
github.com/google/jsonschema-go v0.4.3 // indirect
|
||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.3 // indirect
|
||||
github.com/kevinburke/ssh_config v1.6.0 // indirect
|
||||
github.com/klauspost/compress v1.20.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect
|
||||
github.com/magiconair/properties v1.18.12 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/klauspost/compress v1.20.3 // indirect
|
||||
github.com/mattn/go-colorable v0.1.16 // indirect
|
||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||
github.com/mfridman/interpolate v0.0.2 // indirect
|
||||
github.com/minio/highwayhash v1.0.4 // indirect
|
||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||
github.com/moby/go-archive v0.3.3 // indirect
|
||||
github.com/moby/patternmatcher v0.6.1 // indirect
|
||||
github.com/moby/sys/sequential v0.7.0 // indirect
|
||||
github.com/moby/sys/user v0.4.1 // indirect
|
||||
github.com/moby/sys/userns v0.2.1 // indirect
|
||||
github.com/moby/term v0.5.2 // indirect
|
||||
github.com/nats-io/jwt/v2 v2.8.2 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/oklog/run v1.1.0 // indirect
|
||||
github.com/pjbgf/sha1cd v0.6.0 // indirect
|
||||
github.com/oklog/run v1.2.0 // indirect
|
||||
github.com/philhofer/fwd v1.2.0 // indirect
|
||||
github.com/pjbgf/sha1cd v0.7.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 // indirect
|
||||
github.com/segmentio/asm v1.2.1 // indirect
|
||||
github.com/segmentio/encoding v0.5.4 // indirect
|
||||
github.com/sergi/go-diff v1.4.0 // indirect
|
||||
github.com/sethvargo/go-retry v0.4.0 // indirect
|
||||
github.com/shirou/gopsutil/v4 v4.26.8 // indirect
|
||||
github.com/sethvargo/go-retry v0.5.0 // indirect
|
||||
github.com/sirupsen/logrus v1.10.2 // indirect
|
||||
github.com/stretchr/testify v1.12.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.4.0 // indirect
|
||||
github.com/tklauser/numcpus v0.12.0 // indirect
|
||||
github.com/tinylib/msgp v1.6.4 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 // indirect
|
||||
go.opentelemetry.io/otel v1.46.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.46.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.46.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 // indirect
|
||||
go.opentelemetry.io/otel v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/log v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.47.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.5 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba // indirect
|
||||
golang.org/x/sync v0.23.0 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20261013213113-2ab7f3cbc5fb // indirect
|
||||
golang.org/x/sync v0.24.0 // indirect
|
||||
golang.org/x/text v0.43.0 // indirect
|
||||
golang.org/x/time v0.16.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260921155816-b14227669459 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260921155816-b14227669459 // indirect
|
||||
modernc.org/libc v1.77.1 // indirect
|
||||
modernc.org/sqlite v1.59.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261012220534-4341edf3f941 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
cel.dev/cel-go v0.32.0
|
||||
github.com/BurntSushi/toml v1.6.0
|
||||
github.com/cedar-policy/cedar-go v1.8.0
|
||||
github.com/containerd/errdefs v1.0.0
|
||||
github.com/coreos/go-oidc/v3 v3.21.0
|
||||
github.com/docker/sandbox-kit-spec/v3 v3.0.0-m.6
|
||||
github.com/go-git/go-billy/v6 v6.0.0-alpha.2
|
||||
github.com/go-git/go-git/v6 v6.0.0-alpha.5
|
||||
github.com/docker/sandbox-kit-spec/v3 v3.0.0-m.8
|
||||
github.com/go-git/go-billy/v6 v6.0.0-beta.1
|
||||
github.com/go-git/go-git/v6 v6.0.0-beta.1
|
||||
github.com/go-jose/go-jose/v4 v4.1.5
|
||||
github.com/go-telegram/bot v1.27.0
|
||||
github.com/go-webauthn/webauthn v0.18.2
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/google/jsonschema-go v0.4.3
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/hashicorp/go-hclog v1.6.3
|
||||
github.com/hashicorp/go-plugin v1.8.0
|
||||
github.com/jackc/pgx/v5 v5.11.0
|
||||
github.com/moby/moby/api v1.56.0
|
||||
github.com/moby/moby/client v0.6.0
|
||||
github.com/moby/moby/api v1.56.1
|
||||
github.com/moby/moby/client v0.6.2
|
||||
github.com/modelcontextprotocol/go-sdk v1.8.0
|
||||
github.com/nats-io/nats-server/v2 v2.15.0
|
||||
github.com/nats-io/nats-server/v2 v2.15.1
|
||||
github.com/nats-io/nats.go v1.54.0
|
||||
github.com/opencontainers/go-digest v1.0.0
|
||||
github.com/opencontainers/image-spec v1.1.1
|
||||
github.com/pressly/goose/v3 v3.28.0
|
||||
github.com/samcharles93/ai-sdk v0.1.42
|
||||
github.com/testcontainers/testcontainers-go v0.44.0
|
||||
github.com/testcontainers/testcontainers-go/modules/postgres v0.44.0
|
||||
github.com/pressly/goose/v3 v3.29.0
|
||||
github.com/samcharles93/ai-sdk v0.3.1
|
||||
go.lsp.dev/jsonrpc2 v1.0.1
|
||||
go.lsp.dev/protocol v1.0.1
|
||||
go.lsp.dev/uri v1.0.1
|
||||
golang.org/x/mod v0.41.0
|
||||
golang.org/x/net v0.59.0
|
||||
golang.org/x/crypto v0.58.0
|
||||
golang.org/x/mod v0.42.0
|
||||
golang.org/x/net v0.61.0
|
||||
golang.org/x/oauth2 v0.37.0
|
||||
golang.org/x/sys v0.48.0
|
||||
golang.org/x/term v0.46.0
|
||||
google.golang.org/grpc v1.85.0-dev.0.20260825072537-93e31b48545e
|
||||
golang.org/x/sys v0.49.0
|
||||
golang.org/x/term v0.47.0
|
||||
google.golang.org/grpc v1.86.0-dev
|
||||
google.golang.org/protobuf v1.36.12
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
oras.land/oras-go/v2 v2.6.2
|
||||
oras.land/oras-go/v2 v2.6.3
|
||||
)
|
||||
@@ -2,18 +2,12 @@ cel.dev/cel-go v0.32.0 h1:irvpFKr5EuGPyxeME03ERh0rii1TX+BDAnB9eL3IvNk=
|
||||
cel.dev/cel-go v0.32.0/go.mod h1:DnVip7tpJSsgZymwfT+m1tnEVy3ivAjSMXPx12YrMkU=
|
||||
cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0=
|
||||
cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
|
||||
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
|
||||
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk=
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20260917205352-e937bb47801a h1:4hxax9ktNjSDoFn1tZSeL6gXMTRMpO0FzjdKfT01jgY=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20260917205352-e937bb47801a/go.mod h1:3EWSSOZ50kb+arhww0qIaEXHToib/3FjBj9Jj5lcP5g=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/ProtonMail/go-crypto v1.5.1 h1:pTrLDQHyOT8y3DFYIpijgPBTw/7E2GLMimutvOlceuE=
|
||||
github.com/ProtonMail/go-crypto v1.5.1/go.mod h1:/RaSu30DaKO4RY+XdV/ACcCcZkGr7AhUIduq5sjzzCo=
|
||||
github.com/Microsoft/go-winio v0.6.4 h1:kJF2pamtYCWXf0xAT8sAkwKC0pMl2HYBrRPHAqyUc+g=
|
||||
github.com/Microsoft/go-winio v0.6.4/go.mod h1:1xl5JXG4ze/m74GH6Dc4Mwxfc3VL5siRVQjIAlHH07U=
|
||||
github.com/ProtonMail/go-crypto v1.5.2 h1:cucYnvqcY7UOXVD//mSyjeaPY0SSN3v5cDkYPxumINk=
|
||||
github.com/ProtonMail/go-crypto v1.5.2/go.mod h1:/RaSu30DaKO4RY+XdV/ACcCcZkGr7AhUIduq5sjzzCo=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.8.0 h1:bVV5ZAuwaREn4klRSJusYaA+A7NXq8Qi9C/knCaQ2N4=
|
||||
@@ -26,8 +20,6 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/
|
||||
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
|
||||
github.com/cedar-policy/cedar-go v1.8.0 h1:9gcU7EHXwHC2RMdpph68yTAkdB3behTTssC+kt4GoS8=
|
||||
github.com/cedar-policy/cedar-go v1.8.0/go.mod h1:h5+3CVW1oI5LXVskJG+my9TFCYI5yjh/+Ul3EJie6MI=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudflare/circl v1.6.5 h1:O64F26HEqNhznd/hrC5KZXVKYuKM2rx4deZDTc4ihQA=
|
||||
@@ -42,24 +34,18 @@ github.com/containerd/platforms v1.0.0-rc.5 h1:vXd569rDrz8LeMXzAnBsy6LADV5YtsD8o
|
||||
github.com/containerd/platforms v1.0.0-rc.5/go.mod h1:lKlMXyLybmBedS/JJm11uDofzI8L2v0J2ZbYvNsbq1A=
|
||||
github.com/coreos/go-oidc/v3 v3.21.0 h1:wZo4Q9Pum8dYEj0eMUPrqR+kvuGkeUplbLpNCkBqoWM=
|
||||
github.com/coreos/go-oidc/v3 v3.21.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA=
|
||||
github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
|
||||
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
|
||||
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/docker/go-connections v0.8.1 h1:JibmG5hULs5qXSr/cp/w3Pw5fZuStt4MOHMUExb29/M=
|
||||
github.com/docker/go-connections v0.8.1/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q=
|
||||
github.com/docker/go-connections v0.8.2 h1:9d9DEokx5W7qlr0shkFXIxEA7+TTD+llwzcykSlxMNc=
|
||||
github.com/docker/go-connections v0.8.2/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/sandbox-kit-spec/v3 v3.0.0-m.6 h1:co7vn6GgImYEGO/KPlhPRJT9i5EPWgOKcB9q7bNJlFQ=
|
||||
github.com/docker/sandbox-kit-spec/v3 v3.0.0-m.6/go.mod h1:MrWO4PN3/VYC5xF8eyI8U82Nv/agTHcN4IUzheqA90c=
|
||||
github.com/docker/sandbox-kit-spec/v3 v3.0.0-m.8 h1:ay2XEj0yW3uzsNwN3KXS/c4nlneHONFKaHlrVhu2WCQ=
|
||||
github.com/docker/sandbox-kit-spec/v3 v3.0.0-m.8/go.mod h1:4G6VgFAp9eaQkwy7DbZbOfWRD/Mjvc/TnEtQBRRMEsA=
|
||||
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||
github.com/ebitengine/purego v0.11.1 h1:2zpWRSQNVKN4eKsKO9eM1ILDgWfYMY9GwqRmK6XeQ/0=
|
||||
github.com/ebitengine/purego v0.11.1/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
@@ -67,16 +53,18 @@ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
|
||||
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
|
||||
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
||||
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
||||
github.com/fxamacker/cbor/v2 v2.9.4 h1:xwjVlxEMR3S605oUlgBjKLTTeGFciYPGYCtF/35LKGo=
|
||||
github.com/fxamacker/cbor/v2 v2.9.4/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
|
||||
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
|
||||
github.com/go-git/gcfg/v2 v2.0.2 h1:MY5SIIfTGGEMhdA7d7JePuVVxtKL7Hp+ApGDJAJ7dpo=
|
||||
github.com/go-git/gcfg/v2 v2.0.2/go.mod h1:/lv2NsxvhepuMrldsFilrgct6pxzpGdSRC13ydTLSLs=
|
||||
github.com/go-git/go-billy/v6 v6.0.0-alpha.2 h1:1Sv5WemXL8CxKrAx1gioJ+uHNb2bZJhiQLfwSZ4Et8c=
|
||||
github.com/go-git/go-billy/v6 v6.0.0-alpha.2/go.mod h1:r/bsv9i/iDyyEU8/Z6mjC+YraOVwie1ddfUqBCElKXQ=
|
||||
github.com/go-git/go-billy/v6 v6.0.0-beta.1 h1:OJ4r207zcEbeq/DJNajQUOMd+pph3r9A7hRq1Sjl1bA=
|
||||
github.com/go-git/go-billy/v6 v6.0.0-beta.1/go.mod h1:QGOWN4CzmtRfpFeCw5paG3RJyKdTwsfGASkxBVkIaAU=
|
||||
github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1 h1:gmqi2jvsreu0s8JMLylYDFq4sbjHwwlhktMw0DUg3mA=
|
||||
github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1/go.mod h1:ECf1MqJlBdYpKggBrOXjo/0EnvRZx6D++I86UYjPgAQ=
|
||||
github.com/go-git/go-git/v6 v6.0.0-alpha.5 h1:sE+OlkHgYWNMVmN1s9sR7uyFgsWLtxcNWse/vBYKxRE=
|
||||
github.com/go-git/go-git/v6 v6.0.0-alpha.5/go.mod h1:3IjhiZnM+uBmUrOGSeqrJpsmi4Vd0H2NZO/uK2a7d0s=
|
||||
github.com/go-git/go-git/v6 v6.0.0-beta.1 h1:1t+vJYGDBN6f9GRWskgWx5UjXPFUa7wfffZZZ2C5GtA=
|
||||
github.com/go-git/go-git/v6 v6.0.0-beta.1/go.mod h1:ugDlr38Wwc+fOw85J+Oluh5TNXQtJgYMcriOljg3l4s=
|
||||
github.com/go-jose/go-jose/v4 v4.1.5 h1:RjgjO2LOtWOJKUC5wpwY9LR3B3vwVAz6JS2YHfYU6eA=
|
||||
github.com/go-jose/go-jose/v4 v4.1.5/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-json-experiment/json v0.0.0-20260820222146-c27c302e5fc3 h1:UADEEmDKgfXbtnGJZ97beY5XLo9ZechG1nlU4KnRrkE=
|
||||
@@ -86,11 +74,14 @@ github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/go-telegram/bot v1.27.0 h1:PG9yBDzM8O26oUerE9SZwWlHon4RpH8WcNslZ7CEZmE=
|
||||
github.com/go-telegram/bot v1.27.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/go-webauthn/webauthn v0.18.2 h1:0BeftmEHU7i3Dv0VFwBtidy/ba37Vcdjvqst9EYu8Sk=
|
||||
github.com/go-webauthn/webauthn v0.18.2/go.mod h1:hEXaOuLxvZ3zG9miZe3ehlyeVso9AtklXG+kTn36k+A=
|
||||
github.com/go-webauthn/x v0.3.1 h1:1ff37z3XfmTTomkhlURgGizLIDyOvPgTt2t9nlzKLRo=
|
||||
github.com/go-webauthn/x v0.3.1/go.mod h1:ZInxAynYXfBPvvm5gzKZ7geBlL23K71xASMgohHl/Rg=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
@@ -99,6 +90,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
|
||||
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||
github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba h1:qJEJcuLzH5KDR0gKc0zcktin6KSAwL7+jWKBYceddTc=
|
||||
github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba/go.mod h1:EFYHy8/1y2KfgTAsx7Luu7NGhoxtuVHnNo8jE7FikKc=
|
||||
github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0=
|
||||
github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
@@ -115,16 +108,14 @@ github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7Ulw
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.11.0 h1:IzBBtyK9AHqf98cctWFifYSci2hgQR/cd56wB4p+ogg=
|
||||
github.com/jackc/pgx/v5 v5.11.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jackc/puddle/v2 v2.2.3 h1:f8HoREISb3l5eO9coPgK7U3hKLhWGokOFVcThl5jrao=
|
||||
github.com/jackc/puddle/v2 v2.2.3/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
|
||||
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
|
||||
github.com/kevinburke/ssh_config v1.6.0 h1:J1FBfmuVosPHf5GRdltRLhPJtJpTlMdKTBjRgTaQBFY=
|
||||
github.com/kevinburke/ssh_config v1.6.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
|
||||
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
||||
github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4=
|
||||
github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
@@ -132,116 +123,82 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 h1:eveIIGn4BGM3qknO74omf6HYr30/exH+eVUTuAgwjZ0=
|
||||
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
|
||||
github.com/magiconair/properties v1.18.12 h1:sT9zQpvTB3B4gzrX0tmZNTEaGyg8Zw55MFYRE32Mr9I=
|
||||
github.com/magiconair/properties v1.18.12/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-colorable v0.1.16 h1:+2YjeAe7xP1OQbZW1jERPWWCDLlNqFNCvjiqGiAt84A=
|
||||
github.com/mattn/go-colorable v0.1.16/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/mdelapenya/tlscert v0.2.0 h1:7H81W6Z/4weDvZBNOfQte5GpIMo0lGYEeWbkGp5LJHI=
|
||||
github.com/mdelapenya/tlscert v0.2.0/go.mod h1:O4njj3ELLnJjGdkN7M/vIVCpZ+Cf0L6muqOG4tLSl8o=
|
||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
||||
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
|
||||
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
|
||||
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/moby/go-archive v0.3.3 h1:OxxR9paxsluYi+zDUEXTTaIxtkK3viymW+Ka7vRhhME=
|
||||
github.com/moby/go-archive v0.3.3/go.mod h1:Npdv43fFqlhZW7Xo8fbm3ZMYFvAGNviUPqX21VERbcE=
|
||||
github.com/moby/moby/api v1.56.0 h1:GQzua3NA599ASSIICx0iFgiJeO9YkdDARvQsm23ZZuQ=
|
||||
github.com/moby/moby/api v1.56.0/go.mod h1:sZ+THbVWkjOmBPPfbnzdD/G1LuIexWhqlSHHPTDQ1Uk=
|
||||
github.com/moby/moby/client v0.6.0 h1:AJjEB21QPbXSXjDsZorFBoDZPhMrfbpaPLgSMAW9Bgs=
|
||||
github.com/moby/moby/client v0.6.0/go.mod h1:OCo00wNRyA3m4lmJ228W3JbyCN4ZNNYjpOXiJydBdcQ=
|
||||
github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U=
|
||||
github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||
github.com/moby/sys/mount v0.3.5 h1:eS3fsZTjHaBihwjp4/+5Z3jxqLXYsbwxqpVSfFv3M00=
|
||||
github.com/moby/sys/mount v0.3.5/go.mod h1:WUQDO+/uCiCIkIztx8SrwIDVn2dtMFRBebRhpDFT71M=
|
||||
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
|
||||
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
|
||||
github.com/moby/sys/sequential v0.7.0 h1:ASQNGNROJSuOO6LL6bPHbKvuZu6NU8P4ldPWk31zj/8=
|
||||
github.com/moby/sys/sequential v0.7.0/go.mod h1:NfSTAp6V3fw4tmkD62PEcOKeZKquXT8VKCkf7aVR79o=
|
||||
github.com/moby/sys/user v0.4.1 h1:RgjRlaDKi/Xmyrz4t8lyzXT6v2ooFeO/7xtchmhVWE0=
|
||||
github.com/moby/sys/user v0.4.1/go.mod h1:E9QsW5WRe1kUAf7kW8hXKwu1uhsZEAdPLYHYSDudF4Y=
|
||||
github.com/moby/sys/userns v0.2.1 h1:4OvdM7BcPkASbuouHsbW3aeMJSFlYDldBRnXVZhaRk8=
|
||||
github.com/moby/sys/userns v0.2.1/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
|
||||
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
|
||||
github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
|
||||
github.com/moby/moby/api v1.56.1 h1:PpWkvVPB7Fr/No8w+TfyJ/I6rWZ2YPZhT3JorIg+06c=
|
||||
github.com/moby/moby/api v1.56.1/go.mod h1:sZ+THbVWkjOmBPPfbnzdD/G1LuIexWhqlSHHPTDQ1Uk=
|
||||
github.com/moby/moby/client v0.6.2 h1:ekSPlMccrZGcw6Scb8T9D39qE0mB+XupU/yS0zNw9N4=
|
||||
github.com/moby/moby/client v0.6.2/go.mod h1:DGcnO7qmPJrqobx/ggQgQ/AUk+2wgVdQv7uxB0/mEsc=
|
||||
github.com/modelcontextprotocol/go-sdk v1.8.0 h1:KIvahhYqwtbeniWVPs3TcXEA7b8jEtwfBpOTAI+Urx4=
|
||||
github.com/modelcontextprotocol/go-sdk v1.8.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts=
|
||||
github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc=
|
||||
github.com/nats-io/jwt/v2 v2.8.2/go.mod h1:Ag/56sq9OblL4JgdYufDd16Egb17Kr/8WwwuO/forVc=
|
||||
github.com/nats-io/nats-server/v2 v2.15.0 h1:M99yf0y05rTr46/qc/Is6ZAowI58Ryp2SjufLCUeVJc=
|
||||
github.com/nats-io/nats-server/v2 v2.15.0/go.mod h1:5qLF4CDGzZVFt//3fUrY1ePpwbi05r7QHPNroSUtolk=
|
||||
github.com/nats-io/nats-server/v2 v2.15.1 h1:fK3AeYFIji1Smng60jB0hVoAPZezA/UzsaI3BqXFNEI=
|
||||
github.com/nats-io/nats-server/v2 v2.15.1/go.mod h1:yeuYRtKVKIFtmMz2/YPk+6hvmNBnk+WwTUzErBdH6IE=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
|
||||
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
|
||||
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
|
||||
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
|
||||
github.com/ncruces/go-strftime v1.1.0/go.mod h1:yVaq7iwCN09vHRrKBrrflXT0M9tTMG2KmZ9Fj7xeG/g=
|
||||
github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E=
|
||||
github.com/oklog/run v1.2.0/go.mod h1:mgDbKRSwPhJfesJ4PntqFUbKQRZ50NgmZTSPlFA0YFk=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
|
||||
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
|
||||
github.com/pjbgf/sha1cd v0.6.0 h1:3WJ8Wz8gvDz29quX1OcEmkAlUg9diU4GxJHqs0/XiwU=
|
||||
github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
|
||||
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
|
||||
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
||||
github.com/pjbgf/sha1cd v0.7.0 h1:ZRNPKHj+gfkLBf0KJv/p1Hmz+7bqCT5o311YX0nq+DA=
|
||||
github.com/pjbgf/sha1cd v0.7.0/go.mod h1:pKR5Li+qTCo+ebqITZfwPlJGoCFCvSO00qxjbNtTUFQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 h1:XA01Vk/wv9YikCi1V51yRzIHPMT5of9+cMpZoZvDn/M=
|
||||
github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/pressly/goose/v3 v3.28.0 h1:D2M+iL31GmpZxSHOhX8mqyqAT3CXnokUmm0eKoSP+Vc=
|
||||
github.com/pressly/goose/v3 v3.28.0/go.mod h1:v26MOuB8bL3kzzrt3Vqhb3R0PRVsl8hFQKdrht/L6Rk=
|
||||
github.com/pressly/goose/v3 v3.29.0 h1:dtEnBCT7CqkHIUCdgrXsrmeisaN8gFkRU4Y5OEwif4o=
|
||||
github.com/pressly/goose/v3 v3.29.0/go.mod h1:plA4aP4+u+Q3FMTgbFbhF8TuAWpAdfWpoFGkJsIFWh0=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/samcharles93/ai-sdk v0.1.42 h1:YV4O6oV0OLIqDAnEWAotPyw19K1VH2YoAT0He7aW+Lg=
|
||||
github.com/samcharles93/ai-sdk v0.1.42/go.mod h1:u4zrQ9/Q58L5mNEut4bNQ1ks+RCKq71LN5EDz2N/0Zk=
|
||||
github.com/samcharles93/ai-sdk v0.3.1 h1:fD/Byx1Vo6NeZZBsSurxTO9e2/tAdAlEUIW+J7Hc/DM=
|
||||
github.com/samcharles93/ai-sdk v0.3.1/go.mod h1:u4zrQ9/Q58L5mNEut4bNQ1ks+RCKq71LN5EDz2N/0Zk=
|
||||
github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0=
|
||||
github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0=
|
||||
github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
|
||||
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
|
||||
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/sethvargo/go-retry v0.4.0 h1:9qy1OoIAxBL+gBYnkTnTnWle5wlfsXQlwRzIbbpdqPw=
|
||||
github.com/sethvargo/go-retry v0.4.0/go.mod h1:tvsjdKG6xfiCx4LSiUZ06kcv38xvdVQwv8R6/VnnVWg=
|
||||
github.com/shirou/gopsutil/v4 v4.26.8 h1:YQMTF/1J50B5+Y0vlo1eDRf5DoR7Gk69hY+8wjYkQeo=
|
||||
github.com/shirou/gopsutil/v4 v4.26.8/go.mod h1:5O9FjBiXoTDFatIWjZZosqj4pV0DRtLx598xGbBehzM=
|
||||
github.com/sethvargo/go-retry v0.5.0 h1:JYfFKmVJ8ER06GReN1efzc5cm52BrVsFVzmcHiKJwfY=
|
||||
github.com/sethvargo/go-retry v0.5.0/go.mod h1:tvsjdKG6xfiCx4LSiUZ06kcv38xvdVQwv8R6/VnnVWg=
|
||||
github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo=
|
||||
github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4=
|
||||
github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||
github.com/testcontainers/testcontainers-go v0.44.0 h1:/Fwh6HY1mIikhnm9e7HwoxGycx0lzRAE0f5VQpjFxzI=
|
||||
github.com/testcontainers/testcontainers-go v0.44.0/go.mod h1:IcnwQrYTO86xHXu5bvMaBH7ATlbS3Qn1M1QWW3c66rE=
|
||||
github.com/testcontainers/testcontainers-go/modules/postgres v0.44.0 h1:8fdv/9y3JMxjQ+ULAcOG8RtgeNu5t9XF9LolSXDuTwM=
|
||||
github.com/testcontainers/testcontainers-go/modules/postgres v0.44.0/go.mod h1:CFr2LncGYokw+OKjXcr8ARCKG1SaC2UEnGxFBovE86g=
|
||||
github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU=
|
||||
github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=
|
||||
github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=
|
||||
github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
|
||||
github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ=
|
||||
github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
|
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
|
||||
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
go.lsp.dev/jsonrpc2 v1.0.1 h1:JZAchpm6RcOuwEOnZ7kF3kA1EpEjdJZ/6rMSfOF3+F4=
|
||||
go.lsp.dev/jsonrpc2 v1.0.1/go.mod h1:WN+TesqrPumBmUdsuWyn9DHq3zl4i85L/qG0NLdj8qg=
|
||||
go.lsp.dev/protocol v1.0.1 h1:kLWUIk1v/deXxo1D0VO4avjZnfeuZ82mouJgJd/NbdU=
|
||||
@@ -250,62 +207,63 @@ go.lsp.dev/uri v1.0.1 h1:ywxJN1UXoQ+v0I9lkoQNMmsm7lub5G9ZG7KXT8YTx30=
|
||||
go.lsp.dev/uri v1.0.1/go.mod h1:06a0ghafs4PuqkLsJGUmlgPHw6+kH79edRXjOT/rA8s=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 h1:3g7B90UzBltIDKq1/5mrTGxTnOFDV0ICOhLoxiZ8jlg=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0/go.mod h1:Ef8SuTh59BT7+ofpDxN9z+yOlc4t2GjLmKDgYNJL/NU=
|
||||
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
|
||||
go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE=
|
||||
go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8=
|
||||
go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o=
|
||||
go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI=
|
||||
go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4=
|
||||
go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c=
|
||||
go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
|
||||
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
|
||||
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
|
||||
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
|
||||
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
|
||||
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
|
||||
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
|
||||
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
|
||||
go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw=
|
||||
go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM=
|
||||
go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba h1:Ck8QetSgk912qxWLMCKxd0in+aiyBQyDSMae6e/xmpU=
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba/go.mod h1:50RgIsmK7OwqzTTeqcSXQW8SswW0o8fRcDxmqGluJ8E=
|
||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
||||
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
||||
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||
golang.org/x/exp v0.0.0-20261013213113-2ab7f3cbc5fb h1:fMK59tNbIKghD6eTnk7DGfVtbK6JiHiFgpmBAWcPaco=
|
||||
golang.org/x/exp v0.0.0-20261013213113-2ab7f3cbc5fb/go.mod h1:DBoxwWhjaW8DJJw/YeM4zpeOKMC1FMXSblsYy+1mFSw=
|
||||
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
||||
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
||||
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
|
||||
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/oauth2 v0.37.0 h1:JUlcxA8oAtauLfiH8FX2/FkAWHAdi0QtGCGc+hofE98=
|
||||
golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
|
||||
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
|
||||
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
|
||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
||||
golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE=
|
||||
golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s=
|
||||
golang.org/x/tools v0.50.0 h1:c2ifzfcuY7L90lZ2aKd8S4K2NpASF08SZx9ZuJkHmSU=
|
||||
golang.org/x/tools v0.50.0/go.mod h1:7ulVMw3831Mwi5EZD6RomGyffr4VFjuNYXf2BbCEAV0=
|
||||
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
||||
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260921155816-b14227669459 h1:GS9OIt/j7c8bvBjYNgnKQysVfmV7e4jM0H8ZK95G4t8=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260921155816-b14227669459/go.mod h1:PX5/4vemwVoXtwEcRDWwcR1/r0qrosfx3qoVADMwnVE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260921155816-b14227669459 h1:b0xCahf3FK2m2Cv0p4vTozGPWncCvLfwV86UNg8xWU8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260921155816-b14227669459/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||
google.golang.org/grpc v1.85.0-dev.0.20260825072537-93e31b48545e h1:ar+feAPij1Znzug45m6AoShUCc5AaR8FLA3I6LZd94k=
|
||||
google.golang.org/grpc v1.85.0-dev.0.20260825072537-93e31b48545e/go.mod h1:7aY/KlAHanMAVIWHnk8wloQsdlfwzDz/PP9vCbJG6CU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261012220534-4341edf3f941 h1:DS/w3N8rsfrwxwgGSj6WhMsPo7aNQGmDx74J81zd0NQ=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261012220534-4341edf3f941/go.mod h1:AuGAdi9KnXss7xbLxIKhCvk+Ro/SxpET/iS45DNYN+M=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 h1:QG6hS4zFplRZvOQedzei4t2pT/zkQc3VR1u+S9/rcAw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||
google.golang.org/grpc v1.86.0-dev h1:FLq7hcApuJeJ70J9+k0FvmXsNCwS8B2/MeAfYdy3GHY=
|
||||
google.golang.org/grpc v1.86.0-dev/go.mod h1:Ovl0ECo4xx5r4kn/6d4BPSNB7OIFuu6EAjOzjtVAKaM=
|
||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -319,15 +277,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
||||
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
||||
modernc.org/libc v1.77.1 h1:Ct8j47QtiZ1Enj2DtFXQtUqrPCAjdCmPjtCuvrYQ0Hs=
|
||||
modernc.org/libc v1.77.1/go.mod h1:87/pZ4L6nD1zqW4nItuS12YO7hN1igAah34xjnQo/W0=
|
||||
modernc.org/libc v1.78.0 h1:Lpm+e9K6ruVYEGwWfuBO1xXtYEaXDouFOG1SuWjFDP4=
|
||||
modernc.org/libc v1.78.0/go.mod h1:wvxR55nOF2/66NkJoNV7/coXBTCvT3HR22rcqW6lOuA=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/sqlite v1.59.0 h1:X1es1GpqBlS/5T+vbM4HLUdaa8OtQx468DF2vrx+38A=
|
||||
modernc.org/sqlite v1.59.0/go.mod h1:+paeT2A3iPRHkQDwG7oA6Tk0zQd5woMEI8q7orfry8k=
|
||||
oras.land/oras-go/v2 v2.6.2 h1:N04RXngAp1LJKTG6ifz3xHPipasEkWr+hFmInja5YKo=
|
||||
oras.land/oras-go/v2 v2.6.2/go.mod h1:PlTtg4JTDJkDe8yVHpM2wz7/YDc00GVas+i4jAW2TZ4=
|
||||
modernc.org/sqlite v1.60.1 h1:/blz53O951KWFOso4QQvEs/Fq6cDBKLtMVrYNSeJVKw=
|
||||
modernc.org/sqlite v1.60.1/go.mod h1:1dIoEagfDE72QytD5scH1lxARtaUgKgHC/NuApA27r0=
|
||||
oras.land/oras-go/v2 v2.6.3 h1:72z4K9YiDKVB5jieM8cuB1WSVnbZkkD2hd+NmO3HYVI=
|
||||
oras.land/oras-go/v2 v2.6.3/go.mod h1:imXEFiYkTZUVVYkfv/r5GVmWeiLkGtNQA8FU4F/sjKs=
|
||||
pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk=
|
||||
pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
|
||||
+5
-6
@@ -10,7 +10,7 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO="samcharles93/archie-core"
|
||||
REPO="samcharles93/archie-releases"
|
||||
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}"
|
||||
@@ -89,8 +89,8 @@ fi
|
||||
|
||||
mkdir -p "${ARCHIE_CONFIG_DIR}" "${ARCHIE_DATA_DIR}" "${ARCHIE_BIN_DIR}"
|
||||
|
||||
# 2. Binaries. STAGE ends up holding the binaries, release.json and the
|
||||
# updater scripts, whichever way they were obtained.
|
||||
# 2. Binaries. STAGE ends up holding the binaries and release.json, whichever
|
||||
# way they were obtained.
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "${TMP}"' EXIT
|
||||
|
||||
@@ -111,7 +111,7 @@ if [ "${FROM_SOURCE}" = true ]; then
|
||||
for cmd in $(jq -er '.required_topology.units | join(" ")' "${SRC_DIR}/release.json"); do
|
||||
(cd "${SRC_DIR}" && go build -ldflags "${LDFLAGS}" -o "${STAGE}/${cmd}" "./cmd/${cmd}")
|
||||
done
|
||||
cp "${SRC_DIR}/release.json" "${SRC_DIR}"/scripts/archie-update-* "${STAGE}/"
|
||||
cp "${SRC_DIR}/release.json" "${STAGE}/"
|
||||
else
|
||||
if [ -z "${VERSION}" ]; then
|
||||
tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')"
|
||||
@@ -137,8 +137,7 @@ TOPOLOGY_UNITS="$(tr -d '\n' <"${STAGE}/release.json" | sed -n 's/.*"units": *\[
|
||||
for cmd in ${TOPOLOGY_UNITS}; do
|
||||
install -m755 "${STAGE}/${cmd}" "${ARCHIE_BIN_DIR}/${cmd}"
|
||||
done
|
||||
install -m755 "${STAGE}"/archie-update-* "${ARCHIE_BIN_DIR}/"
|
||||
echo " Installed ${TOPOLOGY_UNITS} and the updater to ${ARCHIE_BIN_DIR}/"
|
||||
echo " Installed ${TOPOLOGY_UNITS} to ${ARCHIE_BIN_DIR}/"
|
||||
|
||||
# 3. Configuration. archied setup asks every question and writes config.toml
|
||||
# plus any secrets to the env file beside it; this script asks nothing itself.
|
||||
|
||||
@@ -254,16 +254,18 @@ func invoke(ctx context.Context, workspace string, h *agentrun.HarnessSpec, argv
|
||||
return err
|
||||
}
|
||||
var stderr tailBuffer
|
||||
cmd.Stderr = &stderr
|
||||
cmd.Stderr = io.MultiWriter(&stderr, os.Stderr)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("start harness: %w", err)
|
||||
}
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
// Keep the raw harness activity visible in the container's live output.
|
||||
output := io.TeeReader(stdout, os.Stdout)
|
||||
scanner := bufio.NewScanner(output)
|
||||
scanner.Buffer(make([]byte, 64*1024), 16*1024*1024)
|
||||
for scanner.Scan() {
|
||||
out.Line(scanner.Bytes(), report)
|
||||
}
|
||||
_, _ = io.Copy(io.Discard, stdout)
|
||||
_, _ = io.Copy(io.Discard, output)
|
||||
if err := cmd.Wait(); err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//go:build unix
|
||||
|
||||
package agentexec
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/agentrun"
|
||||
)
|
||||
|
||||
func TestHarnessLiveOutput(t *testing.T) {
|
||||
if os.Getenv("ARCHIE_TEST_HARNESS_OUTPUT") == "1" {
|
||||
adapter := &codexHarnessOutput{}
|
||||
user := ""
|
||||
if os.Geteuid() == 0 {
|
||||
user = "65534"
|
||||
}
|
||||
err := invoke(t.Context(), "/tmp", &agentrun.HarnessSpec{User: user}, []string{"sh", "-c", `printf '%s\n' '{"type":"thread.started","thread_id":"live-thread"}'; printf '%s\n' 'live diagnostic' >&2`}, adapter, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if adapter.SessionID() != "live-thread" {
|
||||
t.Fatal("forwarding lost the adapter input")
|
||||
}
|
||||
return
|
||||
}
|
||||
cmd := exec.CommandContext(t.Context(), os.Args[0], "-test.run=^TestHarnessLiveOutput$")
|
||||
cmd.Env = append(os.Environ(), "ARCHIE_TEST_HARNESS_OUTPUT=1")
|
||||
got, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("harness: %v: %s", err, got)
|
||||
}
|
||||
for _, want := range []string{"live-thread", "live diagnostic"} {
|
||||
if !strings.Contains(string(got), want) {
|
||||
t.Errorf("worker output %q is missing %q", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/agentrun"
|
||||
)
|
||||
|
||||
@@ -62,7 +64,7 @@ func ProtectionMatcher(p agentrun.Protection, readOnly bool) func(string) bool {
|
||||
func ValidateCaptureArgs(spec agentrun.CaptureTool, value json.RawMessage) (string, bool) {
|
||||
var object map[string]json.RawMessage
|
||||
if err := json.Unmarshal(value, &object); err != nil {
|
||||
return spec.Name + " rejected: arguments must be a JSON object", false //nolint:nilerr // the agent loop must see malformed tool arguments as feedback it can correct, not as a failed tool call
|
||||
return spec.Name + " rejected: arguments must be a JSON object", false // the agent loop must see malformed tool arguments as feedback it can correct, not as a failed tool call
|
||||
}
|
||||
for _, check := range []func(agentrun.CaptureTool, map[string]json.RawMessage) (string, bool){
|
||||
checkRequiredFields,
|
||||
@@ -74,9 +76,52 @@ func ValidateCaptureArgs(spec agentrun.CaptureTool, value json.RawMessage) (stri
|
||||
return rejection, false
|
||||
}
|
||||
}
|
||||
// The derived checks above cover the common cases with friendly wording;
|
||||
// the schema is what enforces the rest of what the tool advertised --
|
||||
// enums, numeric types, nested objects, array shapes -- so a call the
|
||||
// agent could only make valid is rejected with the reason, not recorded.
|
||||
return checkSchema(spec, value)
|
||||
}
|
||||
|
||||
// checkSchema validates the arguments against the tool's advertised JSON
|
||||
// Schema. A tool with no schema, or one that will not resolve, is accepted
|
||||
// here: a schema that never resolves is a definition bug, refused where the
|
||||
// tool is built (workflow's agentResultTool), so the agent is never blamed
|
||||
// for it.
|
||||
func checkSchema(spec agentrun.CaptureTool, value json.RawMessage) (string, bool) {
|
||||
if len(spec.Parameters) == 0 {
|
||||
return "", true
|
||||
}
|
||||
resolved, err := resolveCaptureSchema(spec.Parameters)
|
||||
if err != nil {
|
||||
return "", true
|
||||
}
|
||||
var instance any
|
||||
if err := json.Unmarshal(value, &instance); err != nil {
|
||||
return spec.Name + " rejected: arguments must be JSON", false
|
||||
}
|
||||
if err := resolved.Validate(instance); err != nil {
|
||||
return fmt.Sprintf("%s rejected: %v", spec.Name, err), false
|
||||
}
|
||||
return "", true
|
||||
}
|
||||
|
||||
// resolveCaptureSchema parses and resolves a capture tool's JSON Schema. The
|
||||
// workflow parser resolves the same schema when it builds the tool, so an
|
||||
// unusable schema is refused at definition time rather than silently skipped
|
||||
// here.
|
||||
func resolveCaptureSchema(params json.RawMessage) (*jsonschema.Resolved, error) {
|
||||
var schema jsonschema.Schema
|
||||
if err := json.Unmarshal(params, &schema); err != nil {
|
||||
return nil, fmt.Errorf("capture tool schema: %w", err)
|
||||
}
|
||||
resolved, err := schema.Resolve(nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("capture tool schema: %w", err)
|
||||
}
|
||||
return resolved, nil
|
||||
}
|
||||
|
||||
func checkRequiredFields(spec agentrun.CaptureTool, object map[string]json.RawMessage) (string, bool) {
|
||||
for _, field := range spec.RequiredFields {
|
||||
if _, ok := object[field]; !ok {
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package agentexec
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/agentrun"
|
||||
)
|
||||
|
||||
// resultSchema is the shape of a shipped planner result (triage's), with a
|
||||
// nested object and an array so every constraint kind the agent can violate
|
||||
// is exercised.
|
||||
const resultSchema = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"needs_code_change": {"type": "boolean"},
|
||||
"workflow": {"type": "string", "enum": ["implement", "tdd", "feasibility"]},
|
||||
"reasons": {"type": "string"},
|
||||
"labels": {"type": "array", "items": {"type": "string"}, "maxItems": 2},
|
||||
"plan": {"type": "object", "properties": {"risk": {"type": "integer"}}, "required": ["risk"]}
|
||||
},
|
||||
"required": ["needs_code_change", "workflow", "reasons"]
|
||||
}`
|
||||
|
||||
// TestValidateCaptureArgsEnforcesSchema pins that the advertised schema is
|
||||
// enforced, not merely offered to the agent: an enum, a numeric type, an
|
||||
// array's item type and length, and a nested object's shape all reject with a
|
||||
// message naming what was wrong, so the agent can correct it.
|
||||
func TestValidateCaptureArgsEnforcesSchema(t *testing.T) {
|
||||
base := `"needs_code_change": true, "workflow": "tdd", "reasons": "why"`
|
||||
tests := []struct {
|
||||
name string
|
||||
args string
|
||||
wantOK bool
|
||||
wantText string
|
||||
}{
|
||||
{name: "valid", args: `{` + base + `}`, wantOK: true},
|
||||
{name: "enum violation", args: `{` + base + `, "workflow": "banana"}`, wantText: "workflow"},
|
||||
{name: "wrong boolean type", args: `{"needs_code_change": "yes", "workflow": "tdd", "reasons": "why"}`, wantText: "needs_code_change"},
|
||||
{name: "string where integer expected", args: `{` + base + `, "plan": {"risk": "high"}}`, wantText: "plan"},
|
||||
{name: "array item type", args: `{` + base + `, "labels": [1, 2]}`, wantText: "labels"},
|
||||
{name: "array too long", args: `{` + base + `, "labels": ["a", "b", "c"]}`, wantText: "labels"},
|
||||
{name: "nested required missing", args: `{` + base + `, "plan": {}}`, wantText: "plan"},
|
||||
}
|
||||
spec := agentrun.CaptureTool{Name: "result", Parameters: json.RawMessage(resultSchema)}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
rejection, ok := ValidateCaptureArgs(spec, json.RawMessage(tt.args))
|
||||
if ok != tt.wantOK {
|
||||
t.Fatalf("ok = %v, rejection = %q; want ok %v", ok, rejection, tt.wantOK)
|
||||
}
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
if !strings.HasPrefix(rejection, "result rejected: ") {
|
||||
t.Fatalf("rejection %q does not name the tool", rejection)
|
||||
}
|
||||
if !strings.Contains(rejection, tt.wantText) {
|
||||
t.Fatalf("rejection %q does not mention %q", rejection, tt.wantText)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestValidateCaptureArgsWithoutSchema pins that a tool with no schema, or one
|
||||
// whose schema cannot resolve, still accepts a call: the derived constraint
|
||||
// lists remain the whole check, so the agent is never blocked by a tool
|
||||
// definition the schema check cannot read.
|
||||
func TestValidateCaptureArgsWithoutSchema(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
spec agentrun.CaptureTool
|
||||
args string
|
||||
wantOK bool
|
||||
}{
|
||||
{name: "no schema", spec: agentrun.CaptureTool{Name: "note"}, args: `{"anything": 1}`, wantOK: true},
|
||||
{
|
||||
name: "unresolvable schema is not the agent's problem",
|
||||
spec: agentrun.CaptureTool{Name: "note", Parameters: json.RawMessage(`{"$ref": "#/definitions/missing"}`)},
|
||||
args: `{"anything": 1}`,
|
||||
wantOK: true,
|
||||
},
|
||||
{
|
||||
name: "derived checks still apply without a schema",
|
||||
spec: agentrun.CaptureTool{Name: "note", NonEmptyStrings: []string{"body"}},
|
||||
args: `{"body": " "}`,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, ok := ValidateCaptureArgs(tt.spec, json.RawMessage(tt.args))
|
||||
if ok != tt.wantOK {
|
||||
t.Fatalf("ok = %v, want %v", ok, tt.wantOK)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ type LoopRunner struct {
|
||||
// Limits bounds the size of tool results fed back into the stage. The
|
||||
// zero value applies no limits.
|
||||
Limits ToolLimits
|
||||
// AllowTools is the profile's allowlist over archie-added tools. Empty allows
|
||||
// AllowTools is the allowlist over archie-added tools. Nil allows
|
||||
// all. Capture tools and agentloop's built-in file tools are never
|
||||
// filtered.
|
||||
AllowTools []string
|
||||
@@ -187,9 +187,9 @@ func makeCaptureHandler(spec agentrun.CaptureTool, captures map[string][]json.Ra
|
||||
}
|
||||
}
|
||||
|
||||
// allowedTools keeps the tools allow names; an empty allow keeps them all.
|
||||
// allowedTools keeps the tools allow names; a nil allow keeps them all.
|
||||
func allowedTools(set core.ToolSet, allow []string) core.ToolSet {
|
||||
if len(allow) == 0 {
|
||||
if allow == nil {
|
||||
return set
|
||||
}
|
||||
kept := core.ToolSet{}
|
||||
|
||||
@@ -4,31 +4,31 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/ai-sdk/chat"
|
||||
"github.com/samcharles93/ai-sdk/core"
|
||||
"github.com/samcharles93/ai-sdk/runtime"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/agentexec/modelloop"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/usage"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
"github.com/samcharles93/archie-core/internal/tools/mcp"
|
||||
)
|
||||
|
||||
// taskSamplingModel returns the task's builder model, or "".
|
||||
func taskSamplingModel(cfg config.TaskConfig) string {
|
||||
return strings.TrimSpace(cfg.Models["builder"])
|
||||
}
|
||||
|
||||
// taskSamplingHandler answers MCP sampling requests with the task's model.
|
||||
// Without a runtime or model the request is refused.
|
||||
func taskSamplingHandler(llm *runtime.Runtime, cfg config.TaskConfig) mcp.SamplingHandler {
|
||||
// Without a runtime or model the request is refused. record receives each
|
||||
// call's model ref and token usage.
|
||||
func taskSamplingHandler(llm *runtime.Runtime, cfg config.TaskConfig, record func(context.Context, string, chat.Usage)) mcp.SamplingHandler {
|
||||
return func(ctx context.Context, req mcp.SamplingRequest) (mcp.SamplingResult, error) {
|
||||
if llm == nil {
|
||||
return mcp.SamplingResult{}, errors.New("mcp sampling: no model runtime is configured")
|
||||
}
|
||||
model := taskSamplingModel(cfg)
|
||||
if model == "" {
|
||||
return mcp.SamplingResult{}, errors.New("mcp sampling: no builder model is configured")
|
||||
model, err := config.ResolveModel(cfg.Models, "", config.PurposeAgent)
|
||||
if err != nil {
|
||||
return mcp.SamplingResult{}, fmt.Errorf("mcp sampling: %w", err)
|
||||
}
|
||||
messages, err := modelloop.SamplingMessages(req)
|
||||
if err != nil {
|
||||
@@ -45,6 +45,7 @@ func taskSamplingHandler(llm *runtime.Runtime, cfg config.TaskConfig) mcp.Sampli
|
||||
options.Temperature = float32(*req.Temperature)
|
||||
}
|
||||
result, err := llm.Chat(ctx, model, options)
|
||||
record(ctx, model, result.TotalUsage)
|
||||
if err != nil {
|
||||
return mcp.SamplingResult{}, fmt.Errorf("mcp sampling: %w", err)
|
||||
}
|
||||
@@ -56,3 +57,21 @@ func taskSamplingHandler(llm *runtime.Runtime, cfg config.TaskConfig) mcp.Sampli
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// samplingUsageRecorder records a task's MCP sampling calls against the task.
|
||||
// A failed write is logged, never fails the call.
|
||||
func samplingUsageRecorder(store workflow.Store, t *workflow.Task, log *slog.Logger) func(context.Context, string, chat.Usage) {
|
||||
return func(ctx context.Context, model string, used chat.Usage) {
|
||||
if store == nil || t == nil {
|
||||
return
|
||||
}
|
||||
record := usage.Record{
|
||||
Source: usage.SourceTask, TaskID: t.ID, Attempt: t.Attempt, Workflow: t.Workflow, Step: "mcp-sampling",
|
||||
InputTokens: int64(used.PromptTokens), OutputTokens: int64(used.CompletionTokens),
|
||||
CachedTokens: int64(used.CachedTokens), At: time.Now().UTC(),
|
||||
}.WithRef(model)
|
||||
if err := store.RecordUsage(ctx, record); err != nil && log != nil {
|
||||
log.Warn("record model usage failed", "model", model, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,8 +198,6 @@ func stageRunners(req taskrun.Request, mcpSet *mcpProviderSet, newRunner runnerF
|
||||
// routeTask remains available for routing-only callers. Production execution
|
||||
// compiles the request's pinned YAML directly.
|
||||
func routeTask(req taskrun.Request, registry workflow.Registry) workflow.Workflow {
|
||||
workflow.SetKindWorkflows(req.KindWorkflows)
|
||||
workflow.SetLabelWorkflows(req.LabelWorkflows)
|
||||
return workflow.Route(req.Task, registry)
|
||||
}
|
||||
|
||||
@@ -233,7 +231,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
if len(req.MCPServers) > 0 {
|
||||
llm = modelloop.NewRuntime(req.Providers, req.Cfg.ModelLimits)
|
||||
}
|
||||
mcpSet, mcpErr := startMCPProviders(ctx, req.MCPServers, taskSamplingHandler(llm, req.Cfg), log)
|
||||
mcpSet, mcpErr := startMCPProviders(ctx, req.MCPServers, taskSamplingHandler(llm, req.Cfg, samplingUsageRecorder(dependencies.store, req.Task, log)), log)
|
||||
if mcpSet != nil {
|
||||
defer mcpSet.cleanup(ctx, log)
|
||||
}
|
||||
@@ -269,10 +267,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
Log: log,
|
||||
Guardrails: dependencies.guardrails,
|
||||
}
|
||||
// pr-review reads the PR data the daemon prefetched into workDir.
|
||||
if req.Task.Workflow == "pr-review" {
|
||||
tc.PRSource = prsource.NewFromMount(filepath.Join(workDir, prsource.PrefetchDirName))
|
||||
}
|
||||
configureTaskContext(tc, workDir)
|
||||
|
||||
if req.Repo.PersistentStorage {
|
||||
memory, readErr := readProjectMemory(storage.MemoryPath)
|
||||
@@ -294,6 +289,18 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
|
||||
}, nil
|
||||
}
|
||||
|
||||
// configureTaskContext applies what the task's kind changes about its context:
|
||||
// a test run writes nothing to a forge, and pr-review reads the PR data the
|
||||
// daemon prefetched into workDir.
|
||||
func configureTaskContext(tc *workflow.TaskContext, workDir string) {
|
||||
if tc.Task.IsTestRun() {
|
||||
workflow.SuppressForgeWrites(tc)
|
||||
}
|
||||
if tc.Task.Workflow == "pr-review" {
|
||||
tc.PRSource = prsource.NewFromMount(filepath.Join(workDir, prsource.PrefetchDirName))
|
||||
}
|
||||
}
|
||||
|
||||
// CompilePinnedWorkflow compiles the definition the request carries. With
|
||||
// none, it pins one from the shipped definitions onto req and req.Task.
|
||||
func CompilePinnedWorkflow(req *taskrun.Request, steps *workflow.Manager) (workflow.Workflow, error) {
|
||||
|
||||
@@ -3,16 +3,25 @@ package agentworker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/agentexec"
|
||||
"github.com/samcharles93/archie-core/internal/domain/health"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/agentboot"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/agentgit"
|
||||
agentnats "github.com/samcharles93/archie-core/internal/infrastructure/agenttransport/nats"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/egress"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/readiness"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/workflowsteps"
|
||||
"github.com/samcharles93/archie-core/internal/installtype"
|
||||
"github.com/samcharles93/archie-core/internal/storage"
|
||||
"github.com/samcharles93/archie-core/internal/taskrun"
|
||||
"github.com/samcharles93/archie-core/internal/tools"
|
||||
@@ -41,17 +50,24 @@ type Settings struct {
|
||||
// NATS storerpc path is deleted.
|
||||
StateStoreTarget string
|
||||
StateStoreToken string
|
||||
// StateStoreCA is the PEM CA the State Store's certificate chains to.
|
||||
StateStoreCA []byte
|
||||
|
||||
// ModelProxy, ModelProxyHosts and ModelProxyCA route model provider
|
||||
// requests through the daemon's egress proxy, which holds the keys.
|
||||
// Empty ModelProxy sends them directly.
|
||||
ModelProxy string
|
||||
ModelProxyHosts []string
|
||||
ModelProxyCA string
|
||||
}
|
||||
|
||||
type workerTransport interface {
|
||||
taskServiceTransport
|
||||
Close()
|
||||
LogPublisher() agentexec.LogPublisher
|
||||
EventPublisher() agentexec.EventPublisher
|
||||
SubscribeTasks(context.Context, int64, agentnats.TaskHandler, *slog.Logger) (agentnats.Subscription, error)
|
||||
Forger(identity, credential string, timeout time.Duration) workflow.Forger
|
||||
Store(time.Duration) workflow.Store
|
||||
Calls(time.Duration) task.Caller
|
||||
Trees(string, string, time.Duration) agentnats.RemoteTrees
|
||||
PutPresence(context.Context, storecontract.Presence) error
|
||||
BrokerReady() bool
|
||||
}
|
||||
|
||||
type workerDependencies struct {
|
||||
@@ -110,6 +126,15 @@ func run(ctx context.Context, settings Settings, log *slog.Logger, dependencies
|
||||
workDir = storage.WorktreeMountDir
|
||||
}
|
||||
|
||||
if settings.ModelProxy != "" {
|
||||
transport, err := egress.ModelTransport(settings.ModelProxy, settings.ModelProxyHosts, settings.ModelProxyCA)
|
||||
if err != nil {
|
||||
return &StartupError{Operation: "model proxy", Err: err}
|
||||
}
|
||||
// The model SDK builds its clients on the default transport and takes
|
||||
// no client of its own, so the process-wide default is the seam.
|
||||
http.DefaultTransport = transport
|
||||
}
|
||||
dependencies.markSafe(ctx, workDir, log)
|
||||
|
||||
// The task is known before connecting: without a broker token the
|
||||
@@ -125,6 +150,7 @@ func run(ctx context.Context, settings Settings, log *slog.Logger, dependencies
|
||||
TaskID: taskID,
|
||||
StateStoreURL: settings.StateStoreTarget,
|
||||
StateStoreToken: settings.StateStoreToken,
|
||||
StateStoreCA: settings.StateStoreCA,
|
||||
}, log)
|
||||
if err != nil {
|
||||
operation := "nats connect failed"
|
||||
@@ -148,6 +174,13 @@ func run(ctx context.Context, settings Settings, log *slog.Logger, dependencies
|
||||
}
|
||||
}()
|
||||
|
||||
registry := health.NewRegistry(readiness.NewContractProbe("nats", 0, func(context.Context) error {
|
||||
if !transport.BrokerReady() {
|
||||
return errors.New("broker disconnected")
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
go presence.Run(ctx, presence.Agent, presence.Build{InstanceID: strconv.FormatInt(taskID, 10), Version: Version(), InstallType: installtype.Type()}, transport, registry, log)
|
||||
log.Info("archie-agent ready", "nats", settings.NATSURL)
|
||||
dependencies.wait(ctx, log)
|
||||
return nil
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/alert"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/alertwebhook"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
)
|
||||
|
||||
const (
|
||||
// deliveryInterval is how often due webhook deliveries are claimed.
|
||||
deliveryInterval = 15 * time.Second
|
||||
// releaseCheckInterval is how often GitHub is asked for a newer release.
|
||||
releaseCheckInterval = 6 * time.Hour
|
||||
// alertCallTimeout bounds one check's calls to the State Store.
|
||||
alertCallTimeout = 20 * time.Second
|
||||
// credentialReportEvery is how long an unchanged credential state goes
|
||||
// unreported, so the egress path does not call the State Store per request.
|
||||
credentialReportEvery = 10 * time.Minute
|
||||
)
|
||||
|
||||
// alertChecks raises the alerts that have no transition to hang on: the
|
||||
// daemon's configuration and the release channel. Each check lists what it
|
||||
// owns, so alerts from before a restart are still cleared once fixed.
|
||||
type alertChecks struct {
|
||||
store alert.Store
|
||||
log func(msg string, args ...any)
|
||||
cfg func() config.Config
|
||||
// catalog is the models the providers currently offer.
|
||||
catalog func() modelcatalog.Snapshot
|
||||
// release is the newest release the update channel offers.
|
||||
release func(context.Context) (releaseupdate.Snapshot, error)
|
||||
}
|
||||
|
||||
func (c alertChecks) reporter() alert.Reporter {
|
||||
return alert.Reporter{Raiser: c.store, By: "archied"}
|
||||
}
|
||||
|
||||
// sync makes the open alerts of kind in orgID match active: it raises each
|
||||
// input and resolves the alerts, snoozed or open, whose condition cleared.
|
||||
func (c alertChecks) sync(ctx context.Context, orgID org.OrgID, kind string, active []alert.Input) {
|
||||
reporter := c.reporter()
|
||||
subjects := make([]string, 0, len(active))
|
||||
for _, in := range active {
|
||||
reporter.Raise(ctx, in)
|
||||
subjects = append(subjects, in.Subject)
|
||||
}
|
||||
existing, err := c.store.ListAlerts(ctx, orgID, alert.Filter{States: []alert.State{alert.StateOpen, alert.StateDismissed}, Limit: 500})
|
||||
if err != nil {
|
||||
c.log("alerts not checked", "kind", kind, "err", err)
|
||||
return
|
||||
}
|
||||
for _, a := range existing {
|
||||
if a.Kind == kind && a.Condition && !slices.Contains(subjects, a.Subject) {
|
||||
reporter.Resolve(ctx, a.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// checkConfig raises the alerts the effective configuration implies: a
|
||||
// missing or dangling model alias, and providers and granted services with no
|
||||
// usable credential.
|
||||
func (c alertChecks) checkConfig(ctx context.Context) {
|
||||
cfg := c.cfg()
|
||||
c.sync(ctx, org.DefaultOrgID, alert.KindModelAlias, modelAliasAlerts(cfg.Models, c.catalog()))
|
||||
c.sync(ctx, org.DefaultOrgID, alert.KindProviderNoKey, providerAlerts(cfg.Providers))
|
||||
unbound := unboundAlerts(cfg)
|
||||
for _, orgID := range credentialOrgs(cfg) {
|
||||
c.sync(ctx, orgID, alert.KindToolNoBinding, unbound[orgID])
|
||||
}
|
||||
}
|
||||
|
||||
func modelAliasAlerts(aliases map[string]string, catalog modelcatalog.Snapshot) []alert.Input {
|
||||
var out []alert.Input
|
||||
input := func(alias, title, body string) alert.Input {
|
||||
return alert.Input{
|
||||
Org: org.DefaultOrgID, Kind: alert.KindModelAlias, Subject: "alias:" + alias,
|
||||
Severity: alert.SeverityAction, Condition: true, Title: title, Body: body, Link: "/settings/models",
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(aliases[config.DefaultModelAlias]) == "" {
|
||||
out = append(out, input(config.DefaultModelAlias, "No default model alias is set",
|
||||
"Set it to a model."))
|
||||
}
|
||||
for _, alias := range slices.Sorted(maps.Keys(aliases)) {
|
||||
providerID, modelID, ok := strings.Cut(aliases[alias], "/")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
offered := catalogModels(catalog, providerID)
|
||||
// A provider the catalogue does not list is a credential problem, not
|
||||
// a retired model.
|
||||
if len(offered) > 0 && !slices.Contains(offered, modelID) {
|
||||
out = append(out, input(alias, fmt.Sprintf("Model alias %q points at a model that no longer exists", alias),
|
||||
fmt.Sprintf("The %s provider no longer offers the model this alias names. Choose another model.", providerID)))
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func catalogModels(catalog modelcatalog.Snapshot, providerID string) []string {
|
||||
for _, provider := range catalog.Providers {
|
||||
if provider.ID == providerID {
|
||||
ids := make([]string, len(provider.Models))
|
||||
for i, model := range provider.Models {
|
||||
ids[i] = model.ID
|
||||
}
|
||||
return ids
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func providerAlerts(providers map[string]config.Provider) []alert.Input {
|
||||
var out []alert.Input
|
||||
for _, name := range slices.Sorted(maps.Keys(providers)) {
|
||||
if !providers[name].Disabled {
|
||||
continue
|
||||
}
|
||||
out = append(out, alert.Input{
|
||||
Org: org.DefaultOrgID, Kind: alert.KindProviderNoKey, Subject: "provider:" + name,
|
||||
Severity: alert.SeverityAction, Condition: true,
|
||||
Title: fmt.Sprintf("Provider %q has no usable credential", name),
|
||||
Body: "Key unresolved; its models cannot run. Check the binding.",
|
||||
Link: "/settings/credential-bindings",
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// credentialOrgs are the orgs whose identities are granted credentials, the
|
||||
// instance org always among them.
|
||||
func credentialOrgs(cfg config.Config) []org.OrgID {
|
||||
orgs := []org.OrgID{org.DefaultOrgID}
|
||||
for _, name := range append([]string{""}, identityNames(cfg)...) {
|
||||
orgName, _ := cfg.CredentialAccess(name)
|
||||
if id := org.OrgID(credentialOrg(orgName)); !slices.Contains(orgs, id) {
|
||||
orgs = append(orgs, id)
|
||||
}
|
||||
}
|
||||
return orgs
|
||||
}
|
||||
|
||||
func identityNames(cfg config.Config) []string {
|
||||
names := make([]string, 0, len(cfg.Identities))
|
||||
for _, id := range cfg.Identities {
|
||||
names = append(names, id.Name)
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
func credentialOrg(name string) string {
|
||||
if name == "" {
|
||||
return string(org.DefaultOrgID)
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// unboundAlerts are the granted services with no credential binding in the
|
||||
// granting identity's org, by org. A model provider needs no binding of its
|
||||
// own here: its key is the provider's.
|
||||
func unboundAlerts(cfg config.Config) map[org.OrgID][]alert.Input {
|
||||
out := map[org.OrgID][]alert.Input{}
|
||||
seen := map[alert.Key]bool{}
|
||||
for _, name := range append([]string{""}, identityNames(cfg)...) {
|
||||
orgName, granted := cfg.CredentialAccess(name)
|
||||
orgID := org.OrgID(credentialOrg(orgName))
|
||||
bound := cfg.Containers.BoundCredentials(orgName, granted, granted)
|
||||
for _, service := range granted {
|
||||
key := alert.Key{Org: orgID, Kind: alert.KindToolNoBinding, Subject: "service:" + service}
|
||||
if _, ok := cfg.Providers[service]; ok || bound[service].Service != "" || seen[key] {
|
||||
continue
|
||||
}
|
||||
seen[key] = true
|
||||
out[orgID] = append(out[orgID], alert.Input{
|
||||
Key: key, Severity: alert.SeverityAction, Condition: true,
|
||||
Title: fmt.Sprintf("%q is granted but has no credential binding", service),
|
||||
Body: "Runs cannot authenticate. Bind a credential.",
|
||||
Link: "/settings/credential-bindings",
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// checkRelease raises an info alert while the update channel offers a newer
|
||||
// release. A failed check changes nothing: the next one decides.
|
||||
func (c alertChecks) checkRelease(ctx context.Context) {
|
||||
snapshot, err := c.release(ctx)
|
||||
if err != nil {
|
||||
c.log("release check failed", "err", err)
|
||||
return
|
||||
}
|
||||
var active []alert.Input
|
||||
if available := snapshot.Available(); len(available) > 0 {
|
||||
parts := make([]string, len(available))
|
||||
for i, component := range available {
|
||||
parts[i] = fmt.Sprintf("%s %s", component.Label, component.Available)
|
||||
}
|
||||
active = append(active, alert.Input{
|
||||
Org: org.DefaultOrgID, Kind: alert.KindReleaseAvailable, Subject: "release",
|
||||
Severity: alert.SeverityInfo, Condition: true,
|
||||
Title: "Newer release available", Body: "Available: " + strings.Join(parts, ", ") + ".",
|
||||
Link: "/settings/status",
|
||||
})
|
||||
}
|
||||
c.sync(ctx, org.DefaultOrgID, alert.KindReleaseAvailable, active)
|
||||
}
|
||||
|
||||
// every runs fn now and then each interval until ctx ends.
|
||||
func every(ctx context.Context, interval time.Duration, fn func(context.Context)) {
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
callCtx, cancel := context.WithTimeout(ctx, alertCallTimeout)
|
||||
fn(callCtx)
|
||||
cancel()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// startAlerts starts the daemon's alert checks and the webhook delivery loop.
|
||||
// The State Store being away costs the checks a tick, nothing else.
|
||||
func (b *boot) startAlerts(ctx context.Context) {
|
||||
client, ok := b.stateStore.(alert.Store)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
reader := controlplanerpc.NewRPCClient(b.controlPlaneRPC)
|
||||
catalog := controlplanerpc.UpdateService(reader, "").Catalog
|
||||
checks := alertChecks{
|
||||
store: client, log: b.log.Warn, cfg: b.cfgHolder.Get, catalog: b.catalogState,
|
||||
release: func(ctx context.Context) (releaseupdate.Snapshot, error) { return catalog.Check(ctx) },
|
||||
}
|
||||
b.alertChecks = &checks
|
||||
go every(ctx, releaseCheckInterval, checks.checkRelease)
|
||||
go every(ctx, deliveryInterval, b.deliverAlerts(client))
|
||||
checks.checkConfig(ctx)
|
||||
}
|
||||
|
||||
// recheckAlerts re-evaluates the configuration alerts after the configuration
|
||||
// changed. It never blocks the change that caused it.
|
||||
func (b *boot) recheckAlerts(ctx context.Context) {
|
||||
checks := b.alertChecks
|
||||
if checks == nil {
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), alertCallTimeout)
|
||||
defer cancel()
|
||||
checks.checkConfig(ctx)
|
||||
}()
|
||||
}
|
||||
|
||||
// deliverAlerts sends due webhook deliveries. A delivery the webhook is not
|
||||
// configured for, or whose alert is below the severity threshold, is closed
|
||||
// as skipped; one that fails is retried by the store on its schedule.
|
||||
func (b *boot) deliverAlerts(store alert.Deliverer) func(context.Context) {
|
||||
client := &http.Client{Timeout: 15 * time.Second}
|
||||
return func(ctx context.Context) {
|
||||
due, err := store.ClaimAlertDeliveries(ctx, 20)
|
||||
if err != nil {
|
||||
b.log.Warn("alert deliveries not claimed", "err", err)
|
||||
return
|
||||
}
|
||||
notify := b.cfgHolder.Get().Notify
|
||||
for _, d := range due {
|
||||
outcome := alert.Outcome{DeliveryID: d.ID}
|
||||
threshold := alert.Severity(notify.MinSeverity)
|
||||
if !threshold.Valid() {
|
||||
threshold = alert.SeverityWarning
|
||||
}
|
||||
if notify.Webhook == "" || d.Alert.Severity.Rank() < threshold.Rank() {
|
||||
outcome.Skipped = true
|
||||
} else {
|
||||
secret := ""
|
||||
if notify.Secret != (config.SecretRef{}) {
|
||||
secret, err = b.secrets.Resolve(notify.Secret)
|
||||
}
|
||||
if err != nil {
|
||||
outcome.Error = "notify secret could not be resolved"
|
||||
} else {
|
||||
outcome = alertwebhook.Send(ctx, client, notify.Webhook, secret, d)
|
||||
}
|
||||
}
|
||||
if err := store.RecordAlertAttempt(ctx, outcome); err != nil {
|
||||
b.log.Warn("alert delivery not recorded", "delivery", d.ID, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// credentialWatch raises an alert when a bound credential cannot be resolved
|
||||
// and clears it once it can. The egress path calls observe per request, so an
|
||||
// unchanged state is reported at most every credentialReportEvery.
|
||||
type credentialWatch struct {
|
||||
reporter alert.Reporter
|
||||
mu sync.Mutex
|
||||
last map[alert.Key]credentialState
|
||||
}
|
||||
|
||||
type credentialState struct {
|
||||
rejected bool
|
||||
at time.Time
|
||||
}
|
||||
|
||||
func (w *credentialWatch) observe(ctx context.Context, orgName, service string, rejected bool) {
|
||||
if w == nil {
|
||||
return
|
||||
}
|
||||
key := alert.Key{Org: org.OrgID(credentialOrg(orgName)), Kind: alert.KindCredentialInvalid, Subject: "service:" + service}
|
||||
w.mu.Lock()
|
||||
if w.last == nil {
|
||||
w.last = map[alert.Key]credentialState{}
|
||||
}
|
||||
previous, known := w.last[key]
|
||||
if known && previous.rejected == rejected && time.Since(previous.at) < credentialReportEvery {
|
||||
w.mu.Unlock()
|
||||
return
|
||||
}
|
||||
w.last[key] = credentialState{rejected: rejected, at: time.Now()}
|
||||
w.mu.Unlock()
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), alertCallTimeout)
|
||||
defer cancel()
|
||||
w.reporter.Sync(ctx, rejected, alert.Input{
|
||||
Key: key, Severity: alert.SeverityAction, Condition: true,
|
||||
Title: fmt.Sprintf("The credential bound to %q is not working", service),
|
||||
Body: "Secret unresolved; runs cannot authenticate. Check the binding.",
|
||||
Link: "/settings/credential-bindings",
|
||||
})
|
||||
}()
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/daemon"
|
||||
"github.com/samcharles93/archie-core/internal/domain/access"
|
||||
"github.com/samcharles93/archie-core/internal/domain/agent"
|
||||
"github.com/samcharles93/archie-core/internal/domain/alert"
|
||||
"github.com/samcharles93/archie-core/internal/domain/applystatus"
|
||||
"github.com/samcharles93/archie-core/internal/domain/health"
|
||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||
@@ -48,6 +49,8 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/eventbus/nats"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/extension"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/kitrun"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/logrpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
|
||||
@@ -64,9 +67,10 @@ import (
|
||||
// reverse at shutdown, matching the LIFO ordering of the deferred calls
|
||||
// they replace.
|
||||
type boot struct {
|
||||
catalog *modelcatalog.Catalog
|
||||
cfg config.Config
|
||||
log *slog.Logger
|
||||
catalog *modelcatalog.Catalog
|
||||
cfg config.Config
|
||||
log *slog.Logger
|
||||
playbooks *controlplane.LivePlaybooks
|
||||
|
||||
// stderrLog keeps setupLogging on stderr, never touching cfg.Log.File. An
|
||||
// offline command reads the bootstrap config but is not the daemon: creating
|
||||
@@ -94,6 +98,7 @@ type boot struct {
|
||||
// [services.state].target. It is set by openStateStoreAdapter, which
|
||||
// requires [services.state].target to be set.
|
||||
stateStore storecontract.TaskStore
|
||||
taskModels daemon.TaskModels
|
||||
// accessChain is the daemon's policy engine, built once from the stored
|
||||
// policies (openAccessChain); accessProblems is what the readiness
|
||||
// surface reports. Both are nil when no policy store is wired.
|
||||
@@ -103,7 +108,6 @@ type boot struct {
|
||||
// (daemon.RunCredentialIssuer), wrapping the same *staterpc.Client as
|
||||
// stateStore, which also verifies a credential for a worktree push.
|
||||
stateStoreGrants *staterpc.GrantIssuer
|
||||
stateStoreToken string
|
||||
controlPlane *controlplane.Client
|
||||
// controlPlaneRPC is the State Store's control-plane transport, kept so the
|
||||
// daemon root can build its workflow-definitions client from it
|
||||
@@ -158,8 +162,14 @@ type boot struct {
|
||||
containerPool *container.Pool
|
||||
// kitLauncher starts Kit profile tasks; nil when the egress path cannot
|
||||
// be built on this host.
|
||||
kitLauncher daemon.KitLauncher
|
||||
storeBackend storage.Backend
|
||||
kitLauncher *kitrun.Launcher
|
||||
// modelEgress gives native tasks model access through the egress proxy;
|
||||
// nil when the proxy cannot start.
|
||||
modelEgress daemon.ModelEgress
|
||||
// sessionGrants records live setup sessions' granted credential services
|
||||
// for the egress proxy's resolver.
|
||||
sessionGrants *sessionGrants
|
||||
storeBackend storage.Backend
|
||||
|
||||
// runtimeVersions records the version of every control-plane kind boot's
|
||||
// layering applied. Set once at boot before the runtime-resource watches
|
||||
@@ -178,14 +188,6 @@ type boot struct {
|
||||
// schedulingEngine is the cron/scheduling ticker engine (setupScheduling).
|
||||
schedulingEngine *scheduling.Engine
|
||||
|
||||
// kindWorkflows/labelWorkflows are the resolved kind/label -> workflow
|
||||
// routing bindings loaded by loadWorkflowRouting. They are handed to the
|
||||
// daemon so runViaAgent can carry them in taskrun.Request: workflow.Route
|
||||
// runs in the archie-agent process, which never sees the daemon's
|
||||
// package-level workflow state.
|
||||
kindWorkflows workflow.KindWorkflows
|
||||
labelWorkflows workflow.LabelWorkflows
|
||||
|
||||
// agentStatus records the most recent version/install-type an
|
||||
// archie-agent worker reported about itself. Allocated up front, before
|
||||
// any gateway goroutine (Telegram, webui) that might read it via
|
||||
@@ -200,6 +202,13 @@ type boot struct {
|
||||
// signal path rather than inventing a new one.
|
||||
shutdown context.CancelFunc
|
||||
|
||||
// alertChecks re-evaluates the configuration alerts when the configuration
|
||||
// changes. Nil until the daemon's run loop starts them.
|
||||
alertChecks *alertChecks
|
||||
// credentialWatch reports bound credentials that stop resolving. Nil
|
||||
// when the State Store has no alert surface.
|
||||
credentialWatch *credentialWatch
|
||||
|
||||
cleanups []func()
|
||||
}
|
||||
|
||||
@@ -263,17 +272,20 @@ func (b *boot) openStateStoreAdapter(ctx context.Context) error {
|
||||
if target == "" {
|
||||
return fmt.Errorf("services.state.target is required: archied/archie-gateway no longer own archie.db; the standalone archie-state-store process owns it (docs/prds/state-store-contract.md §12 step 7)")
|
||||
}
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Daemon, b.cfg.Services, b.secrets)
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Daemon, b.cfg)
|
||||
if err != nil {
|
||||
b.log.Error("state store adapter", "err", err)
|
||||
return err
|
||||
}
|
||||
b.stateStore = client
|
||||
if alerts, ok := b.stateStore.(alert.Store); ok {
|
||||
b.credentialWatch = &credentialWatch{reporter: alert.Reporter{Raiser: alerts, Log: b.log, By: "archied"}}
|
||||
}
|
||||
b.taskModels = client
|
||||
b.controlPlaneRPC = client.ControlPlane()
|
||||
b.controlPlane = controlplane.NewRPCClient(b.controlPlaneRPC)
|
||||
b.applyStatus = applystatus.New(b.processName, client, b.log)
|
||||
b.stateStoreGrants = &staterpc.GrantIssuer{Client: client}
|
||||
b.stateStoreToken = b.cfg.Services.ResolvedToken(config.ServiceNameState, b.secrets.Getenv)
|
||||
b.addCleanup(cleanup)
|
||||
b.startSecretEngines(ctx, client)
|
||||
return nil
|
||||
@@ -340,7 +352,7 @@ func (b *boot) setupObservability(ctx context.Context) {
|
||||
|
||||
const reactionStreamMaxAge = 24 * time.Hour
|
||||
|
||||
func (b *boot) connectNATS(ctx context.Context) error { //nolint:nestif // embedded broker discovery and startup require explicit fallback branches
|
||||
func (b *boot) connectNATS(ctx context.Context) error { // embedded broker discovery and startup require explicit fallback branches
|
||||
cfg, log := b.cfg, b.log
|
||||
url := cfg.NATS.URL
|
||||
var natsToken string
|
||||
@@ -462,70 +474,25 @@ func (b *boot) setupContainers(ctx context.Context) func() {
|
||||
|
||||
// setupGatewayClient dials the Gateway, which owns every model call. The daemon
|
||||
// only enqueues the chat tasks scheduled workflows create.
|
||||
func (b *boot) setupGatewayClient() error {
|
||||
func (b *boot) setupGatewayClient(ctx context.Context) error {
|
||||
b.setupChatTasks(b.cfg)
|
||||
contract, cleanup, err := composeChatContract(b.cfg.Services, b.secrets)
|
||||
contract, cleanup, err := composeChatContract(b.cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.addCleanup(cleanup)
|
||||
b.chat = &webui.ChatService{Contract: contract}
|
||||
messaging, closeMessaging, err := composeMessaging(b.cfg.Services, b.secrets)
|
||||
messaging, closeMessaging, err := composeMessaging(b.cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.addCleanup(closeMessaging)
|
||||
b.messaging = messaging
|
||||
go postOutcomes(ctx, b.stateStore, messaging.Deliver, b.log)
|
||||
b.setupReadinessProbes()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *boot) loadWorkflows() error {
|
||||
cfg, log := b.cfg, b.log
|
||||
if err := b.loadWorkflowRouting(cfg, log); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Info("workflow step registry built", "shipped_workflows", len(workflow.ShippedDefinitions().Definitions))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *boot) loadWorkflowRouting(cfg config.Config, log *slog.Logger) error {
|
||||
kindWorkflows, err := workflow.LoadKindWorkflowsYAML(cfg.WorkflowRoutingFile)
|
||||
if err != nil {
|
||||
log.Error("workflow routing file load failed", "path", cfg.WorkflowRoutingFile, "err", err)
|
||||
return err
|
||||
}
|
||||
|
||||
labelWorkflows, err := workflow.LoadLabelWorkflowsYAML(cfg.WorkflowLabelsFile)
|
||||
if err != nil {
|
||||
log.Error("workflow labels file load failed", "path", cfg.WorkflowLabelsFile, "err", err)
|
||||
return err
|
||||
}
|
||||
|
||||
dirKindWorkflows, dirLabelWorkflows, err := workflow.LoadPlaybookDirs(cfg.PlaybookDirs)
|
||||
if err != nil {
|
||||
log.Error("playbook dirs load failed", "dirs", cfg.PlaybookDirs, "err", err)
|
||||
return err
|
||||
}
|
||||
kindWorkflows, err = workflow.MergeKindWorkflows(kindWorkflows, dirKindWorkflows)
|
||||
if err != nil {
|
||||
log.Error("workflow binding collision between routing file and playbook dir", "err", err)
|
||||
return err
|
||||
}
|
||||
labelWorkflows, err = workflow.MergeLabelWorkflows(labelWorkflows, dirLabelWorkflows)
|
||||
if err != nil {
|
||||
log.Error("workflow binding collision between labels file and playbook dir", "err", err)
|
||||
return err
|
||||
}
|
||||
|
||||
workflow.SetKindWorkflows(kindWorkflows)
|
||||
workflow.SetLabelWorkflows(labelWorkflows)
|
||||
b.kindWorkflows = kindWorkflows
|
||||
b.labelWorkflows = labelWorkflows
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *boot) buildWorktreeManager() {
|
||||
cfg := b.cfg
|
||||
b.trees = &worktree.Manager{
|
||||
@@ -571,13 +538,18 @@ func (b *boot) registerNATSRPC() error {
|
||||
log.Error("nats connection unavailable for task RPC", "err", err)
|
||||
return err
|
||||
}
|
||||
unsubscribe, err := registerTaskRPCServers(coreConn, b.forgeClient, b.trees, b.identityRunners, b.stateStoreGrants.Client, log)
|
||||
unsubscribe, err := registerTaskRPCServers(coreConn, b.forgeClient, b.trees, b.identityRunners, b.stateStoreGrants.Client, installedAuthorities{b.stateStoreGrants.Client}, log)
|
||||
if err != nil {
|
||||
log.Error("task RPC server registration failed", "err", err)
|
||||
return err
|
||||
}
|
||||
b.addCleanup(unsubscribe)
|
||||
|
||||
stopLogs, err := logrpc.RegisterDaemon(coreConn, b.logFeed, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("register daemon logs: %w", err)
|
||||
}
|
||||
b.addCleanup(stopLogs)
|
||||
unsubscribeSystemLogs, err := subscribeSystemLogs(coreConn, b.taskLogs, log)
|
||||
if err != nil {
|
||||
log.Error("system log subscribe failed", "err", err)
|
||||
@@ -606,11 +578,12 @@ func (b *boot) buildDaemon() {
|
||||
b.d = &daemon.Daemon{
|
||||
Cfg: b.cfgHolder,
|
||||
ConnectedNATS: daemon.NATSEndpoint{URL: b.natsURL, Token: b.natsToken, Scoped: b.cfg.NATS.Mode != config.NATSModeExternal},
|
||||
ConnectedStateStore: daemon.StateStoreEndpoint{URL: strings.TrimSpace(b.cfg.Services.Get(config.ServiceNameState).Target), Token: b.stateStoreToken},
|
||||
ConnectedStateStore: daemon.StateStoreEndpoint{URL: strings.TrimSpace(b.cfg.Services.Get(config.ServiceNameState).Target), CA: b.stateStoreCA()},
|
||||
Store: b.stateStore,
|
||||
Bus: b.bus,
|
||||
Forge: b.forgeClient,
|
||||
Trees: b.trees,
|
||||
PackageAuthorities: installedAuthorities{b.stateStoreGrants.Client},
|
||||
Storage: b.storeBackend,
|
||||
Log: log,
|
||||
Tasks: b.natsClient,
|
||||
@@ -618,15 +591,15 @@ func (b *boot) buildDaemon() {
|
||||
RunCredentials: b.stateStoreGrants,
|
||||
ContainerPool: b.containerPool,
|
||||
KitLauncher: b.kitLauncher,
|
||||
ModelEgress: b.modelEgress,
|
||||
TaskModels: b.taskModels,
|
||||
Identities: b.identityRunners,
|
||||
RootIdentityID: identity.StableID(servicekit.IdentityNames(b.cfg)[0]),
|
||||
TaskLogs: b.taskLogs,
|
||||
AgentStatus: b.agentStatus,
|
||||
KindWorkflows: b.kindWorkflows,
|
||||
LabelWorkflows: b.labelWorkflows,
|
||||
WorkflowDefinitions: b.workflowDefinitions,
|
||||
WorkflowEnablement: b.controlPlane,
|
||||
Playbooks: controlplane.NewLivePlaybooks(b.controlPlaneRPC, b.log),
|
||||
Playbooks: b.livePlaybooks(),
|
||||
}
|
||||
|
||||
if identities, ok := b.stateStore.(identity.Repository); ok {
|
||||
@@ -717,29 +690,16 @@ func (b *boot) publishConfig(ctx context.Context, cfg config.Config) {
|
||||
// The daemon owns the published configuration view.
|
||||
if b.processName != applystatus.Gateway {
|
||||
b.publishConfigSnapshot(ctx)
|
||||
b.recheckAlerts(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *boot) configOrigins() []webui.ConfigOrigin {
|
||||
provenance := b.currentProvenance.Load()
|
||||
if provenance == nil {
|
||||
return nil
|
||||
}
|
||||
origins := make([]webui.ConfigOrigin, 0, len(provenance.Origins))
|
||||
for _, origin := range provenance.Origins {
|
||||
origins = append(origins, webui.ConfigOrigin{
|
||||
Path: origin.Path, Role: string(origin.Role), Layer: string(origin.Layer), Feature: string(origin.Feature),
|
||||
})
|
||||
}
|
||||
return origins
|
||||
}
|
||||
|
||||
func (b *boot) configViewInput() webui.ConfigViewInput {
|
||||
catalog, _ := b.catalogState()
|
||||
catalog := b.catalogState()
|
||||
in := webui.ConfigViewInput{
|
||||
Config: b.cfgHolder.Get(),
|
||||
Provenance: b.configOrigins(),
|
||||
Catalog: catalogView(catalog),
|
||||
Config: b.cfgHolder.Get(),
|
||||
Catalog: catalogView(catalog),
|
||||
SecretEngines: b.secrets.List(),
|
||||
}
|
||||
if b.lastReload != nil {
|
||||
status := b.lastReload()
|
||||
@@ -805,12 +765,14 @@ func (b *boot) startServices(ctx context.Context) error {
|
||||
|
||||
func (b *boot) setupBackends(ctx context.Context) error {
|
||||
closeContainers := b.setupContainers(ctx)
|
||||
// Registered before the Kit launcher so its cleanups (the harness
|
||||
// listener and the egress relay) run first: cleanups unwind LIFO, and a
|
||||
// session teardown needs the Docker client the pool still owns.
|
||||
b.addCleanup(closeContainers)
|
||||
err := b.connectNATS(ctx)
|
||||
if err == nil {
|
||||
b.setupKitLauncher(ctx)
|
||||
}
|
||||
|
||||
b.addCleanup(closeContainers)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -826,11 +788,16 @@ func (b *boot) runLoop(ctx context.Context, once bool) error {
|
||||
b.announceReady()
|
||||
if once {
|
||||
b.d.Cycle(ctx)
|
||||
// A drain pass no longer waits for the tasks it submitted, so a
|
||||
// single-cycle invocation waits for them here: exiting while their
|
||||
// containers still run would kill work this pass accepted.
|
||||
b.d.WaitForTasks()
|
||||
return nil
|
||||
}
|
||||
b.log.Info("archied running", "repos", len(b.cfg.Repos), "poll", b.cfg.PollInterval.Std().String(), "label", b.cfg.Label)
|
||||
b.startDrainMonitor(ctx)
|
||||
b.startWatchdog(ctx)
|
||||
b.startAlerts(ctx)
|
||||
if err := b.d.Run(ctx); err != nil && ctx.Err() == nil {
|
||||
b.log.Error("daemon exited", "err", err)
|
||||
return err
|
||||
@@ -854,7 +821,7 @@ func (b *boot) addCleanup(fn func()) {
|
||||
b.cleanups = append(b.cleanups, fn)
|
||||
}
|
||||
|
||||
func (b *boot) catalogState() (modelcatalog.Snapshot, []string) { return b.catalog.State() }
|
||||
func (b *boot) catalogState() modelcatalog.Snapshot { return b.catalog.State() }
|
||||
|
||||
// loadCatalog layers the model catalog under the file config. A catalog that
|
||||
// cannot be read leaves the configured providers and models in effect.
|
||||
@@ -866,7 +833,7 @@ func (b *boot) loadCatalog(ctx context.Context) {
|
||||
}
|
||||
models := modelcatalog.Apply(&b.cfg, snapshot)
|
||||
b.cfgHolder.Set(b.cfg.Clone())
|
||||
b.catalog.Set(snapshot, models)
|
||||
b.catalog.Set(snapshot)
|
||||
b.log.Info("model catalog loaded", "providers", len(snapshot.Providers), "models", len(models))
|
||||
}
|
||||
|
||||
@@ -881,7 +848,7 @@ func (b *boot) refreshModelCatalog(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.catalog.Set(snapshot, models)
|
||||
b.catalog.Set(snapshot)
|
||||
b.publishConfig(ctx, cfg)
|
||||
b.log.Info("model catalog refreshed", "providers", len(snapshot.Providers), "models", len(models))
|
||||
return nil
|
||||
@@ -894,3 +861,24 @@ func (b *boot) startModelCatalogRefresh(ctx context.Context) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (b *boot) livePlaybooks() *controlplane.LivePlaybooks {
|
||||
b.playbooks = controlplane.NewLivePlaybooks(b.controlPlaneRPC, b.log)
|
||||
b.playbooks.ApplyStatus = b.applyStatus
|
||||
return b.playbooks
|
||||
}
|
||||
|
||||
// playbookRefreshInterval is how often archied re-reads the resources it
|
||||
// would otherwise load only on first use, so their apply status stays reported.
|
||||
const playbookRefreshInterval = 30 * time.Second
|
||||
|
||||
// stateStoreCA is the CA a task container verifies the State Store with;
|
||||
// nil without [tls].
|
||||
func (b *boot) stateStoreCA() []byte {
|
||||
id, err := servicekit.Identity(b.cfg.TLS, presence.Daemon)
|
||||
if err != nil {
|
||||
b.log.Warn("state store CA for containers", "err", err)
|
||||
return nil
|
||||
}
|
||||
return id.CAPEM()
|
||||
}
|
||||
@@ -3,27 +3,29 @@ package archied
|
||||
import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
|
||||
// composeChatContract dials the standalone archie-gateway, the sole owner of
|
||||
// ChatContract, from the daemon's own configuration key. Token resolution is
|
||||
// the daemon's (it owns the config keys and the secret registry); the dial
|
||||
// itself and the fail-closed non-loopback rule belong to the transport, so
|
||||
// they come from gatewayrpc.Dial.
|
||||
func composeChatContract(services config.Services, secrets *secret.Registry, options ...grpc.DialOption) (gateway.ChatContract, func(), error) {
|
||||
target, err := services.RequireTarget(config.ServiceNameGateway)
|
||||
// ChatContract, from the daemon's own configuration key.
|
||||
func composeChatContract(cfg config.Config, options ...grpc.DialOption) (gateway.ChatContract, func(), error) {
|
||||
target, err := cfg.Services.RequireTarget(config.ServiceNameGateway)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
id, err := servicekit.Identity(cfg.TLS, presence.Daemon)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// Assigned through a typed variable rather than returned directly: a
|
||||
// direct forward would hand a failed dial's nil *Client back as a
|
||||
// non-nil ChatContract interface.
|
||||
client, cleanup, err := gatewayrpc.Dial(target, services.ResolvedToken(config.ServiceNameGateway, secrets.Getenv), options...)
|
||||
client, cleanup, err := gatewayrpc.Dial(target, id, options...)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -32,10 +34,14 @@ func composeChatContract(services config.Services, secrets *secret.Registry, opt
|
||||
|
||||
// composeMessaging builds the Messaging Service client. The connection is
|
||||
// lazy, so an absent Messaging Service fails each delivery, not the daemon.
|
||||
func composeMessaging(services config.Services, secrets *secret.Registry) (*messagingrpc.Client, func(), error) {
|
||||
target, err := services.RequireTarget(config.ServiceNameMessaging)
|
||||
func composeMessaging(cfg config.Config) (*messagingrpc.Client, func(), error) {
|
||||
target, err := cfg.Services.RequireTarget(config.ServiceNameMessaging)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return messagingrpc.Dial(target, services.ResolvedToken(config.ServiceNameMessaging, secrets.Getenv))
|
||||
id, err := servicekit.Identity(cfg.TLS, presence.Daemon)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return messagingrpc.Dial(target, id)
|
||||
}
|
||||
@@ -24,7 +24,7 @@ func (b *boot) runtimeConfig(ctx context.Context, base config.Config) (config.Co
|
||||
if settings := b.executionSettings.Load(); settings != nil {
|
||||
applyExecutionBudgets(cfg, *settings)
|
||||
}
|
||||
})
|
||||
}, nil)
|
||||
}
|
||||
|
||||
func (b *boot) loadRuntimeConfig(ctx context.Context) error {
|
||||
@@ -52,7 +52,7 @@ func (b *boot) reloadConfig(ctx context.Context, doc *configuration.Document) er
|
||||
// drop them from the running config even though the file is
|
||||
// unchanged. Re-apply the same merge (idempotent: a catalog that
|
||||
// failed to load merges to identity).
|
||||
catalog, _ := b.catalogState()
|
||||
catalog := b.catalogState()
|
||||
modelcatalog.Apply(&doc.Config, catalog)
|
||||
// Bounded: this runs on the signal loop, which handles nothing else
|
||||
// while it waits, and a State Store that has stopped answering must
|
||||
@@ -63,15 +63,17 @@ func (b *boot) reloadConfig(ctx context.Context, doc *configuration.Document) er
|
||||
if err != nil {
|
||||
return fmt.Errorf("runtime settings unavailable: %w", err)
|
||||
}
|
||||
doc.Config = cfg
|
||||
old := b.cfgHolder.Get()
|
||||
restartFields := changedNonReloadableFields(old, cfg)
|
||||
cfg = preserveForgeIdentity(old, cfg)
|
||||
doc.Config = cfg
|
||||
b.currentProvenance.Store(&doc.Provenance)
|
||||
b.publishConfig(ctx, cfg)
|
||||
// The container pool reads the published config on every acquire, but the
|
||||
// dispatcher holds its limit; a reloaded containers.max_concurrency must
|
||||
// reach it the same way a control-plane update does.
|
||||
b.resizeTaskDispatcher(cfg.Containers.MaxConcurrency)
|
||||
if fields := changedNonReloadableFields(old, cfg); len(fields) > 0 {
|
||||
if fields := restartFields; len(fields) > 0 {
|
||||
b.log.Warn("config reloaded; some changes require a restart",
|
||||
"fields", fields, "paths", doc.Provenance.Paths())
|
||||
} else {
|
||||
@@ -210,9 +212,6 @@ func applyExecutionBudgets(cfg *config.Config, settings workflow.ExecutionSettin
|
||||
MaxSteps: settings.MaxModelToolSteps, WallClock: config.Duration(settings.MaxRuntime), GateMaxFailures: settings.MaxConsecutiveGateFailures,
|
||||
TaskWallClock: config.Duration(settings.MaxTaskRuntime),
|
||||
}
|
||||
for i := range cfg.Identities {
|
||||
cfg.Identities[i].Budgets = cfg.Budgets
|
||||
}
|
||||
}
|
||||
|
||||
// startLiveSettings starts everything a live control-plane update needs
|
||||
@@ -263,8 +262,9 @@ func (b *boot) startLiveSettings(ctx context.Context) error {
|
||||
// restart-required. Each kind is watched in its own goroutine, exactly the
|
||||
// shape the workflow-execution-settings watch established.
|
||||
var runtimeResourceKinds = []string{
|
||||
controlplane.TaskPolicyKind,
|
||||
controlplane.ProviderSettingsKind,
|
||||
controlplane.ModelRoleAssignmentsKind,
|
||||
controlplane.ModelAliasesKind,
|
||||
controlplane.RepositoryPoliciesKind,
|
||||
controlplane.SchedulingPolicyKind,
|
||||
controlplane.ToolSettingsKind,
|
||||
@@ -370,7 +370,7 @@ func (b *boot) applyRuntimeResourceUpdate(ctx context.Context, kind string, upda
|
||||
// this read returns can lack the catalog's model limits and discovered
|
||||
// providers. The merge is idempotent, and reloadConfig re-applies it
|
||||
// before layering for the same reason.
|
||||
catalog, _ := b.catalogState()
|
||||
catalog := b.catalogState()
|
||||
modelcatalog.Apply(&base, catalog)
|
||||
cfg, _, err := b.runtimeConfig(ctx, base)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/container"
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/harness/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/harnesssession"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/kitrun"
|
||||
)
|
||||
|
||||
// setupSessionTTL bounds a setup container's life independently of the pool's
|
||||
// max-uptime reaper: a login that never finishes must not hold a container
|
||||
// until the reaper's (longer) cap.
|
||||
const setupSessionTTL = 30 * time.Minute
|
||||
|
||||
// sessionGrants records the credential services each live setup session is
|
||||
// bound for. A session's proxy token names no task, so the egress proxy's run
|
||||
// resolver consults this registry: without it, the token endpoint is never
|
||||
// intercepted and no OAuth token is ever captured.
|
||||
type sessionGrants struct {
|
||||
mu sync.RWMutex
|
||||
m map[string]sessionGrant
|
||||
}
|
||||
|
||||
type sessionGrant struct {
|
||||
org string
|
||||
services []string
|
||||
}
|
||||
|
||||
func (g *sessionGrants) Grant(token, org string, services []string) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
if g.m == nil {
|
||||
g.m = map[string]sessionGrant{}
|
||||
}
|
||||
g.m[token] = sessionGrant{org: org, services: slices.Clone(services)}
|
||||
}
|
||||
|
||||
func (g *sessionGrants) Revoke(token string) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
delete(g.m, token)
|
||||
}
|
||||
|
||||
// GrantedFor reports the org and granted services a session token carries.
|
||||
func (g *sessionGrants) GrantedFor(token string) (string, []string, bool) {
|
||||
g.mu.RLock()
|
||||
defer g.mu.RUnlock()
|
||||
grant, ok := g.m[token]
|
||||
return grant.org, grant.services, ok
|
||||
}
|
||||
|
||||
// harnessServer serves the daemon's harness session contract.
|
||||
type harnessServer struct {
|
||||
pb.UnimplementedHarnessServiceServer
|
||||
sessions *harnesssession.Manager
|
||||
// runs serves the run target; nil answers Unavailable.
|
||||
runs *runView
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
// Open dispatches on the first frame's target. Setup sessions open a PTY; a run
|
||||
// target is a read-only view of the task's running sandbox.
|
||||
func (h *harnessServer) Open(stream pb.HarnessService_OpenServer) error {
|
||||
first, err := stream.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
target := first.GetTarget()
|
||||
if target == nil || target.GetOrg() == "" {
|
||||
return status.Error(codes.InvalidArgument, "the first frame must name a session target with an org")
|
||||
}
|
||||
switch t := target.GetTarget().(type) {
|
||||
case *pb.OpenTarget_Setup:
|
||||
if t.Setup.GetProfile() == "" {
|
||||
return status.Error(codes.InvalidArgument, "the setup target names no profile")
|
||||
}
|
||||
return h.openSetup(stream, target.GetOrg(), t.Setup.GetProfile(), first.GetSize())
|
||||
case *pb.OpenTarget_Run:
|
||||
if t.Run.GetTaskId() <= 0 {
|
||||
return status.Error(codes.InvalidArgument, "the run target names no task")
|
||||
}
|
||||
return h.openRun(stream, target.GetOrg(), t.Run)
|
||||
default:
|
||||
return status.Error(codes.InvalidArgument, "the target names no session")
|
||||
}
|
||||
}
|
||||
|
||||
// openSetup opens one setup session and pumps frames until the shell exits or
|
||||
// either side closes. Teardown runs on every return.
|
||||
func (h *harnessServer) openSetup(stream pb.HarnessService_OpenServer, org, profile string, size *pb.ConsoleSize) error {
|
||||
session, err := h.sessions.Open(stream.Context(), org, profile, int(size.GetRows()), int(size.GetCols()))
|
||||
if err != nil {
|
||||
h.log.Warn("setup session failed to open", "org", org, "profile", profile, "err", err)
|
||||
// The failure rides the stream as a frame, not only as a status: the
|
||||
// dashboard's terminal shows the frame's text, which is the operator's
|
||||
// only honest account of why the session did not open.
|
||||
return stream.Send(&pb.OpenResponse{Frame: &pb.OpenResponse_Error{Error: err.Error()}})
|
||||
}
|
||||
defer func() {
|
||||
_ = session.Close()
|
||||
h.log.Info("setup session closed", "org", org, "profile", profile)
|
||||
}()
|
||||
h.log.Info("setup session opened", "org", org, "profile", profile)
|
||||
|
||||
output := make(chan error, 1)
|
||||
go func() { output <- h.pumpOutput(stream, session) }()
|
||||
|
||||
input := make(chan error, 1)
|
||||
go func() { input <- h.pumpInput(stream, session) }()
|
||||
|
||||
select {
|
||||
case err := <-output:
|
||||
if err != nil {
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
code, codeErr := session.ExitCode(context.WithoutCancel(stream.Context()))
|
||||
if codeErr != nil {
|
||||
return nil
|
||||
}
|
||||
return stream.Send(&pb.OpenResponse{Frame: &pb.OpenResponse_ExitCode{ExitCode: int32(code)}})
|
||||
case err := <-input:
|
||||
if errors.Is(err, io.EOF) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// pumpOutput copies terminal output to the stream until the shell ends.
|
||||
func (h *harnessServer) pumpOutput(stream pb.HarnessService_OpenServer, session *harnesssession.Session) error {
|
||||
buf := make([]byte, 32<<10)
|
||||
for {
|
||||
n, err := session.Read(buf)
|
||||
if n > 0 {
|
||||
frame := &pb.OpenResponse{Frame: &pb.OpenResponse_Stdout{Stdout: slices.Clone(buf[:n])}}
|
||||
if sendErr := stream.Send(frame); sendErr != nil {
|
||||
return sendErr
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pumpInput copies client frames to the session until the client closes.
|
||||
func (h *harnessServer) pumpInput(stream pb.HarnessService_OpenServer, session *harnesssession.Session) error {
|
||||
for {
|
||||
req, err := stream.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if stdin, ok := req.GetFrame().(*pb.OpenRequest_Stdin); ok {
|
||||
if _, err := session.Write(stdin.Stdin); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// setupHarness serves the harness session contract on the configured listen
|
||||
// address. It is skipped, with the reason logged, when no service token is
|
||||
// configured: a session is a shell in a container that holds an org's
|
||||
// credential, so the token is required even on loopback.
|
||||
func (b *boot) setupHarness(ctx context.Context) {
|
||||
conn := b.cfg.Services.Get(config.ServiceNameHarness)
|
||||
listen, err := servicekit.ResolveListen(config.ServiceNameHarness, "", conn.Listen)
|
||||
if err != nil {
|
||||
b.log.Warn("harness sessions disabled", "err", err)
|
||||
return
|
||||
}
|
||||
id, err := servicekit.Identity(b.cfg.TLS, presence.Daemon)
|
||||
if err != nil {
|
||||
b.log.Warn("harness sessions disabled", "err", err)
|
||||
return
|
||||
}
|
||||
if id == nil {
|
||||
b.log.Warn("harness sessions disabled: a session is a shell holding an org's credential, so it needs [tls] ca_file and cert_dir")
|
||||
return
|
||||
}
|
||||
creds, err := id.ServerOption(listen, false)
|
||||
if err != nil {
|
||||
b.log.Warn("harness sessions disabled", "err", err)
|
||||
return
|
||||
}
|
||||
ln, err := (&net.ListenConfig{}).Listen(ctx, "tcp", listen)
|
||||
if err != nil {
|
||||
b.log.Warn("harness sessions disabled: listen", "err", err)
|
||||
return
|
||||
}
|
||||
manager := &harnesssession.Manager{
|
||||
Launcher: b.kitLauncher,
|
||||
Client: b.containerPool.Client(),
|
||||
Profile: func(name string) (config.AgentProfile, error) { return b.cfgHolder.Get().Containers.Profile(name) },
|
||||
TTL: setupSessionTTL,
|
||||
}
|
||||
srv := grpc.NewServer(append(servicekit.ServerLimits(), creds)...)
|
||||
pb.RegisterHarnessServiceServer(srv, &harnessServer{sessions: manager, runs: b.runView(), log: b.log})
|
||||
go func() {
|
||||
if err := srv.Serve(ln); err != nil && !errors.Is(err, grpc.ErrServerStopped) {
|
||||
b.log.Error("harness listener stopped", "err", err)
|
||||
}
|
||||
}()
|
||||
b.addCleanup(func() {
|
||||
// An open session stream would hold GracefulStop until its TTL; give
|
||||
// in-flight frames a moment, then stop. Mirrors the State Store's
|
||||
// shutdown so a session cannot hold shutdown to the watchdog leash.
|
||||
timer := time.AfterFunc(10*time.Second, srv.Stop)
|
||||
srv.GracefulStop()
|
||||
timer.Stop()
|
||||
_ = ln.Close()
|
||||
})
|
||||
b.log.Info("harness sessions enabled", "addr", ln.Addr().String())
|
||||
}
|
||||
|
||||
var _ kitrun.GrantRegistry = (*sessionGrants)(nil)
|
||||
|
||||
// runView wires the run target to the task store and the container pool. The
|
||||
// store is the daemon's own contract client, so a task it cannot read answers
|
||||
// Unavailable rather than guessing.
|
||||
func (b *boot) runView() *runView {
|
||||
if b.stateStore == nil || b.containerPool == nil {
|
||||
return nil
|
||||
}
|
||||
cli := b.containerPool.Client()
|
||||
return &runView{
|
||||
tasks: b.stateStore,
|
||||
follow: func(ctx context.Context, taskID, attempt int64) (io.ReadCloser, error) {
|
||||
return container.FollowLogs(ctx, cli, kitrun.TaskContainer(taskID, attempt), runTail)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/containerd/errdefs"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/container"
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/harness/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
)
|
||||
|
||||
// runTail is how much recent output a view opens with, in lines.
|
||||
const runTail = 200
|
||||
|
||||
// taskLookup reads the task a run target names.
|
||||
type taskLookup interface {
|
||||
TaskByID(ctx context.Context, id int64) (*workflow.Task, error)
|
||||
}
|
||||
|
||||
// runView resolves a run target to its container and follows its output. It
|
||||
// is read-only by construction: it holds no exec and no stdin path, so a view
|
||||
// confers no authority over the container.
|
||||
type runView struct {
|
||||
tasks taskLookup
|
||||
follow func(ctx context.Context, taskID, attempt int64) (io.ReadCloser, error)
|
||||
}
|
||||
|
||||
// open refuses a task the daemon does not know, one that is not running, and
|
||||
// an attempt that is not the running one. Each refusal states its reason: the
|
||||
// container is gone with the attempt, so there is nothing to answer
|
||||
// "unavailable" about.
|
||||
func (v *runView) open(ctx context.Context, target *pb.RunTarget) (io.ReadCloser, error) {
|
||||
t, err := v.tasks.TaskByID(ctx, target.GetTaskId())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Unavailable, "the task store is unavailable: "+err.Error())
|
||||
}
|
||||
switch {
|
||||
case t == nil || t.OrgOrDefault() != string(org.OrgFromContext(ctx)):
|
||||
return nil, status.Errorf(codes.NotFound, "task %d is unknown", target.GetTaskId())
|
||||
case t.Status != workflow.StatusRunning:
|
||||
return nil, status.Errorf(codes.NotFound, "task %d is %s, not running; its sandbox is gone", t.ID, t.Status)
|
||||
case int64(t.Attempt) != target.GetAttempt():
|
||||
return nil, status.Errorf(codes.NotFound, "attempt %d is not running; task %d is on attempt %d", target.GetAttempt(), t.ID, t.Attempt)
|
||||
}
|
||||
logs, err := v.follow(ctx, t.ID, target.GetAttempt())
|
||||
if err != nil {
|
||||
if errdefs.IsNotFound(err) || errors.Is(err, container.ErrNotRunning) {
|
||||
return nil, status.Errorf(codes.NotFound, "task %d has no running sandbox: %v", t.ID, err)
|
||||
}
|
||||
return nil, status.Errorf(codes.Unavailable, "the sandbox view is unavailable: %v", err)
|
||||
}
|
||||
return logs, nil
|
||||
}
|
||||
|
||||
// openRun streams a running task's sandbox output until the task's container
|
||||
// ends or the client leaves. Client frames are ignored: this is the peek, not
|
||||
// a takeover.
|
||||
func (h *harnessServer) openRun(stream pb.HarnessService_OpenServer, orgID string, target *pb.RunTarget) error {
|
||||
if h.runs == nil {
|
||||
return status.Error(codes.Unavailable, "run-scoped views need the task store and the container pool")
|
||||
}
|
||||
logs, err := h.runs.open(org.WithOrg(stream.Context(), org.OrgID(orgID)), target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = logs.Close() }()
|
||||
// An empty frame tells the client the view opened before the sandbox has
|
||||
// printed anything.
|
||||
if err := stream.Send(&pb.OpenResponse{Frame: &pb.OpenResponse_Stdout{}}); err != nil {
|
||||
return err
|
||||
}
|
||||
h.log.Info("run view opened", "task", target.GetTaskId(), "attempt", target.GetAttempt())
|
||||
defer h.log.Info("run view closed", "task", target.GetTaskId(), "attempt", target.GetAttempt())
|
||||
|
||||
buf := make([]byte, 32<<10)
|
||||
for {
|
||||
n, err := logs.Read(buf)
|
||||
if n > 0 {
|
||||
if sendErr := stream.Send(&pb.OpenResponse{Frame: &pb.OpenResponse_Stdout{Stdout: append([]byte(nil), buf[:n]...)}}); sendErr != nil {
|
||||
return sendErr
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err == io.EOF || stream.Context().Err() != nil {
|
||||
return nil
|
||||
}
|
||||
return status.Error(codes.Unavailable, fmt.Sprintf("the sandbox output ended: %v", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/errdefs"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/harness/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
)
|
||||
|
||||
type fakeTasks struct {
|
||||
task *workflow.Task
|
||||
err error
|
||||
}
|
||||
|
||||
func (f fakeTasks) TaskByID(context.Context, int64) (*workflow.Task, error) { return f.task, f.err }
|
||||
|
||||
func TestRunViewOpen(t *testing.T) {
|
||||
running := &workflow.Task{ID: 7, Status: workflow.StatusRunning, Attempt: 2}
|
||||
cases := []struct {
|
||||
name string
|
||||
tasks fakeTasks
|
||||
attempt int64
|
||||
follow error
|
||||
code codes.Code
|
||||
reason string
|
||||
}{
|
||||
{"running attempt", fakeTasks{task: running}, 2, nil, codes.OK, ""},
|
||||
{"unknown task", fakeTasks{}, 2, nil, codes.NotFound, "unknown"},
|
||||
{"finished task", fakeTasks{task: &workflow.Task{ID: 7, Status: workflow.StatusParked, Attempt: 2}}, 2, nil, codes.NotFound, "not running"},
|
||||
{"earlier attempt", fakeTasks{task: running}, 1, nil, codes.NotFound, "attempt 1 is not running"},
|
||||
{"container gone", fakeTasks{task: running}, 2, errdefs.ErrNotFound, codes.NotFound, "no running sandbox"},
|
||||
{"store down", fakeTasks{err: errors.New("dial")}, 2, nil, codes.Unavailable, "unavailable"},
|
||||
{"other org", fakeTasks{task: &workflow.Task{ID: 7, Org: "other", Status: workflow.StatusRunning, Attempt: 2}}, 2, nil, codes.NotFound, "unknown"},
|
||||
{"docker down", fakeTasks{task: running}, 2, errors.New("connection refused"), codes.Unavailable, "unavailable"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
v := &runView{tasks: tc.tasks, follow: func(context.Context, int64, int64) (io.ReadCloser, error) {
|
||||
if tc.follow != nil {
|
||||
return nil, tc.follow
|
||||
}
|
||||
return io.NopCloser(strings.NewReader("")), nil
|
||||
}}
|
||||
rc, err := v.open(org.WithOrg(t.Context(), org.DefaultOrgID), &pb.RunTarget{TaskId: 7, Attempt: tc.attempt})
|
||||
if got := status.Code(err); got != tc.code {
|
||||
t.Fatalf("code = %v (%v), want %v", got, err, tc.code)
|
||||
}
|
||||
if err != nil && !strings.Contains(err.Error(), tc.reason) {
|
||||
t.Fatalf("reason %q does not state %q", err, tc.reason)
|
||||
}
|
||||
if rc != nil {
|
||||
_ = rc.Close()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/storepkg"
|
||||
)
|
||||
|
||||
// installedAuthorities answers a package's accepted authority from the State
|
||||
// Store. A package the operator has not accepted has none.
|
||||
type installedAuthorities struct {
|
||||
packages storepkg.Installations
|
||||
}
|
||||
|
||||
func (a installedAuthorities) AcceptedAuthority(ctx context.Context, name string) (storepkg.Authority, error) {
|
||||
installed, err := a.packages.GetInstalled(ctx, name)
|
||||
if err != nil || installed.AcceptedAuthority == nil {
|
||||
return storepkg.Authority{}, err
|
||||
}
|
||||
return *installed.AcceptedAuthority, nil
|
||||
}
|
||||
@@ -42,11 +42,6 @@ func (b *boot) setupKitLauncher(ctx context.Context) {
|
||||
log.Warn("kit harness runs disabled: egress CA", "err", err)
|
||||
return
|
||||
}
|
||||
fetcher, err := fetch.New(fetch.WithDockerCredentials())
|
||||
if err != nil {
|
||||
log.Warn("kit harness runs disabled: kit registry client", "err", err)
|
||||
return
|
||||
}
|
||||
ln, err := (&net.ListenConfig{}).Listen(ctx, "tcp", net.JoinHostPort(pool.HostGateway(), "0"))
|
||||
if err != nil {
|
||||
log.Warn("kit harness runs disabled: egress proxy listener", "err", err)
|
||||
@@ -60,8 +55,10 @@ func (b *boot) setupKitLauncher(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
// The proxy resolves each credential from the run credential the
|
||||
// container logs in with, against the live grants and bindings.
|
||||
resolver := runCredentialResolver{runs: b.stateStoreGrants.Client, config: b.cfgHolder, secrets: b.secrets}
|
||||
// container logs in with, against the live grants and bindings; a setup
|
||||
// session's token resolves through the session grants instead.
|
||||
b.sessionGrants = &sessionGrants{}
|
||||
resolver := runCredentialResolver{runs: b.stateStoreGrants.Client, sessions: b.sessionGrants, models: b.taskModels, config: b.cfgHolder, secrets: b.secrets, credentials: b.credentialWatch}
|
||||
// Without a harness secret store, Register refuses a Kit with a
|
||||
// required OAuth credential.
|
||||
oauthStore, _ := b.stateStore.(egress.OAuthStore)
|
||||
@@ -72,16 +69,28 @@ func (b *boot) setupKitLauncher(ctx context.Context) {
|
||||
log.Error("egress proxy stopped", "err", err)
|
||||
}
|
||||
}()
|
||||
// Native tasks need only the proxy for model access, so it serves them
|
||||
// even when a Kit-only piece below fails.
|
||||
b.modelEgress = modelEgress{proxy: proxy, addr: ln.Addr().String(), caFile: egress.CACertPath(caDir), config: b.cfgHolder}
|
||||
fetcher, err := fetch.New(fetch.WithDockerCredentials())
|
||||
if err != nil {
|
||||
b.addCleanup(func() { _ = srv.Close() })
|
||||
log.Warn("kit harness runs disabled: kit registry client", "err", err)
|
||||
return
|
||||
}
|
||||
networks := egress.NewNetworks(pool.Client(), egress.RelaySpec{
|
||||
Name: relayName, Image: b.cfg.Containers.Image,
|
||||
Entrypoint: []string{"archie-agent"}, Cmd: cmd, Network: pool.NetworkName(),
|
||||
})
|
||||
b.addCleanup(shutdownEgress(networks, srv, log))
|
||||
b.kitLauncher = &kitrun.Launcher{
|
||||
kitLauncher := &kitrun.Launcher{
|
||||
Pool: pool, Fetch: fetcher, Proxy: proxy, Networks: networks,
|
||||
AgentBinary: agentBinary, CAFile: egress.CACertPath(caDir),
|
||||
Config: b.cfgHolder, Secrets: b.secrets, OAuth: oauthStore,
|
||||
Grants: b.sessionGrants,
|
||||
}
|
||||
b.kitLauncher = kitLauncher
|
||||
b.setupHarness(ctx)
|
||||
log.Info("kit harness runs enabled", "proxy", ln.Addr().String())
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
@@ -29,6 +30,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/container"
|
||||
"github.com/samcharles93/archie-core/internal/daemon"
|
||||
"github.com/samcharles93/archie-core/internal/domain/applystatus"
|
||||
"github.com/samcharles93/archie-core/internal/domain/health"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
@@ -36,6 +38,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/forge"
|
||||
"github.com/samcharles93/archie-core/internal/forgerpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/readiness"
|
||||
"github.com/samcharles93/archie-core/internal/logging"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
"github.com/samcharles93/archie-core/internal/storage"
|
||||
@@ -123,7 +126,7 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
return 0
|
||||
}
|
||||
|
||||
if recovering, err := resumeUpdate(context.Background()); err != nil {
|
||||
if recovering, err := resumeUpdate(context.Background(), args.cfgPath); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return 1
|
||||
} else if recovering {
|
||||
@@ -182,11 +185,12 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
return 1
|
||||
}
|
||||
|
||||
if err := b.setupGatewayClient(); err != nil {
|
||||
if err := b.setupGatewayClient(ctx); err != nil {
|
||||
return 1
|
||||
}
|
||||
if ps, ok := b.stateStore.(storecontract.PresenceStore); ok {
|
||||
go presence.Run(ctx, b.processName, servicekit.Build(), ps, b.healthRegistry, b.log)
|
||||
b.reportBrokerPresence(ctx, ps)
|
||||
}
|
||||
// The daemon publishes the configuration view, which carries the catalog's
|
||||
// model limits.
|
||||
@@ -194,9 +198,6 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
if err := b.buildTreesAndIdentities(ctx); err != nil {
|
||||
return 1
|
||||
}
|
||||
if err := b.loadWorkflows(); err != nil {
|
||||
return 1
|
||||
}
|
||||
|
||||
if err := b.registerNATSRPC(); err != nil {
|
||||
return 1
|
||||
@@ -206,6 +207,9 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence
|
||||
}
|
||||
|
||||
b.buildDaemon()
|
||||
b.playbooks.Keep(ctx, playbookRefreshInterval)
|
||||
b.workflowDefinitions.Keep(ctx, playbookRefreshInterval)
|
||||
b.controlPlane.KeepSchedules(ctx, playbookRefreshInterval)
|
||||
b.wireConfigSurfaces(ctx, args.cfgPath, args.overlayPath)
|
||||
|
||||
if err := b.startServices(ctx); err != nil {
|
||||
@@ -288,6 +292,11 @@ func subscribeSystemLogs(nc *natsio.Conn, taskLogs *logging.TaskRegistry, log *s
|
||||
}
|
||||
// The NATS callback has no context of its own; the write is an append to
|
||||
// an already-open sink, so there is nothing to cancel.
|
||||
if entry.Fields == nil {
|
||||
entry.Fields = map[string]any{}
|
||||
}
|
||||
entry.Fields["service"] = presence.Agent
|
||||
entry.Fields["task_id"] = taskID
|
||||
taskLogs.Write(context.Background(), taskID, entry)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -350,7 +359,7 @@ func subscribeAgentEvents(nc *natsio.Conn, bus *events.Bus, log *slog.Logger) (u
|
||||
// tasks, and one server pair per identity answers that identity's scoped
|
||||
// subjects so a container-mode task owned by a non-root identity has its RPC
|
||||
// calls served by its own forge client and worktree manager.
|
||||
func registerTaskRPCServers(nc *natsio.Conn, forgeClient forge.Forge, trees *worktree.Manager, identities []*daemon.IdentityRunner, runs worktreerpc.Runs, log *slog.Logger) (unsubscribe func(), err error) {
|
||||
func registerTaskRPCServers(nc *natsio.Conn, forgeClient forge.Forge, trees *worktree.Manager, identities []*daemon.IdentityRunner, runs worktreerpc.Runs, authorities forgerpc.Authorities, log *slog.Logger) (unsubscribe func(), err error) {
|
||||
unsubs := make([]func(), 0, 2+2*len(identities))
|
||||
unsubAll := func() {
|
||||
for _, u := range unsubs {
|
||||
@@ -359,7 +368,7 @@ func registerTaskRPCServers(nc *natsio.Conn, forgeClient forge.Forge, trees *wor
|
||||
}
|
||||
|
||||
registerForge := func(fg forge.Forge, identity string) error {
|
||||
srv := &forgerpc.Server{Forge: fg, Runs: runs, Log: log.With("rpc_identity", identity)}
|
||||
srv := &forgerpc.Server{Forge: fg, Runs: runs, Authorities: authorities, Log: log.With("rpc_identity", identity)}
|
||||
u, err := srv.RegisterFor(nc, identity)
|
||||
if err != nil {
|
||||
return fmt.Errorf("register forgerpc%s: %w", identitySuffix(identity), err)
|
||||
@@ -526,3 +535,15 @@ func resolveRegistryAuth(ref secret.SecretRef, secrets *secret.Registry, log *sl
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func (b *boot) reportBrokerPresence(ctx context.Context, ps storecontract.PresenceStore) {
|
||||
if conn, err := b.natsClient.CoreConn(); err == nil {
|
||||
registry := health.NewRegistry(readiness.NewContractProbe("connection", 0, func(context.Context) error {
|
||||
if !conn.IsConnected() {
|
||||
return errors.New("broker disconnected")
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
go presence.Run(ctx, presence.Broker, presence.Build{Version: conn.ConnectedServerVersion(), InstallType: b.cfg.NATS.Mode}, ps, registry, b.log)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"github.com/docker/sandbox-kit-spec/v3/spec"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/daemon"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/egress"
|
||||
"github.com/samcharles93/archie-core/internal/storage"
|
||||
)
|
||||
|
||||
const modelProxyCAPath = "/opt/archie/egress-ca.pem"
|
||||
|
||||
// modelEgress opens native task containers' model sessions on the egress
|
||||
// proxy. Each keyed provider's key is the org's credential binding named
|
||||
// after the provider.
|
||||
type modelEgress struct {
|
||||
proxy *egress.Proxy
|
||||
addr string
|
||||
caFile string
|
||||
config *config.Holder
|
||||
}
|
||||
|
||||
func (m modelEgress) Open(token, org string, providers map[string]config.Provider) (daemon.ModelSession, error) {
|
||||
var keyed []string
|
||||
for _, name := range slices.Sorted(maps.Keys(providers)) {
|
||||
if providers[name].APIKeyEnv != "" {
|
||||
keyed = append(keyed, name)
|
||||
}
|
||||
}
|
||||
if len(keyed) == 0 {
|
||||
return daemon.ModelSession{}, nil
|
||||
}
|
||||
bound := m.config.Get().Containers.BoundCredentials(org, keyed, keyed)
|
||||
var (
|
||||
subs []egress.Substitution
|
||||
hosts []string
|
||||
env []string
|
||||
)
|
||||
for _, name := range keyed {
|
||||
p := providers[name]
|
||||
if _, ok := bound[name]; !ok {
|
||||
return daemon.ModelSession{}, fmt.Errorf("provider %q has no credential binding named %q in org %s", name, name, org)
|
||||
}
|
||||
host, err := egress.ProviderHost(p.Class, p.BaseURL)
|
||||
if err != nil {
|
||||
return daemon.ModelSession{}, fmt.Errorf("provider %q: %w", name, err)
|
||||
}
|
||||
subs = append(subs, egress.Substitution{Service: name, Host: host})
|
||||
hosts = append(hosts, host)
|
||||
env = append(env, p.APIKeyEnv+"="+egress.SentinelFor(name))
|
||||
}
|
||||
session, err := m.proxy.Register(egress.SessionOptions{
|
||||
Token: token, Org: org, Substitutions: subs,
|
||||
Network: &spec.PhasedNetwork{Runtime: &spec.NetworkRules{Allow: hosts}},
|
||||
})
|
||||
if err != nil {
|
||||
return daemon.ModelSession{}, err
|
||||
}
|
||||
session.EnterRuntime()
|
||||
return daemon.ModelSession{
|
||||
Env: append(env, egress.ModelProxyEnvFor(m.addr, token, hosts, modelProxyCAPath)...),
|
||||
Mounts: []storage.Mount{{Type: storage.MountTypeBind, Source: m.caFile, Destination: modelProxyCAPath}},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m modelEgress) Close(token string) { m.proxy.Revoke(token) }
|
||||
@@ -0,0 +1,72 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
)
|
||||
|
||||
const outcomePostInterval = 15 * time.Second
|
||||
|
||||
type outcomeDeliverer func(ctx context.Context, channel, chatID, text string) error
|
||||
|
||||
// postOutcomes reports each finished chat task to the conversation that
|
||||
// spawned it. A task stays unposted until delivery succeeds, so a Messaging
|
||||
// Service that is down or restarting only delays the report.
|
||||
func postOutcomes(ctx context.Context, tasks storecontract.OutcomePoster, deliver outcomeDeliverer, log *slog.Logger) {
|
||||
ticker := time.NewTicker(outcomePostInterval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
postPendingOutcomes(ctx, tasks, deliver, log)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func postPendingOutcomes(ctx context.Context, tasks storecontract.OutcomePoster, deliver outcomeDeliverer, log *slog.Logger) {
|
||||
pending, err := tasks.UnpostedOutcomes(ctx)
|
||||
if err != nil {
|
||||
log.Warn("list unposted task outcomes", "err", err)
|
||||
return
|
||||
}
|
||||
for _, t := range pending {
|
||||
// An origin that names no chat can never be delivered; marking it
|
||||
// posted keeps it from being retried forever.
|
||||
if channel, chatID, ok := splitOrigin(t.Origin); ok {
|
||||
if err := deliver(ctx, channel, chatID, outcomeText(t)); err != nil {
|
||||
log.Warn("post task outcome", "task", t.ID, "err", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
if err := tasks.MarkOutcomePosted(ctx, t.ID); err != nil {
|
||||
log.Warn("mark task outcome posted", "task", t.ID, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// splitOrigin reads "<channel>:<chat>[/<thread>]", the form messaging.Origin
|
||||
// writes. Delivery addresses the chat; threads are not addressable.
|
||||
func splitOrigin(origin string) (channel, chatID string, ok bool) {
|
||||
channel, conversation, found := strings.Cut(origin, ":")
|
||||
chatID, _, _ = strings.Cut(conversation, "/")
|
||||
return channel, chatID, found && channel != "" && chatID != ""
|
||||
}
|
||||
|
||||
func outcomeText(t *task.Task) string {
|
||||
text := fmt.Sprintf("Task %d (%s) finished: %s", t.ID, t.Title, t.Status)
|
||||
if t.PRNumber > 0 {
|
||||
text += fmt.Sprintf(", PR #%d", t.PRNumber)
|
||||
}
|
||||
if t.ParkReason != "" {
|
||||
text += "\n" + t.ParkReason
|
||||
}
|
||||
return text
|
||||
}
|
||||
@@ -98,5 +98,5 @@ type unscopedBroker struct{}
|
||||
func (unscopedBroker) Name() string { return "nats_credential_scope" }
|
||||
|
||||
func (unscopedBroker) Check(context.Context) health.Result {
|
||||
return health.Result{Status: health.StatusDegraded, Detail: "external NATS: agent containers receive the broker token, which reaches every subject; use the embedded broker to scope them to their task"}
|
||||
return health.Result{Status: health.StatusDegraded, Detail: "external NATS: containers get a broker token that reaches every subject; use the embedded broker"}
|
||||
}
|
||||
@@ -117,21 +117,8 @@ var reloadableFields = map[string]bool{
|
||||
"ModelLimits": true,
|
||||
"Notify": true,
|
||||
"Review": true,
|
||||
// BotUser/BotEmail used to be poll-path only; ForTask now carries both
|
||||
// into the task snapshot as well, because the sandboxed worker builds
|
||||
// its own worktree.Manager and signs its own commits (agentworker
|
||||
// task_execution.go, config.go ForTask). The commit identity is
|
||||
// therefore per-dispatch and does reload. The startup-built daemon
|
||||
// trees (bootstrap.go:654) still capture both, but only to record
|
||||
// user.name/user.email in the clone's own .git/config
|
||||
// (worktree.go setIdentity) -- cosmetic, not the signature go-git
|
||||
// commits with -- so a reload applies where it counts and this stays
|
||||
// reloadable rather than requires-restart.
|
||||
"BotEmail": true,
|
||||
// cfg.Label additionally feeds IssuesWithLabel per poll cycle
|
||||
// (daemon.go:359,390) and cfg.BotUser feeds AssignedIssues (:364,377).
|
||||
"Label": true,
|
||||
"BotUser": true,
|
||||
// Poll loops read the dispatch label each cycle.
|
||||
"Label": true,
|
||||
// MaxRetries has two consumers, both re-reading it: the webui maxRetriesFor
|
||||
// handler (api_tasks.go:380,383) reads it per request, and ForTask carries
|
||||
// it into every dispatched TaskConfig, where the container's remediation
|
||||
@@ -148,7 +135,6 @@ var reloadableSubFields = map[string]map[string]bool{
|
||||
"VolumeTTL": true, "Profiles": true, "Credentials": true,
|
||||
"Image": true, "MaxConcurrency": true, "MaxUptime": true, "PullPolicy": true, "Network": true,
|
||||
},
|
||||
"Forge": {"Host": true},
|
||||
// Policy is carried into TaskConfig by ForTask (config.go); MCPServers,
|
||||
// WebFetch and Minimax are not and stay requires-restart.
|
||||
"Tools": {"Policy": true},
|
||||
@@ -188,3 +174,9 @@ func changedNonReloadableFields(old, next config.Config) []string {
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
||||
// Account credentials, identity namespaces and forge listeners survive a reload.
|
||||
func preserveForgeIdentity(old, next config.Config) config.Config {
|
||||
next.BotUser, next.BotEmail, next.Forge = old.BotUser, old.BotEmail, old.Forge
|
||||
return next
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
)
|
||||
|
||||
func TestReloadPreservesForgeIdentity(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name, field string
|
||||
change func(*config.Config)
|
||||
}{
|
||||
{"forge host", "Forge", func(c *config.Config) { c.Forge.Host = "other.example" }},
|
||||
{"bot user", "BotUser", func(c *config.Config) { c.BotUser = "other-account" }},
|
||||
{"commit email", "BotEmail", func(c *config.Config) { c.BotEmail = "other@example.test" }},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
old := config.Config{BotUser: "archie", BotEmail: "archie@example.test", Forge: config.Forge{Host: "forge.example"}}
|
||||
next := old.Clone()
|
||||
tt.change(&next)
|
||||
if restored := preserveForgeIdentity(old, next); restored.BotUser != old.BotUser || restored.BotEmail != old.BotEmail || restored.Forge != old.Forge {
|
||||
t.Fatal("reload changed the running forge identity")
|
||||
}
|
||||
if changed := changedNonReloadableFields(old, next); !slices.Contains(changed, tt.field) {
|
||||
t.Fatalf("identity change was reloadable: %v", changed)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/daemon"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/egress"
|
||||
)
|
||||
@@ -12,30 +14,83 @@ import (
|
||||
// credential for the run a run credential names, when the request is made,
|
||||
// from the live grants and bindings. A revoked credential, a grant removed
|
||||
// mid-run or a binding in another org stops resolving at once.
|
||||
//
|
||||
// A setup session's token names no task, so the resolver consults the session
|
||||
// grants first: the session is bound for the org's bindings of the Kit's
|
||||
// declared services, which is the intersection the operator's update-on-secret
|
||||
// authorisation covers.
|
||||
type runCredentialResolver struct {
|
||||
runs interface {
|
||||
TaskForCredential(ctx context.Context, token string) (*workflow.Task, error)
|
||||
}
|
||||
sessions interface {
|
||||
GrantedFor(token string) (org string, services []string, ok bool)
|
||||
}
|
||||
// models answers a task's org's own providers. Nil grants only the
|
||||
// instance providers.
|
||||
models daemon.TaskModels
|
||||
config *config.Holder
|
||||
secrets interface {
|
||||
Resolve(config.SecretRef) (string, error)
|
||||
}
|
||||
// credentials, when set, is told whether each bound secret resolved.
|
||||
credentials *credentialWatch
|
||||
}
|
||||
|
||||
func (r runCredentialResolver) Resolve(ctx context.Context, credential, service string) (string, error) {
|
||||
if r.sessions != nil {
|
||||
if org, services, ok := r.sessions.GrantedFor(credential); ok {
|
||||
return r.resolveBinding(ctx, org, services, service)
|
||||
}
|
||||
}
|
||||
task, err := r.runs.TaskForCredential(ctx, credential)
|
||||
if err != nil {
|
||||
return "", egress.ErrUnbound
|
||||
}
|
||||
cfg := r.config.Get()
|
||||
org, granted := cfg.CredentialAccess(task.Identity)
|
||||
_, granted := cfg.CredentialAccess(task.Identity)
|
||||
org := task.OrgOrDefault()
|
||||
// A configured model provider's key is granted to every run of the org:
|
||||
// any agent stage needs model access.
|
||||
if r.isModelProvider(ctx, cfg, task, service) {
|
||||
granted = append(slices.Clone(granted), service)
|
||||
}
|
||||
return r.resolveBinding(ctx, org, granted, service)
|
||||
}
|
||||
|
||||
// resolveBinding resolves service from the org's binding when the run or
|
||||
// session is granted it. An OAuth binding resolves to the empty string: the
|
||||
// proxy supplies the org's token set itself.
|
||||
func (r runCredentialResolver) resolveBinding(ctx context.Context, org string, granted []string, service string) (string, error) {
|
||||
cfg := r.config.Get()
|
||||
binding, ok := cfg.Containers.BoundCredentials(org, granted, []string{service})[service]
|
||||
if !ok {
|
||||
return "", egress.ErrUnbound
|
||||
}
|
||||
if binding.Secret == (config.SecretRef{}) {
|
||||
// An OAuth binding: the proxy supplies the org's token set itself.
|
||||
return "", nil
|
||||
}
|
||||
return r.secrets.Resolve(binding.Secret)
|
||||
if r.secrets == nil {
|
||||
return "", egress.ErrUnbound
|
||||
}
|
||||
value, err := r.secrets.Resolve(binding.Secret)
|
||||
r.credentials.observe(ctx, org, service, err != nil)
|
||||
return value, err
|
||||
}
|
||||
|
||||
// isModelProvider reports whether service is a provider the task's models
|
||||
// run on: an instance provider, or one of its org's own.
|
||||
func (r runCredentialResolver) isModelProvider(ctx context.Context, cfg config.Config, task *workflow.Task, service string) bool {
|
||||
if _, ok := cfg.Providers[service]; ok {
|
||||
return true
|
||||
}
|
||||
if r.models == nil {
|
||||
return false
|
||||
}
|
||||
models, err := r.models.TaskModels(ctx, task.ID)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, ok := models.Providers[service]
|
||||
return ok
|
||||
}
|
||||
@@ -29,17 +29,21 @@ func TestEgressResolvesOnlyGrantedCredentials(t *testing.T) {
|
||||
own := []string{"anthropic"}
|
||||
cfg := config.Config{
|
||||
GrantedCredentials: []string{"github"},
|
||||
Providers: map[string]config.Provider{"openai": {Class: "openai"}, "deepseek": {Class: "deepseek"}},
|
||||
Identities: []config.IdentityConfig{{Name: "acme-bot", Org: "acme", GrantedCredentials: &own}},
|
||||
Containers: config.ContainerConfig{Credentials: []config.CredentialBinding{
|
||||
{Service: "github", Secret: config.SecretRef{Engine: "env", Key: "GH"}},
|
||||
{Service: "anthropic", Secret: config.SecretRef{Engine: "env", Key: "ROOT_AI"}},
|
||||
{Service: "anthropic", Org: "acme", Secret: config.SecretRef{Engine: "env", Key: "ACME_AI"}},
|
||||
{Service: "openai", Secret: config.SecretRef{Engine: "env", Key: "ROOT_OPENAI"}},
|
||||
{Service: "openai", Org: "acme", Secret: config.SecretRef{Engine: "env", Key: "ACME_OPENAI"}},
|
||||
{Service: "deepseek", Secret: config.SecretRef{Engine: "env", Key: "ROOT_DEEPSEEK"}},
|
||||
}},
|
||||
}
|
||||
r := runCredentialResolver{
|
||||
runs: runsByToken{"root-run": {ID: 1}, "acme-run": {ID: 2, Identity: "acme-bot"}},
|
||||
runs: runsByToken{"root-run": {ID: 1}, "acme-run": {ID: 2, Identity: "acme-bot", Org: "acme"}, "acme-row-run": {ID: 3, Org: "acme"}},
|
||||
config: config.NewHolder(cfg),
|
||||
secrets: secretValues{"GH": "gh-secret", "ROOT_AI": "root-ai", "ACME_AI": "acme-ai"},
|
||||
secrets: secretValues{"GH": "gh-secret", "ROOT_AI": "root-ai", "ACME_AI": "acme-ai", "ROOT_OPENAI": "root-openai", "ACME_OPENAI": "acme-openai", "ROOT_DEEPSEEK": "root-deepseek"},
|
||||
}
|
||||
tests := []struct {
|
||||
name, credential, service, want string
|
||||
@@ -49,6 +53,10 @@ func TestEgressResolvesOnlyGrantedCredentials(t *testing.T) {
|
||||
{"identity run gets its own org's binding", "acme-run", "anthropic", "acme-ai"},
|
||||
{"identity grants replace the root's", "acme-run", "github", ""},
|
||||
{"unknown credential", "gone", "github", ""},
|
||||
{"a model provider key needs no grant", "root-run", "openai", "root-openai"},
|
||||
{"a model provider key is the run's own org's", "acme-run", "openai", "acme-openai"},
|
||||
{"another org's model provider key is unbound", "acme-run", "deepseek", ""},
|
||||
{"the task's own org decides, not the identity mapping", "acme-row-run", "openai", "acme-openai"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@@ -65,3 +73,47 @@ func TestEgressResolvesOnlyGrantedCredentials(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestEgressResolvesASessionGrant pins that a setup session's token, which
|
||||
// names no task, resolves only the granted services of its own org. A grant
|
||||
// that widened to another org's binding would hand the container a credential
|
||||
// the operator's update-on-secret authorisation never covered.
|
||||
func TestEgressResolvesASessionGrant(t *testing.T) {
|
||||
cfg := config.Config{Containers: config.ContainerConfig{Credentials: []config.CredentialBinding{
|
||||
{Service: "github", Org: "acme", Secret: config.SecretRef{Engine: "env", Key: "ACME_GH"}},
|
||||
{Service: "linear", Org: "acme"},
|
||||
}}}
|
||||
sessions := &sessionGrants{}
|
||||
sessions.Grant("acme-session", "acme", []string{"github", "linear"})
|
||||
sessions.Grant("other-session", "other", []string{"github"})
|
||||
r := runCredentialResolver{
|
||||
runs: runsByToken{"acme-run": {ID: 1, Identity: "acme-bot", Org: "acme"}},
|
||||
sessions: sessions,
|
||||
config: config.NewHolder(cfg),
|
||||
secrets: secretValues{"ACME_GH": "acme-gh"},
|
||||
}
|
||||
tests := []struct {
|
||||
name, credential, service, want string
|
||||
bound bool
|
||||
}{
|
||||
{name: "a bound api key resolves", credential: "acme-session", service: "github", want: "acme-gh", bound: true},
|
||||
{name: "a bound oauth service resolves to the proxy's own token set", credential: "acme-session", service: "linear", bound: true},
|
||||
{name: "a service outside the grant is unbound", credential: "acme-session", service: "nope"},
|
||||
{name: "another org's binding is unbound", credential: "other-session", service: "github"},
|
||||
{name: "an unknown token falls through to the task path", credential: "acme-run", service: "github"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := r.Resolve(context.Background(), tt.credential, tt.service)
|
||||
if !tt.bound {
|
||||
if !errors.Is(err, egress.ErrUnbound) {
|
||||
t.Fatalf("got %q, %v; want ErrUnbound", got, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil || got != tt.want {
|
||||
t.Fatalf("got %q, %v; want %q", got, err, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (b *boot) setupScheduling() error {
|
||||
}
|
||||
runners[scheduling.KindWorkflow] = workflowRunner
|
||||
}
|
||||
router, err := crondelivery.NewRouter(store, runners, cfg.Events)
|
||||
router, err := crondelivery.NewRouter(store, runners)
|
||||
if err != nil {
|
||||
return fmt.Errorf("scheduling: build router: %w", err)
|
||||
}
|
||||
@@ -174,8 +174,6 @@ func (s scheduleResourceStore) MarkRun(ctx context.Context, id string, runAt tim
|
||||
// The stop path derives its own timeout budget from Background rather than
|
||||
// the boot context, which is already cancelled by the time shutdown runs --
|
||||
// the same reasoning as shutdownCuratorRuntime.
|
||||
//
|
||||
//nolint:contextcheck
|
||||
func shutdownSchedulingEngine(e *scheduling.Engine, log *slog.Logger) func() {
|
||||
return func() {
|
||||
stopCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
|
||||
@@ -72,18 +72,7 @@ func (b *boot) startWatchdog(ctx context.Context) {
|
||||
// beginning a fresh poll pass, and therefore how stale the progress marker may
|
||||
// be before the loop counts as stalled.
|
||||
//
|
||||
// It is the root poll interval, or the slowest configured identity in
|
||||
// multi-identity mode: each identity polls its own repos, identity poll
|
||||
// intervals are frozen at boot, and the marker is stamped by whichever identity
|
||||
// polled most recently -- so the worst case between stamps is the slowest
|
||||
// identity, not the fastest. The root value is re-read per sample, so a
|
||||
// reloaded poll_interval is honoured.
|
||||
// The shared interval is re-read so live polling changes are honoured.
|
||||
func (b *boot) loopCadence() time.Duration {
|
||||
cadence := b.cfgHolder.Get().PollInterval.Std()
|
||||
for _, id := range b.d.Identities {
|
||||
if override := id.Cfg.PollInterval.Std(); override > cadence {
|
||||
cadence = override
|
||||
}
|
||||
}
|
||||
return cadence
|
||||
return b.cfgHolder.Get().PollInterval.Std()
|
||||
}
|
||||
@@ -17,5 +17,6 @@ func (b *boot) startSecretEngines(ctx context.Context, client *staterpc.Client)
|
||||
b.applyStatus.Report(ctx, controlplanerpc.ExtensionSettingsKind, version, err)
|
||||
}
|
||||
runner := secretengine.Supervise(ctx, b.secrets, source, b.processName, report, b.log)
|
||||
runner.OnChange(func() { b.publishConfigSnapshot(ctx) })
|
||||
b.addCleanup(runner.Close)
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
|
||||
// RunStatus prints one line per service from the State Store's presence
|
||||
@@ -31,7 +30,7 @@ func RunStatus(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stderr, "archied status: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Daemon, doc.Config.Services, secret.NewRegistry())
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Daemon, doc.Config)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "archied status: %v\n", err)
|
||||
return 1
|
||||
|
||||
@@ -31,7 +31,7 @@ func stepVocabulary() (*workflow.Manager, error) { return workflowsteps.NewManag
|
||||
// (main.go's Run) before buildDaemon captures the client.
|
||||
//
|
||||
// It is deliberately not part of openStateStoreAdapter, which the gateway root
|
||||
// shares: the gateway reads catalog, runtime settings and personas, never a
|
||||
// shares: the gateway reads catalog, runtime settings and SOUL, never a
|
||||
// workflow definition, so registering a vocabulary there would be the dead
|
||||
// vocabulary this shape removed from internal/app/archiemessaging -- a root that
|
||||
// cannot consume it must not be failed by it.
|
||||
@@ -48,6 +48,8 @@ func (b *boot) openDaemonWorkflowDefinitions() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("build workflow definitions client: %w", err)
|
||||
}
|
||||
definitions.ApplyStatus = b.applyStatus
|
||||
b.controlPlane.ApplyStatus = b.applyStatus
|
||||
b.workflowDefinitions = definitions
|
||||
return nil
|
||||
}
|
||||
|
||||
+199
-43
@@ -7,55 +7,200 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
)
|
||||
|
||||
// RunUpdateTopology observes the host using the candidate's topology contract.
|
||||
func RunUpdateTopology(args []string, out, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("update-topology", flag.ContinueOnError)
|
||||
// The watchdog's patience: how long the restarted daemon has to report the
|
||||
// release, and how long it must then stay healthy.
|
||||
const (
|
||||
updateHealthTimeout = 60 * time.Second
|
||||
updateObserve = 120 * time.Second
|
||||
updatePoll = 3 * time.Second
|
||||
)
|
||||
|
||||
const updateUsage = `usage:
|
||||
archied update check [-channel stable|next|exact-pin] [-pin version]
|
||||
archied update install -version X [-config FILE] [-report FILE -channel C -chat ID -thread ID]
|
||||
archied update watchdog [-config FILE] [-recover]`
|
||||
|
||||
// RunUpdate serves `archied update`: check prints the release snapshot,
|
||||
// install verifies and stages a release and hands it to the watchdog, and
|
||||
// watchdog switches over, watches the daemon and commits or rolls back.
|
||||
func RunUpdate(args []string, out, stderr io.Writer) int {
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintln(stderr, updateUsage)
|
||||
return 2
|
||||
}
|
||||
switch args[0] {
|
||||
case "check":
|
||||
return runUpdateCheck(args[1:], out, stderr)
|
||||
case "install":
|
||||
return runUpdateInstall(args[1:], out, stderr)
|
||||
case "watchdog":
|
||||
return runUpdateWatchdog(args[1:], stderr)
|
||||
default:
|
||||
fmt.Fprintln(stderr, updateUsage)
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
func runUpdateInstall(args []string, out, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("update install", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
configPath := flags.String("config", "", "bootstrap config file")
|
||||
releasePath := flags.String("release", "", "release manifest")
|
||||
configPath := flags.String("config", configuration.DefaultConfigPath(), "bootstrap config file")
|
||||
version := flags.String("version", "", "release version to install")
|
||||
releaseURL := flags.String("release-url", releaseupdate.ReleaseURL, "base URL of the release downloads")
|
||||
var meta releaseupdate.InstallMeta
|
||||
flags.StringVar(&meta.ReportPath, "report", "", "where the watchdog leaves the outcome")
|
||||
flags.StringVar(&meta.Channel, "channel", "", "channel the outcome is reported on")
|
||||
flags.Int64Var(&meta.ChatID, "chat", 0, "chat the outcome is reported to")
|
||||
flags.IntVar(&meta.ThreadID, "thread", 0, "thread the outcome is reported to")
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 2
|
||||
}
|
||||
self, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
if err := checkUpdateTopology(*configPath, *releasePath, out); err != nil {
|
||||
ctx := context.Background()
|
||||
tx, err := hostTransaction(*configPath, filepath.Dir(self), func(line string) { fmt.Fprintln(out, line) })
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
result, err := tx.Prepare(ctx, releaseupdate.PrepareRequest{
|
||||
Version: *version, ReleaseURL: *releaseURL, Self: self, Meta: meta,
|
||||
CheckTopology: func(ctx context.Context, required releaseupdate.Topology, managed bool) error {
|
||||
return checkUpdateTopology(ctx, *configPath, required, managed, out)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
frozen := filepath.Join(releaseupdate.JournalPath(updateStateDir()), releaseupdate.WatchdogBinary)
|
||||
if err := spawnWatchdog(ctx, result.RestartRequested, frozen, *configPath, false); err != nil {
|
||||
// The journal stays: the next archied boot recovers it.
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
if !result.RestartRequested {
|
||||
fmt.Fprintf(out, "no systemd user manager: the watchdog installs %s without restarting; restart the archie services to run it\n", *version)
|
||||
}
|
||||
data, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintln(out, releaseupdate.ResultSentinel+string(data))
|
||||
return 0
|
||||
}
|
||||
|
||||
func runUpdateWatchdog(args []string, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("update watchdog", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
configPath := flags.String("config", configuration.DefaultConfigPath(), "bootstrap config file")
|
||||
recovering := flags.Bool("recover", false, "recover an interrupted transaction at boot")
|
||||
binDir := flags.String("bin-dir", "", "directory of the live binaries")
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 2
|
||||
}
|
||||
tx, err := hostTransaction(*configPath, *binDir, func(line string) { fmt.Fprintln(stderr, line) })
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
if err := tx.Run(context.Background(), *recovering); err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func checkUpdateTopology(configPath, releasePath string, out io.Writer) error {
|
||||
data, err := os.ReadFile(releasePath)
|
||||
// hostTransaction wires the transaction to this host: systemd user units,
|
||||
// Docker, the daemon's health endpoint, the control-plane image policy and
|
||||
// the State Store's own backup and restore.
|
||||
func hostTransaction(configPath, binDir string, progress func(string)) (*releaseupdate.Transaction, error) {
|
||||
_, doc, err := servicekit.Resolve(slog.New(slog.DiscardHandler), configPath, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if binDir == "" {
|
||||
return nil, errors.New("-bin-dir is required")
|
||||
}
|
||||
return &releaseupdate.Transaction{
|
||||
StateDir: updateStateDir(),
|
||||
BinDir: binDir,
|
||||
Units: systemdUnits{},
|
||||
Images: dockerImages{},
|
||||
Policy: imagePolicy{configPath: configPath},
|
||||
Database: stateDatabase{configPath: configPath},
|
||||
Health: daemonHealth{url: doc.Config.Health.URL()},
|
||||
Progress: progress,
|
||||
HealthTimeout: updateHealthTimeout,
|
||||
Observe: updateObserve,
|
||||
Poll: updatePoll,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// spawnWatchdog runs the frozen watchdog outside this process, so restarting
|
||||
// any service, including the one that asked for the update, cannot kill it.
|
||||
// Under systemd it is a transient unit of its own; without one it is a
|
||||
// detached session.
|
||||
func spawnWatchdog(ctx context.Context, managed bool, binary, configPath string, recovering bool) error {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var manifest struct {
|
||||
Required releaseupdate.Topology `json:"required_topology"`
|
||||
args := []string{"update", "watchdog", "-config", configPath, "-bin-dir", filepath.Dir(exe)}
|
||||
if recovering {
|
||||
args = append(args, "-recover")
|
||||
}
|
||||
if err := json.Unmarshal(data, &manifest); err != nil {
|
||||
stateEnv := "ARCHIE_UPDATE_STATE_DIR=" + updateStateDir()
|
||||
if managed {
|
||||
// The units load the env file beside the config for database and
|
||||
// service credentials; the watchdog needs the same ones.
|
||||
envFile := "EnvironmentFile=-" + filepath.Join(filepath.Dir(configPath), "env")
|
||||
run := append([]string{"--user", "--collect", "--quiet", "--unit=archied-update-watchdog", "--setenv=" + stateEnv, "--property=" + envFile, binary}, args...)
|
||||
if output, err := exec.CommandContext(ctx, "systemd-run", run...).CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("start the update watchdog: %w: %s", err, output)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
logFile, err := os.OpenFile(filepath.Join(updateStateDir(), "watchdog.log"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(manifest.Required.Units) == 0 {
|
||||
return errors.New("release has no required_topology")
|
||||
defer func() { _ = logFile.Close() }()
|
||||
cmd := exec.Command(binary, args...) //nolint:noctx // the watchdog must outlive this process
|
||||
cmd.Env = append(os.Environ(), stateEnv)
|
||||
cmd.Stdout, cmd.Stderr = logFile, logFile
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("start the update watchdog: %w", err)
|
||||
}
|
||||
for _, unit := range manifest.Required.Units {
|
||||
if !regexp.MustCompile(`^archie[a-z0-9-]*$`).MatchString(unit) {
|
||||
return fmt.Errorf("invalid release unit %q", unit)
|
||||
}
|
||||
}
|
||||
data, err = os.ReadFile(configPath)
|
||||
return cmd.Process.Release()
|
||||
}
|
||||
|
||||
// checkUpdateTopology refuses a host missing a unit or config section the
|
||||
// release requires. Units are observable only under systemd; without it there
|
||||
// is nothing to restart, so only the config is checked.
|
||||
func checkUpdateTopology(ctx context.Context, configPath string, required releaseupdate.Topology, managed bool, out io.Writer) error {
|
||||
data, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -64,25 +209,34 @@ func checkUpdateTopology(configPath, releasePath string, out io.Writer) error {
|
||||
return fmt.Errorf("observe topology: %w", err)
|
||||
}
|
||||
sections := make(map[string]bool)
|
||||
for _, section := range manifest.Required.ConfigSections {
|
||||
for _, section := range required.ConfigSections {
|
||||
sections[section] = hasConfigSection(document, section)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
output, observeErr := exec.CommandContext(ctx, "systemctl", "--user", "list-unit-files", "archie*.service", "--no-legend", "--no-pager").Output()
|
||||
units := observedUnits(output, observeErr)
|
||||
plan := manifest.Required.MigrationPlan(units, sections)
|
||||
if len(plan) != 0 {
|
||||
fmt.Fprintln(out, "Required migration, in order:")
|
||||
for _, step := range plan {
|
||||
fmt.Fprintln(out, " -", step)
|
||||
units := make(map[string]bool)
|
||||
var observeErr error
|
||||
if managed {
|
||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
var output []byte
|
||||
output, observeErr = exec.CommandContext(ctx, "systemctl", "--user", "list-unit-files", "archie*.service", "--no-legend", "--no-pager").Output()
|
||||
units = observedUnits(output, observeErr)
|
||||
} else {
|
||||
for _, unit := range required.Units {
|
||||
units[unit] = true
|
||||
}
|
||||
if observeErr != nil {
|
||||
return fmt.Errorf("topology unknown; apply the printed migration before retrying: %w", observeErr)
|
||||
}
|
||||
return errors.New("refusing partial installation; apply the printed migration before retrying")
|
||||
}
|
||||
return nil
|
||||
plan := required.MigrationPlan(units, sections)
|
||||
if len(plan) == 0 {
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintln(out, "Required migration, in order:")
|
||||
for _, step := range plan {
|
||||
fmt.Fprintln(out, " -", step)
|
||||
}
|
||||
if observeErr != nil {
|
||||
return fmt.Errorf("topology unknown; apply the printed migration before retrying: %w", observeErr)
|
||||
}
|
||||
return errors.New("refusing partial installation; apply the printed migration before retrying")
|
||||
}
|
||||
|
||||
func hasConfigSection(document map[string]any, section string) bool {
|
||||
@@ -108,10 +262,11 @@ func updateStateDir() string {
|
||||
return filepath.Join(dir, "archie", "update")
|
||||
}
|
||||
|
||||
// Recovery runs independently of the daemon unit: it must be able to stop that
|
||||
// unit and replace its executable without systemd killing the recovery process.
|
||||
func resumeUpdate(ctx context.Context) (bool, error) {
|
||||
journal := filepath.Join(updateStateDir(), "transaction")
|
||||
// resumeUpdate hands an interrupted transaction to the frozen watchdog and
|
||||
// reports that this boot must stop: recovery may replace this executable and
|
||||
// restart this unit, so it runs outside it.
|
||||
func resumeUpdate(ctx context.Context, configPath string) (bool, error) {
|
||||
journal := releaseupdate.JournalPath(updateStateDir())
|
||||
if _, err := os.Stat(journal); errors.Is(err, os.ErrNotExist) {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
@@ -123,14 +278,15 @@ func resumeUpdate(ctx context.Context) (bool, error) {
|
||||
}
|
||||
defer lock.Close()
|
||||
if err := unix.Flock(int(lock.Fd()), unix.LOCK_EX|unix.LOCK_NB); errors.Is(err, unix.EWOULDBLOCK) {
|
||||
// A live watchdog owns the transaction and is restarting this unit.
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() { _ = unix.Flock(int(lock.Fd()), unix.LOCK_UN) }()
|
||||
cmd := exec.CommandContext(ctx, "systemd-run", "--user", "--collect", "--quiet", "--unit=archied-update-recovery", "--setenv=ARCHIE_UPDATE_STATE_DIR="+updateStateDir(), filepath.Join(journal, "watchdog"), "--boot-recover")
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return false, fmt.Errorf("schedule update recovery: %w: %s", err, output)
|
||||
_ = unix.Flock(int(lock.Fd()), unix.LOCK_UN)
|
||||
frozen := filepath.Join(journal, releaseupdate.WatchdogBinary)
|
||||
if err := spawnWatchdog(ctx, (systemdUnits{}).Managed(ctx), frozen, configPath, true); err != nil {
|
||||
return false, fmt.Errorf("schedule update recovery: %w", err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -11,18 +11,14 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
)
|
||||
|
||||
// RunUpdate serves `archied update check`, printing the release snapshot as
|
||||
// JSON. The channel defaults to the environment the installer passes on.
|
||||
func RunUpdate(args []string, out, stderr io.Writer) int {
|
||||
if len(args) == 0 || args[0] != "check" {
|
||||
fmt.Fprintln(stderr, "usage: archied update check [-channel stable|next|exact-pin] [-pin version]")
|
||||
return 2
|
||||
}
|
||||
// runUpdateCheck serves `archied update check`, printing the release snapshot
|
||||
// as JSON. The channel defaults to the environment.
|
||||
func runUpdateCheck(args []string, out, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("update check", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
channel := flags.String("channel", envOr("ARCHIE_UPDATE_RELEASE_CHANNEL", "stable"), "stable, next, or exact-pin")
|
||||
pin := flags.String("pin", os.Getenv("ARCHIE_UPDATE_PIN"), "exact release version")
|
||||
if err := flags.Parse(args[1:]); err != nil {
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 2
|
||||
}
|
||||
catalog := &releaseupdate.GitHubCatalog{Channel: func(context.Context) (string, string, error) { return *channel, *pin, nil }}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/statestore"
|
||||
"github.com/samcharles93/archie-core/internal/domain/health"
|
||||
)
|
||||
|
||||
// systemdUnits drives the archie user units through systemctl --user.
|
||||
type systemdUnits struct{}
|
||||
|
||||
// Managed reports whether a systemd user manager answers.
|
||||
func (systemdUnits) Managed(ctx context.Context) bool {
|
||||
return systemctl(ctx, "show-environment") == nil
|
||||
}
|
||||
|
||||
func (systemdUnits) Start(ctx context.Context, unit string) error {
|
||||
return systemctl(ctx, "restart", unit+".service")
|
||||
}
|
||||
|
||||
func (systemdUnits) Stop(ctx context.Context, unit string) error {
|
||||
return systemctl(ctx, "stop", unit+".service")
|
||||
}
|
||||
|
||||
func systemctl(ctx context.Context, args ...string) error {
|
||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
|
||||
defer cancel()
|
||||
output, err := exec.CommandContext(ctx, "systemctl", append([]string{"--user"}, args...)...).CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("systemctl --user %s: %w: %s", strings.Join(args, " "), err, strings.TrimSpace(string(output)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// dockerImages pulls through the Docker CLI.
|
||||
type dockerImages struct{}
|
||||
|
||||
func (dockerImages) Pull(ctx context.Context, ref string) error {
|
||||
ctx, cancel := context.WithTimeout(ctx, 15*time.Minute)
|
||||
defer cancel()
|
||||
if output, err := exec.CommandContext(ctx, "docker", "pull", ref).CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("docker pull %s: %w: %s", ref, err, strings.TrimSpace(string(output)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// stateDatabase is the task database, backed up and restored in-process by
|
||||
// the State Store's own recovery code.
|
||||
type stateDatabase struct{ configPath string }
|
||||
|
||||
func (d stateDatabase) Backup(ctx context.Context, out string) error {
|
||||
_, err := statestore.RunRecovery(ctx, statestore.RecoveryOptions{Operation: statestore.RecoveryBackup, Out: out, Config: d.configPath})
|
||||
return err
|
||||
}
|
||||
|
||||
func (d stateDatabase) Restore(ctx context.Context, from string) error {
|
||||
_, err := statestore.RunRecovery(ctx, statestore.RecoveryOptions{Operation: statestore.RecoveryRestore, From: from, Config: d.configPath})
|
||||
return err
|
||||
}
|
||||
|
||||
func (d stateDatabase) SchemaVersion(ctx context.Context) (int64, error) {
|
||||
return statestore.SchemaVersion(ctx, statestore.RecoveryOptions{Config: d.configPath})
|
||||
}
|
||||
|
||||
// daemonHealth asks archied's /health/detailed, which answers 200 only once
|
||||
// the daemon serves and every readiness probe passes.
|
||||
type daemonHealth struct{ url string }
|
||||
|
||||
func (h daemonHealth) Healthy(ctx context.Context) (string, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, h.url+"/health/detailed", nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var report struct {
|
||||
Status health.Status `json:"status"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK || json.Unmarshal(body, &report) != nil || report.Status != health.StatusOK {
|
||||
return report.Version, fmt.Errorf("%s: %s", resp.Status, strings.TrimSpace(string(body)))
|
||||
}
|
||||
return report.Version, nil
|
||||
}
|
||||
@@ -5,54 +5,56 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/controlplane"
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
|
||||
type imageChange struct {
|
||||
Previous string `json:"previous"`
|
||||
Candidate string `json:"candidate"`
|
||||
// imagePolicy is the control plane's agent image, reached through the State
|
||||
// Store contract. Only the image field changes, preserving concurrent edits
|
||||
// to unrelated settings.
|
||||
type imagePolicy struct{ configPath string }
|
||||
|
||||
func (p imagePolicy) Image(ctx context.Context) (string, error) {
|
||||
var image string
|
||||
err := p.with(ctx, func(_ pb.ControlPlaneServiceClient, _ *pb.QueryResponse, _ map[string]json.RawMessage, current string) error {
|
||||
image = current
|
||||
return nil
|
||||
})
|
||||
return image, err
|
||||
}
|
||||
|
||||
// RunUpdateImage journals and switches the control-plane image policy. It only
|
||||
// changes the image field, preserving concurrent edits to unrelated settings.
|
||||
func RunUpdateImage(args []string, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("update-image", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
configPath := flags.String("config", "", "bootstrap config")
|
||||
journal := flags.String("journal", "", "transaction directory")
|
||||
candidate := flags.String("prepare", "", "candidate image digest")
|
||||
rollback := flags.Bool("rollback", false, "restore the prior image")
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
if err := updateImage(ctx, *configPath, *journal, *candidate, *rollback); err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
func (p imagePolicy) SetImage(ctx context.Context, expected, desired string) error {
|
||||
return p.with(ctx, func(rpc pb.ControlPlaneServiceClient, response *pb.QueryResponse, policy map[string]json.RawMessage, current string) error {
|
||||
if current == desired {
|
||||
return nil
|
||||
}
|
||||
if current != expected {
|
||||
return errors.New("image policy changed during update; refusing to overwrite it")
|
||||
}
|
||||
var err error
|
||||
if policy["image"], err = json.Marshal(desired); err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := json.Marshal(policy)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = rpc.Command(ctx, &pb.CommandRequest{Kind: controlplane.ContainerRuntimePoliciesKind, Command: "replace", ValueJson: data, ExpectedVersion: response.Resource.Version, Actor: "self-update", Source: "installer", RequestId: fmt.Sprintf("self-update-%x-%d", sha256.Sum256(data), response.Resource.Version)})
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func updateImage(ctx context.Context, configPath, journal, candidate string, rollback bool) error {
|
||||
_, doc, err := servicekit.Resolve(slog.New(slog.DiscardHandler), configPath, "")
|
||||
func (p imagePolicy) with(ctx context.Context, use func(pb.ControlPlaneServiceClient, *pb.QueryResponse, map[string]json.RawMessage, string) error) error {
|
||||
_, doc, err := servicekit.Resolve(slog.New(slog.DiscardHandler), p.configPath, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Daemon, doc.Config.Services, secret.NewRegistry())
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Daemon, doc.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -70,48 +72,5 @@ func updateImage(ctx context.Context, configPath, journal, candidate string, rol
|
||||
if err := json.Unmarshal(policy["image"], ¤t); err != nil {
|
||||
return err
|
||||
}
|
||||
path := filepath.Join(journal, "image.json")
|
||||
if candidate != "" {
|
||||
return prepareImageChange(path, current, candidate)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var change imageChange
|
||||
if err := json.Unmarshal(data, &change); err != nil {
|
||||
return err
|
||||
}
|
||||
expected, desired := change.Previous, change.Candidate
|
||||
if rollback {
|
||||
expected, desired = desired, expected
|
||||
}
|
||||
if current == desired {
|
||||
return nil
|
||||
}
|
||||
if current != expected {
|
||||
return errors.New("image policy changed during update; refusing to overwrite it")
|
||||
}
|
||||
policy["image"], err = json.Marshal(desired)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err = json.Marshal(policy)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = rpc.Command(ctx, &pb.CommandRequest{Kind: controlplane.ContainerRuntimePoliciesKind, Command: "replace", ValueJson: data, ExpectedVersion: response.Resource.Version, Actor: "self-update", Source: "installer", RequestId: fmt.Sprintf("self-update-%x-%d", sha256.Sum256(data), response.Resource.Version)})
|
||||
return err
|
||||
}
|
||||
|
||||
func prepareImageChange(path, current, candidate string) error {
|
||||
if !regexp.MustCompile(`^([a-zA-Z0-9./:_-]+@)?sha256:[a-f0-9]{64}$`).MatchString(candidate) {
|
||||
return errors.New("candidate image must be pinned by digest")
|
||||
}
|
||||
data, err := json.Marshal(imageChange{Previous: current, Candidate: candidate})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, data, 0o600)
|
||||
return use(rpc, response, policy, current)
|
||||
}
|
||||
@@ -8,18 +8,19 @@ import (
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
)
|
||||
|
||||
func TestUpdateTopologyRefusal(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
manifest := filepath.Join(root, "release.json")
|
||||
config := filepath.Join(root, "config.toml")
|
||||
writeUpdateFixture(t, manifest, `{"required_topology":{"units":["archie-state-store","archie-gateway","archied"],"config_sections":["services.state","services.gateway"]}}`)
|
||||
required := releaseupdate.Topology{Units: []string{"archie-state-store", "archie-gateway", "archied"}, ConfigSections: []string{"services.state", "services.gateway"}}
|
||||
writeUpdateFixture(t, config, "[services.state]\ntarget='localhost:9090'\n")
|
||||
writeUpdateFixture(t, filepath.Join(root, "systemctl"), "#!/bin/sh\nprintf 'archied.service enabled enabled\\n'\n")
|
||||
t.Setenv("PATH", root+":"+os.Getenv("PATH"))
|
||||
var output bytes.Buffer
|
||||
if err := checkUpdateTopology(config, manifest, &output); err == nil {
|
||||
if err := checkUpdateTopology(t.Context(), config, required, true, &output); err == nil {
|
||||
t.Fatal("partial topology accepted")
|
||||
}
|
||||
for _, missing := range []string{"configure [services.gateway]", "install and enable archie-state-store.service", "install and enable archie-gateway.service"} {
|
||||
@@ -39,6 +40,7 @@ func TestResumeUpdate(t *testing.T) {
|
||||
}
|
||||
called := filepath.Join(root, "called")
|
||||
writeUpdateFixture(t, filepath.Join(root, "systemd-run"), "#!/bin/sh\nprintf '%s\\n' \"$@\" > '"+called+"'\n")
|
||||
writeUpdateFixture(t, filepath.Join(root, "systemctl"), "#!/bin/sh\n")
|
||||
t.Setenv("PATH", root+":"+os.Getenv("PATH"))
|
||||
lock, err := os.OpenFile(filepath.Join(root, "lock"), os.O_CREATE|os.O_RDWR, 0o600)
|
||||
if err != nil {
|
||||
@@ -50,7 +52,7 @@ func TestResumeUpdate(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
resumed, err := resumeUpdate(t.Context())
|
||||
resumed, err := resumeUpdate(t.Context(), filepath.Join(root, "config.toml"))
|
||||
if err != nil || resumed == active {
|
||||
t.Fatalf("resumed=%v err=%v", resumed, err)
|
||||
}
|
||||
@@ -59,7 +61,7 @@ func TestResumeUpdate(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(data), "--boot-recover") {
|
||||
if !strings.Contains(string(data), "-recover") {
|
||||
t.Fatalf("not a rollback: %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,14 @@ package archiegateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/logrpc"
|
||||
"github.com/samcharles93/archie-core/internal/logging"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
"github.com/samcharles93/archie-core/internal/skill"
|
||||
)
|
||||
|
||||
@@ -21,8 +26,10 @@ func (b *server) setSkillList(entries []skill.CatalogEntry) {
|
||||
// channels, so channel reload is left unset and answers Unavailable.
|
||||
func (b *server) chatCatalog() gatewayrpc.Catalog {
|
||||
return gatewayrpc.Catalog{
|
||||
Skills: b.skillEntries,
|
||||
Curators: b.curatorStates,
|
||||
CheckSecret: func(ref secret.SecretRef) bool { _, err := b.secrets.Resolve(ref); return err == nil },
|
||||
Logs: b.recentLogs,
|
||||
Skills: b.skillEntries,
|
||||
Curators: b.curatorStates,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,3 +93,14 @@ func skillSource(entry skill.CatalogEntry, workDir, sharedDir string) string {
|
||||
return "user-global skills"
|
||||
}
|
||||
}
|
||||
|
||||
func (b *server) recentLogs(ctx context.Context, service string, q logging.Query) (logging.Result, error) {
|
||||
switch service {
|
||||
case "", presence.Gateway:
|
||||
return b.logFeed.Read(q)
|
||||
case presence.Daemon:
|
||||
return logrpc.ReadDaemon(ctx, b.taskActionsConn, q)
|
||||
default:
|
||||
return logging.Result{}, fmt.Errorf("unknown log service %q", service)
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,14 @@ import (
|
||||
|
||||
// carriesPersonIdentity reports whether a platform's SenderID names a person.
|
||||
//
|
||||
// Telegram and email carry a native per-person sender id (a Telegram numeric
|
||||
// user id, an SMTP from address). The dashboard ("web") has one bearer token,
|
||||
// not users. Treating a shared token as an identity
|
||||
// would give it the same standing as a real user, which the read path's
|
||||
// isolation guarantee depends on never happening.
|
||||
// Web sender IDs are supplied by the authenticated UI service.
|
||||
// Telegram and email carry native person identifiers.
|
||||
//
|
||||
// An unknown platform fails closed, so a channel added later gets global and
|
||||
// agent scopes only until someone decides deliberately that it carries people.
|
||||
func carriesPersonIdentity(platform string) bool {
|
||||
switch platform {
|
||||
case "telegram", "email":
|
||||
case "telegram", "email", "web":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
||||
@@ -7,113 +7,46 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
|
||||
)
|
||||
|
||||
// chatModelManager owns the process-local model selected for interactive chat.
|
||||
// The configured role-to-model map supplies the available catalog; switching
|
||||
// chat models does not rewrite daemon configuration or affect workflow roles.
|
||||
// chatModelManager owns the model selection for interactive chat. Named
|
||||
// aliases remain defaults; choosing a catalog model does not rewrite them
|
||||
// or affect workflow steps.
|
||||
type chatModelManager struct {
|
||||
mu sync.RWMutex
|
||||
models []string
|
||||
active string
|
||||
// configured, explicit and catalog are the sources the offered set is
|
||||
// derived from: the role assignments (live via SetConfigured), the
|
||||
// [chat].models catalog (fixed for the process), and the model catalog's
|
||||
// own refs (replaced wholesale by SetModelCatalog).
|
||||
configured map[string]string
|
||||
explicit []string
|
||||
catalog []string
|
||||
mu sync.RWMutex
|
||||
aliases map[string]string
|
||||
active map[org.OrgID]string
|
||||
details map[string]gateway.ModelDetails
|
||||
providerNames map[string]string
|
||||
// orgAliases answers the aliases the principal ctx carries may use. Nil
|
||||
// serves every caller the instance aliases.
|
||||
orgAliases func(ctx context.Context) (map[string]string, error)
|
||||
}
|
||||
|
||||
// pickChatDefault is the model the manager starts on: the chat role's
|
||||
// assignment, falling back to the builder role's.
|
||||
func pickChatDefault(configured map[string]string) string {
|
||||
if active := strings.TrimSpace(configured["chat"]); active != "" {
|
||||
return active
|
||||
}
|
||||
return strings.TrimSpace(configured["builder"])
|
||||
}
|
||||
|
||||
// mergeModelRefs is the model set the manager offers: the configured role
|
||||
// assignments plus every catalog, unique and sorted.
|
||||
func mergeModelRefs(configured map[string]string, catalogs ...[]string) []string {
|
||||
unique := make(map[string]struct{}, len(configured))
|
||||
for _, ref := range configured {
|
||||
ref = strings.TrimSpace(ref)
|
||||
if ref != "" {
|
||||
unique[ref] = struct{}{}
|
||||
}
|
||||
}
|
||||
for _, catalog := range catalogs {
|
||||
for _, ref := range catalog {
|
||||
ref = strings.TrimSpace(ref)
|
||||
if ref != "" {
|
||||
unique[ref] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
models := make([]string, 0, len(unique))
|
||||
for ref := range unique {
|
||||
models = append(models, ref)
|
||||
}
|
||||
slices.Sort(models)
|
||||
return models
|
||||
}
|
||||
|
||||
func newChatModelManager(configured map[string]string, catalogs ...[]string) *chatModelManager {
|
||||
explicit := make([]string, 0, len(catalogs))
|
||||
for _, catalog := range catalogs {
|
||||
explicit = append(explicit, catalog...)
|
||||
}
|
||||
m := &chatModelManager{
|
||||
configured: configured,
|
||||
explicit: explicit,
|
||||
details: make(map[string]gateway.ModelDetails),
|
||||
providerNames: make(map[string]string),
|
||||
}
|
||||
m.active = pickChatDefault(configured)
|
||||
m.setModelsLocked()
|
||||
func newChatModelManager(aliases map[string]string) *chatModelManager {
|
||||
m := &chatModelManager{active: make(map[org.OrgID]string), details: make(map[string]gateway.ModelDetails), providerNames: make(map[string]string)}
|
||||
m.SetConfigured(aliases)
|
||||
return m
|
||||
}
|
||||
|
||||
// setModelsLocked re-derives the offered set from the three sources and keeps
|
||||
// the active selection when the new set still carries it, falling back the way
|
||||
// construction does when it does not.
|
||||
func (m *chatModelManager) setModelsLocked() {
|
||||
m.models = mergeModelRefs(m.configured, m.explicit, m.catalog)
|
||||
if !slices.Contains(m.models, m.active) {
|
||||
m.active = pickChatDefault(m.configured)
|
||||
}
|
||||
}
|
||||
|
||||
// SetConfigured re-derives the model set the manager offers after a live
|
||||
// change to model-role-assignments or provider-settings: the list is built
|
||||
// from the configured roles at construction, so a stored change would leave
|
||||
// the chat surfaces offering refs the runtime can no longer resolve. The
|
||||
// operator's active selection survives when the new roles still carry it; a
|
||||
// removed one falls back the way construction does.
|
||||
func (m *chatModelManager) SetConfigured(configured map[string]string) {
|
||||
// SetConfigured replaces the alias table after a live change to model-aliases.
|
||||
// An available selection survives; otherwise chat returns to the default alias.
|
||||
func (m *chatModelManager) SetConfigured(aliases map[string]string) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.configured = configured
|
||||
m.setModelsLocked()
|
||||
m.aliases = aliases
|
||||
m.keepActiveLocked()
|
||||
}
|
||||
|
||||
// SetModelCatalog replaces the model catalog's contribution to the manager:
|
||||
// the references it offers, the provider display names and the per-model
|
||||
// details. The previous snapshot's entries are dropped rather than merged --
|
||||
// a model or provider the catalog no longer publishes must stop being offered
|
||||
// and described, and these maps are the manager's own state rather than a
|
||||
// second catalogue to fall back on.
|
||||
func (m *chatModelManager) SetModelCatalog(snapshot modelcatalog.Snapshot, models []string) {
|
||||
// SetModelCatalog replaces the provider display names and per-model details
|
||||
// the catalog publishes.
|
||||
func (m *chatModelManager) SetModelCatalog(snapshot modelcatalog.Snapshot) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.catalog = slices.Clone(models)
|
||||
m.details = make(map[string]gateway.ModelDetails)
|
||||
m.providerNames = make(map[string]string)
|
||||
for _, provider := range snapshot.Providers {
|
||||
@@ -129,7 +62,15 @@ func (m *chatModelManager) SetModelCatalog(snapshot modelcatalog.Snapshot, model
|
||||
}
|
||||
}
|
||||
}
|
||||
m.setModelsLocked()
|
||||
m.keepActiveLocked()
|
||||
}
|
||||
|
||||
// keepActiveLocked retains an alias or an available model across live updates.
|
||||
func (m *chatModelManager) keepActiveLocked() {
|
||||
selection := m.selectionLocked(org.DefaultOrgID)
|
||||
if !slices.Contains(config.ChatAliases(m.aliases), selection) && !slices.Contains(chatModelRefs(m.aliases, m.details), selection) {
|
||||
m.active[org.DefaultOrgID] = config.PurposeChat.DefaultAlias()
|
||||
}
|
||||
}
|
||||
|
||||
func (m *chatModelManager) ProviderDisplayName(provider string) string {
|
||||
@@ -145,80 +86,116 @@ func (m *chatModelManager) ModelDetails(ref string) (gateway.ModelDetails, bool)
|
||||
return details, ok
|
||||
}
|
||||
|
||||
func (m *chatModelManager) Models() []string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return slices.Clone(m.models)
|
||||
func (m *chatModelManager) selectionLocked(id org.OrgID) string {
|
||||
if selection := m.active[id]; selection != "" {
|
||||
return selection
|
||||
}
|
||||
return config.PurposeChat.DefaultAlias()
|
||||
}
|
||||
|
||||
func (m *chatModelManager) ActiveModel() string {
|
||||
func (m *chatModelManager) ActiveAlias(ctx context.Context) string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.active
|
||||
selection := m.selectionLocked(org.OrgFromContext(ctx))
|
||||
if strings.Contains(selection, "/") {
|
||||
return ""
|
||||
}
|
||||
return selection
|
||||
}
|
||||
|
||||
func (m *chatModelManager) SetActiveModel(ctx context.Context, ref string) error {
|
||||
func (m *chatModelManager) SetActiveModel(ctx context.Context, selection string) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
aliases, err := m.aliasesFor(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if !slices.Contains(m.models, ref) {
|
||||
return fmt.Errorf("model %q is not configured", ref)
|
||||
id := org.OrgFromContext(ctx)
|
||||
if id == org.DefaultOrgID || m.orgAliases == nil {
|
||||
aliases = m.aliases
|
||||
}
|
||||
m.active = ref
|
||||
if !slices.Contains(config.ChatAliases(aliases), selection) && !slices.Contains(m.refsLocked(id, aliases), selection) {
|
||||
return fmt.Errorf("model or alias %q is not available", selection)
|
||||
}
|
||||
m.active[id] = selection
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *chatModelManager) Providers() []string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
seen := make(map[string]bool)
|
||||
var providers []string
|
||||
for _, model := range m.models {
|
||||
provider, _, ok := strings.Cut(model, "/")
|
||||
if ok && provider != "" && !seen[provider] {
|
||||
seen[provider] = true
|
||||
providers = append(providers, provider)
|
||||
}
|
||||
// aliasesFor is the alias table ctx's org resolves against: the instance's
|
||||
// for the system org, the org's own answer otherwise.
|
||||
func (m *chatModelManager) aliasesFor(ctx context.Context) (map[string]string, error) {
|
||||
if m.orgAliases == nil || org.OrgFromContext(ctx) == org.DefaultOrgID {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.aliases, nil
|
||||
}
|
||||
slices.Sort(providers)
|
||||
return providers
|
||||
return m.orgAliases(ctx)
|
||||
}
|
||||
|
||||
func (m *chatModelManager) ActiveProvider() string {
|
||||
// ModelsFor returns the model references ctx's org may select.
|
||||
func (m *chatModelManager) ModelsFor(ctx context.Context) ([]string, error) {
|
||||
aliases, err := m.aliasesFor(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
provider, _, _ := strings.Cut(m.active, "/")
|
||||
return provider
|
||||
id := org.OrgFromContext(ctx)
|
||||
if id == org.DefaultOrgID || m.orgAliases == nil {
|
||||
aliases = m.aliases
|
||||
}
|
||||
return m.refsLocked(id, aliases), nil
|
||||
}
|
||||
|
||||
func (m *chatModelManager) ModelsForProvider(provider string) []string {
|
||||
// ModelFor resolves the current selection in the caller's org. A direct
|
||||
// selection is checked again so revoked models stop serving turns.
|
||||
func (m *chatModelManager) ModelFor(ctx context.Context) (string, error) {
|
||||
aliases, err := m.aliasesFor(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
prefix := provider + "/"
|
||||
var models []string
|
||||
for _, model := range m.models {
|
||||
if strings.HasPrefix(model, prefix) {
|
||||
models = append(models, model)
|
||||
}
|
||||
id := org.OrgFromContext(ctx)
|
||||
if id == org.DefaultOrgID || m.orgAliases == nil {
|
||||
aliases = m.aliases
|
||||
}
|
||||
return models
|
||||
selection := m.selectionLocked(id)
|
||||
if strings.Contains(selection, "/") {
|
||||
if !slices.Contains(m.refsLocked(id, aliases), selection) {
|
||||
return "", fmt.Errorf("model %q is not available in this org", selection)
|
||||
}
|
||||
return selection, nil
|
||||
}
|
||||
return config.ResolveModel(aliases, selection, config.PurposeChat)
|
||||
}
|
||||
|
||||
func (m *chatModelManager) SetActiveProvider(ctx context.Context, provider string) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
// refsLocked keeps tenant choices within their assigned aliases; the system
|
||||
// org can also select from its credential-filtered provider catalog.
|
||||
func (m *chatModelManager) refsLocked(id org.OrgID, aliases map[string]string) []string {
|
||||
if id != org.DefaultOrgID {
|
||||
return chatModelRefs(aliases, nil)
|
||||
}
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
prefix := provider + "/"
|
||||
for _, model := range m.models {
|
||||
if strings.HasPrefix(model, prefix) {
|
||||
m.active = model
|
||||
return nil
|
||||
return chatModelRefs(aliases, m.details)
|
||||
}
|
||||
|
||||
func chatModelRefs(aliases map[string]string, catalog map[string]gateway.ModelDetails) []string {
|
||||
refs := make(map[string]struct{}, len(catalog)+len(aliases))
|
||||
for ref := range catalog {
|
||||
refs[ref] = struct{}{}
|
||||
}
|
||||
for _, alias := range config.ChatAliases(aliases) {
|
||||
if ref := strings.TrimSpace(aliases[alias]); ref != "" {
|
||||
refs[ref] = struct{}{}
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("provider %q is not configured", provider)
|
||||
out := make([]string, 0, len(refs))
|
||||
for ref := range refs {
|
||||
out = append(out, ref)
|
||||
}
|
||||
slices.Sort(out)
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package archiegateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
|
||||
)
|
||||
|
||||
type modelSelectionSessions struct{ gateway.SessionStore }
|
||||
|
||||
func (modelSelectionSessions) List(context.Context) ([]gateway.SessionContext, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func TestChatModelSelection(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
org org.OrgID
|
||||
selection string
|
||||
want string
|
||||
denied bool
|
||||
}{
|
||||
{"catalog model", org.DefaultOrgID, "openai/new", "openai/new", false},
|
||||
{"configured alias", org.DefaultOrgID, "fast", "openai/small", false},
|
||||
{"unknown model", org.DefaultOrgID, "openai/unknown", "openai/old", true},
|
||||
{"org model", "tenant", "anthropic/sonnet", "anthropic/sonnet", false},
|
||||
{"org alias", "tenant", "tenant-chat", "anthropic/sonnet", false},
|
||||
{"other org model", "tenant", "openai/new", "anthropic/sonnet", true},
|
||||
{"other org alias", "tenant", "fast", "anthropic/sonnet", true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
manager := newChatModelManager(map[string]string{"default": "openai/old", "fast": "openai/small"})
|
||||
manager.SetModelCatalog(modelcatalog.Snapshot{Providers: []modelcatalog.Provider{
|
||||
{ID: "openai", Models: []modelcatalog.Model{{ID: "old"}, {ID: "small"}, {ID: "new"}}},
|
||||
{ID: "anthropic", Models: []modelcatalog.Model{{ID: "sonnet"}}},
|
||||
}})
|
||||
manager.orgAliases = func(context.Context) (map[string]string, error) {
|
||||
return map[string]string{"default": "anthropic/sonnet", "tenant-chat": "anthropic/sonnet"}, nil
|
||||
}
|
||||
ctx := org.WithOrg(t.Context(), tc.org)
|
||||
router := gateway.NewRouter(nil, nil, "telegram")
|
||||
router.Models = manager
|
||||
reply, err := router.Route(ctx, gateway.Inbound{Message: messaging.Message{Text: "/model " + tc.selection}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if denied := strings.HasPrefix(reply, "Cannot switch"); denied != tc.denied {
|
||||
t.Fatalf("reply = %q, denied = %v", reply, tc.denied)
|
||||
}
|
||||
got, err := manager.ModelFor(ctx)
|
||||
if err != nil || got != tc.want {
|
||||
t.Fatalf("runtime model = %q, %v; want %q", got, err, tc.want)
|
||||
}
|
||||
adapter := &gateway.LocalChatAdapter{Router: router, Sessions: modelSelectionSessions{}, Models: manager}
|
||||
snapshot, err := adapter.Snapshot(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
provider, _, _ := strings.Cut(tc.want, "/")
|
||||
if snapshot.ActiveModel != tc.want || snapshot.ActiveProvider != provider || !slices.Contains(snapshot.ModelsByProvider[provider], tc.want) || !slices.Contains(snapshot.Providers, provider) {
|
||||
t.Fatalf("selector lost model/provider: %+v", snapshot)
|
||||
}
|
||||
if tc.org != org.DefaultOrgID && slices.Contains(snapshot.Models, "openai/new") {
|
||||
t.Fatal("selector exposed another org's model")
|
||||
}
|
||||
profile, err := router.Route(ctx, gateway.Inbound{Message: messaging.Message{Text: "/profile"}})
|
||||
if err != nil || !strings.Contains(profile, tc.want) {
|
||||
t.Fatalf("profile without task identity = %q, %v", profile, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChatModelOrgIsolation(t *testing.T) {
|
||||
for _, selection := range []string{"fast", "tenant/fast"} {
|
||||
t.Run(selection, func(t *testing.T) {
|
||||
m := newChatModelManager(map[string]string{"default": "openai/main"})
|
||||
tenantAliases := map[string]string{"default": "tenant/main", "fast": "tenant/fast"}
|
||||
m.orgAliases = func(ctx context.Context) (map[string]string, error) {
|
||||
if org.OrgFromContext(ctx) == "tenant" {
|
||||
return tenantAliases, nil
|
||||
}
|
||||
return map[string]string{"default": "other/main"}, nil
|
||||
}
|
||||
tenant := org.WithOrg(t.Context(), "tenant")
|
||||
if err := m.SetActiveModel(tenant, selection); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
check := func(systemModel string) {
|
||||
t.Helper()
|
||||
for id, want := range map[org.OrgID]string{org.DefaultOrgID: systemModel, "tenant": "tenant/fast", "other": "other/main"} {
|
||||
got, err := m.ModelFor(org.WithOrg(t.Context(), id))
|
||||
if err != nil || got != want {
|
||||
t.Errorf("org %s model = %q, %v; want %q", id, got, err, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
check("openai/main")
|
||||
m.SetConfigured(map[string]string{"default": "openai/updated"})
|
||||
m.SetModelCatalog(modelcatalog.Snapshot{})
|
||||
check("openai/updated")
|
||||
delete(tenantAliases, "fast")
|
||||
if _, err := m.ModelFor(tenant); err == nil {
|
||||
t.Fatal("revoked tenant choice still executes")
|
||||
}
|
||||
adapter := &gateway.LocalChatAdapter{Router: gateway.NewRouter(nil, nil, "telegram"), Sessions: modelSelectionSessions{}, Models: m}
|
||||
snapshot, err := adapter.Snapshot(tenant)
|
||||
if err != nil || snapshot.ActiveModel != "" || !slices.Contains(snapshot.ModelsByProvider["tenant"], "tenant/main") {
|
||||
t.Fatalf("picker cannot recover: %+v, %v", snapshot, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,9 @@ func (b *server) setupTranscriber(cfg config.Config, log *slog.Logger) {
|
||||
})
|
||||
if ok {
|
||||
b.transcriber = client
|
||||
log.Info("voice transcription enabled", "role", transcription.Role)
|
||||
} else if cfg.Models[transcription.Role] != "" {
|
||||
log.Warn("voice transcription configured but unavailable; capability disabled", "role", transcription.Role)
|
||||
log.Info("voice transcription enabled")
|
||||
} else if _, err := config.ResolveModel(cfg.Models, "", config.PurposeTranscription); err == nil {
|
||||
log.Warn("voice transcription configured but unavailable; capability disabled")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,18 +84,18 @@ func (b *server) startRateLimiter(ctx context.Context, cfg config.RateLimitConfi
|
||||
}
|
||||
|
||||
// rebuildChatModelRuntime re-derives the gateway chat runtime's provider set
|
||||
// after a live change to provider-settings or model-role-assignments. The
|
||||
// after a live change to provider-settings or model-aliases. The
|
||||
// turn runner reads the runtime through server.chatLLM, so the swap reaches its
|
||||
// next turn without rebuilding the runner, and the model manager re-derives
|
||||
// the references it offers from the new role assignments and the catalog.
|
||||
// the aliases it offers.
|
||||
func (b *server) rebuildChatModelRuntime(cfg config.Config) {
|
||||
if b.chatModels == nil {
|
||||
return // this process serves no chat turns
|
||||
}
|
||||
b.setLLM(modelloop.NewRuntime(executionProviders(cfg), cfg.ModelLimits))
|
||||
b.chatModels.SetConfigured(cfg.Models)
|
||||
catalog, models := b.catalogState()
|
||||
b.chatModels.SetModelCatalog(catalog, models)
|
||||
catalog := b.catalogState()
|
||||
b.chatModels.SetModelCatalog(catalog)
|
||||
b.log.Info("chat model runtime rebuilt", "providers", len(cfg.Providers), "models", len(cfg.Models))
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/agentexec/modelloop"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/domain/usage"
|
||||
"github.com/samcharles93/archie-core/internal/events"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
@@ -36,11 +37,13 @@ type chatSetup struct {
|
||||
// than the value captured when the runner was built.
|
||||
ToolLimits func() modelloop.ToolLimits
|
||||
// LLM resolves the provider runtime at each use: a live provider-settings
|
||||
// or model-role-assignments update swaps the runtime wholesale (ai-sdk's
|
||||
// or model-aliases update swaps the runtime wholesale (ai-sdk's
|
||||
// Runtime caches the provider instances it built), so the pointer cannot
|
||||
// be captured at construction. nil means no model runtime is configured.
|
||||
LLM func() *runtime.Runtime
|
||||
ChatModels gateway.ModelManager
|
||||
LLM func() *runtime.Runtime
|
||||
ChatModels gateway.ModelManager
|
||||
// Usage records each model call; nil records nothing.
|
||||
Usage *usageSink
|
||||
ToolReg *tools.Registry
|
||||
Soul gateway.SoulSource
|
||||
ChatTasks gateway.TaskCreator
|
||||
@@ -48,6 +51,7 @@ type chatSetup struct {
|
||||
ChatTaskLogs gateway.ChatTaskLogReader
|
||||
ChatTaskActor gateway.ChatTaskActor
|
||||
DefaultChatIdentity string
|
||||
Workflows gateway.WorkflowSource
|
||||
// Bus carries primary-input events: a completed
|
||||
// chat turn is published here so input-driven curators can wake. Nil
|
||||
// disables turn events (tests, minimal setups).
|
||||
@@ -97,7 +101,7 @@ func componentInstallTypeEnricher(nats config.NATSConfig) func(string) (string,
|
||||
}
|
||||
|
||||
func makeUpdateService(reader controlplanerpc.ResourceReader, cfg config.Config) *releaseupdate.Service {
|
||||
updates := controlplanerpc.UpdateService(reader, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"), cfg.Health.URL())
|
||||
updates := controlplanerpc.UpdateService(reader, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"))
|
||||
updates.Enrich = componentInstallTypeEnricher(cfg.NATS)
|
||||
return updates
|
||||
}
|
||||
@@ -129,12 +133,13 @@ func newChatTurnRunner(
|
||||
Sessions: sessionStore,
|
||||
Models: s.ChatModels,
|
||||
Soul: s.Soul,
|
||||
Model: newChatTurnModel(s.LLM, s.ToolReg, cfg.Chat.MaxSteps, s.ToolLimits, s.ProviderOutcomes),
|
||||
Model: newChatTurnModel(s.LLM, s.ToolReg, cfg.Chat.MaxSteps, s.ToolLimits, s.ProviderOutcomes, s.Usage),
|
||||
TaskLister: s.ChatTaskLister,
|
||||
Tasks: s.ChatTasks,
|
||||
TaskLogs: s.ChatTaskLogs,
|
||||
TaskActor: s.ChatTaskActor,
|
||||
TaskIdentity: s.DefaultChatIdentity,
|
||||
Workflows: s.Workflows,
|
||||
Bus: s.Bus,
|
||||
BotUser: cfg.BotUser,
|
||||
Channel: channel,
|
||||
@@ -191,31 +196,38 @@ func chatRepoEnv(cfg config.Config, identity string) []gateway.RepoEnv {
|
||||
// and records at its own adapter (curatorLLMRunner). Anything that reaches the
|
||||
// runtime without recording leaves /status reporting a stale last-known
|
||||
// outcome, which is a /status that lies about the provider.
|
||||
func sendChatTurn(ctx context.Context, llm *runtime.Runtime, chatModel string, options core.GenerateOptions, turn gateway.TurnStream, outcomes *providerOutcomeRecorder, icons map[string]string) (string, error) {
|
||||
text, err := runChatTurn(ctx, llm, chatModel, options, turn, icons)
|
||||
func sendChatTurn(ctx context.Context, llm *runtime.Runtime, chatModel string, options core.GenerateOptions, turn gateway.TurnStream, outcomes *providerOutcomeRecorder, usageRecords *usageSink, icons map[string]string) (string, error) {
|
||||
text, used, err := runChatTurn(ctx, llm, chatModel, options, turn, icons)
|
||||
usageRecords.record(ctx, usage.SourceChat, chatModel, used)
|
||||
// record tolerates a nil recorder: a setup built without one (tests, a
|
||||
// deployment whose health surface is unwired) still makes its calls.
|
||||
outcomes.record(chatModel, err)
|
||||
return text, err
|
||||
}
|
||||
|
||||
func runChatTurn(ctx context.Context, llm *runtime.Runtime, chatModel string, options core.GenerateOptions, turn gateway.TurnStream, icons map[string]string) (string, error) {
|
||||
// runChatTurn returns the reply and the tokens the call used, which a
|
||||
// failed call may still report.
|
||||
func runChatTurn(ctx context.Context, llm *runtime.Runtime, chatModel string, options core.GenerateOptions, turn gateway.TurnStream, icons map[string]string) (string, chat.Usage, error) {
|
||||
if turn == nil {
|
||||
result, err := llm.Chat(ctx, chatModel, options)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("llm chat: %w", err)
|
||||
return "", result.TotalUsage, fmt.Errorf("llm chat: %w", err)
|
||||
}
|
||||
return result.Text, nil
|
||||
return result.Text, result.TotalUsage, nil
|
||||
}
|
||||
stream, err := llm.ChatStream(ctx, chatModel, options)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("llm chat stream: %w", err)
|
||||
return "", chat.Usage{}, fmt.Errorf("llm chat stream: %w", err)
|
||||
}
|
||||
text := drainChatStream(stream.FullStream, turn, icons)
|
||||
if _, err := stream.FinishReason(); err != nil {
|
||||
return "", fmt.Errorf("llm chat stream: %w", err)
|
||||
var used chat.Usage
|
||||
if stream.Usage != nil {
|
||||
used, _ = stream.Usage()
|
||||
}
|
||||
return text, nil
|
||||
if _, err := stream.FinishReason(); err != nil {
|
||||
return "", used, fmt.Errorf("llm chat stream: %w", err)
|
||||
}
|
||||
return text, used, nil
|
||||
}
|
||||
|
||||
// drainChatStream consumes a model stream to close, reporting assistant text
|
||||
@@ -324,6 +336,7 @@ type chatTitleGenerator struct {
|
||||
log *slog.Logger
|
||||
llm func() *runtime.Runtime
|
||||
chatModels gateway.ModelManager
|
||||
usage *usageSink
|
||||
}
|
||||
|
||||
// newChatTitleGenerator wires an LLM-backed title generator for a chat
|
||||
@@ -333,7 +346,7 @@ func newChatTitleGenerator(s chatSetup) gateway.TitleGenerator {
|
||||
if s.LLM == nil || s.ChatModels == nil {
|
||||
return nil
|
||||
}
|
||||
return &chatTitleGenerator{log: s.Log, llm: s.LLM, chatModels: s.ChatModels}
|
||||
return &chatTitleGenerator{log: s.Log, llm: s.LLM, chatModels: s.ChatModels, usage: s.Usage}
|
||||
}
|
||||
|
||||
func (g *chatTitleGenerator) GenerateTitle(ctx context.Context, sessionID, firstMessage string) (string, error) {
|
||||
@@ -356,8 +369,12 @@ func (g *chatTitleGenerator) GenerateTitle(ctx context.Context, sessionID, first
|
||||
if llm == nil {
|
||||
return "", fmt.Errorf("no model runtime is configured")
|
||||
}
|
||||
text, err := sendChatTurn(ctx, llm, g.chatModels.ActiveModel(),
|
||||
core.GenerateOptions{Messages: messages, MaxSteps: 1}, nil, nil, nil)
|
||||
model, err := g.chatModels.ModelFor(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text, err := sendChatTurn(ctx, llm, model,
|
||||
core.GenerateOptions{Messages: messages, MaxSteps: 1}, nil, nil, g.usage, nil)
|
||||
if err != nil {
|
||||
if g.log != nil {
|
||||
g.log.Error("session title generation failed", "session", sessionID, "err", err)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
@@ -115,7 +116,7 @@ func (a chatTaskListerAdapter) ListChatTasks(ctx context.Context, identity strin
|
||||
// identity through the tool input.
|
||||
type chatTaskLogReaderAdapter struct {
|
||||
tasks func(context.Context, int64) (*workflow.Task, error)
|
||||
taskLogs *logging.TaskRegistry
|
||||
taskLogs storecontract.TaskLogStore
|
||||
}
|
||||
|
||||
func (a chatTaskLogReaderAdapter) ReadChatTaskLogs(
|
||||
@@ -141,19 +142,9 @@ func (a chatTaskLogReaderAdapter) ReadChatTaskLogs(
|
||||
if attempt <= 0 {
|
||||
attempt = task.Attempt
|
||||
}
|
||||
path := a.taskLogs.Path(taskID, attempt)
|
||||
if path == "" {
|
||||
return gateway.ChatTaskLogResult{Attempt: attempt, Entries: []gateway.ChatTaskLogEntry{}}, nil
|
||||
}
|
||||
|
||||
page, err := logging.Page(path, logging.Query{
|
||||
Component: q.Component,
|
||||
Contains: q.Contains,
|
||||
Levels: q.Levels,
|
||||
Since: q.Since,
|
||||
Until: q.Until,
|
||||
Limit: q.Limit,
|
||||
}, q.AfterID)
|
||||
page, err := a.taskLogs.TaskLog(ctx, taskID, attempt, logging.Query{
|
||||
Component: q.Component, Contains: q.Contains, Levels: q.Levels, Since: q.Since, Until: q.Until, Limit: q.Limit, BeforeID: q.AfterID,
|
||||
})
|
||||
if err != nil {
|
||||
return gateway.ChatTaskLogResult{}, err
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ type chatTurnModel struct {
|
||||
limits func() modelloop.ToolLimits
|
||||
// outcomes records each call's result for /status (see sendChatTurn).
|
||||
outcomes *providerOutcomeRecorder
|
||||
usage *usageSink
|
||||
}
|
||||
|
||||
func newChatTurnModel(
|
||||
@@ -37,6 +38,7 @@ func newChatTurnModel(
|
||||
maxSteps int,
|
||||
limits func() modelloop.ToolLimits,
|
||||
outcomes *providerOutcomeRecorder,
|
||||
usageRecords *usageSink,
|
||||
) gateway.TurnModel {
|
||||
return &chatTurnModel{
|
||||
llm: llm,
|
||||
@@ -44,6 +46,7 @@ func newChatTurnModel(
|
||||
maxSteps: maxSteps,
|
||||
limits: limits,
|
||||
outcomes: outcomes,
|
||||
usage: usageRecords,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +73,7 @@ func (m *chatTurnModel) Prepare(
|
||||
toolInfo: toolSummaries(options.Tools),
|
||||
toolTokens: gateway.EstimateTokens(string(toolSchema)),
|
||||
outcomes: m.outcomes,
|
||||
usage: m.usage,
|
||||
icons: toolIcons(m.registry),
|
||||
}, nil
|
||||
}
|
||||
@@ -81,6 +85,7 @@ type preparedChatTurnModel struct {
|
||||
toolInfo []gateway.ToolSummary
|
||||
toolTokens int
|
||||
outcomes *providerOutcomeRecorder
|
||||
usage *usageSink
|
||||
// icons maps tool name to the icon that tool registered, for chat
|
||||
// surfaces to render. A nil map yields "" for every lookup, which is
|
||||
// the no-icon rendering.
|
||||
@@ -202,5 +207,5 @@ func (m *preparedChatTurnModel) Generate(
|
||||
if m.llm == nil {
|
||||
return "", fmt.Errorf("llm chat: no model runtime is configured")
|
||||
}
|
||||
return sendChatTurn(ctx, m.llm, m.model, options, stream, m.outcomes, m.icons)
|
||||
return sendChatTurn(ctx, m.llm, m.model, options, stream, m.outcomes, m.usage, m.icons)
|
||||
}
|
||||
@@ -11,7 +11,10 @@ import (
|
||||
"github.com/samcharles93/ai-sdk/runtime"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/agentexec/modelloop"
|
||||
"github.com/samcharles93/archie-core/internal/app/controlplane"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/curator"
|
||||
"github.com/samcharles93/archie-core/internal/domain/usage"
|
||||
"github.com/samcharles93/archie-core/internal/events"
|
||||
infraMemory "github.com/samcharles93/archie-core/internal/infrastructure/memory"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/sessioncurator"
|
||||
@@ -21,6 +24,11 @@ import (
|
||||
|
||||
func (b *server) setupCurators(ctx context.Context) {
|
||||
log := b.log.With("component", "curator")
|
||||
model, err := b.chatModels.ModelFor(ctx)
|
||||
if err != nil {
|
||||
log.Warn("curators disabled: chat model unavailable", "err", err)
|
||||
return
|
||||
}
|
||||
skillsRoot := b.cfg.SkillsDir
|
||||
if skillsRoot == "" {
|
||||
skillsRoot = b.cfg.WorkDir
|
||||
@@ -32,8 +40,8 @@ func (b *server) setupCurators(ctx context.Context) {
|
||||
MemoryEngines: b.memEngines,
|
||||
Skills: skillcurator.NewStore(skillsRoot),
|
||||
Conversations: sessioncurator.NewAdapter(b.chatSessionStore, b.cfg.BotUser),
|
||||
LLM: curatorLLMRunner{llm: b.chatLLM, outcomes: b.providerOutcomes},
|
||||
Model: b.chatModels.ActiveModel(),
|
||||
LLM: curatorLLMRunner{llm: b.chatLLM, outcomes: b.providerOutcomes, usage: b.usage},
|
||||
Model: model,
|
||||
})
|
||||
|
||||
if err := b.curatorRegistry.Register(skillcurator.New(skillcurator.DefaultInterval)); err != nil {
|
||||
@@ -44,30 +52,6 @@ func (b *server) setupCurators(ctx context.Context) {
|
||||
log.Error("session-memory curator registration failed", "err", err)
|
||||
}
|
||||
|
||||
for _, def := range b.cfg.Curators {
|
||||
if !def.Enabled {
|
||||
continue
|
||||
}
|
||||
engine := curator.NewDefinitionEngine(curator.Definition{
|
||||
Name: def.Name,
|
||||
Enabled: def.Enabled,
|
||||
Instructions: def.Instructions,
|
||||
Manifest: curator.Manifest{
|
||||
Interval: def.Interval.Std(),
|
||||
Cooldown: def.Cooldown.Std(),
|
||||
OnInput: def.OnInput,
|
||||
Tools: def.Tools,
|
||||
Skills: def.Skills,
|
||||
MemoryEngine: def.MemoryEngine,
|
||||
Conversations: def.Conversations,
|
||||
Model: def.Model,
|
||||
},
|
||||
})
|
||||
if err := b.curatorRegistry.Register(engine); err != nil {
|
||||
log.Error("config curator registration failed", "curator", def.Name, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
b.curatorRuntime = curator.NewRuntime(b.curatorRegistry, curator.RuntimeConfig{})
|
||||
curator.WakeOnPrimaryInput(ctx, b.bus, b.curatorRuntime, events.KindTurnCompleted)
|
||||
rt := b.curatorRuntime
|
||||
@@ -129,6 +113,7 @@ type curatorLLMRunner struct {
|
||||
// provider is demonstrably reachable -- or worse, keeps showing a much
|
||||
// older chat outcome as current.
|
||||
outcomes *providerOutcomeRecorder
|
||||
usage *usageSink
|
||||
}
|
||||
|
||||
func (r curatorLLMRunner) Chat(ctx context.Context, req curator.ChatRequest) (curator.ChatResult, error) {
|
||||
@@ -158,6 +143,7 @@ func (r curatorLLMRunner) Chat(ctx context.Context, req curator.ChatRequest) (cu
|
||||
MaxSteps: max(req.MaxSteps, 1),
|
||||
})
|
||||
r.outcomes.record(req.Model, err)
|
||||
r.usage.record(ctx, usage.SourceCurator, req.Model, res.TotalUsage)
|
||||
if err != nil {
|
||||
return curator.ChatResult{}, err
|
||||
}
|
||||
@@ -168,3 +154,23 @@ func (r curatorLLMRunner) Chat(ctx context.Context, req curator.ChatRequest) (cu
|
||||
}
|
||||
return curator.ChatResult{Text: res.Text, ToolCalls: calls}, nil
|
||||
}
|
||||
|
||||
func (b *server) applyCurators(ctx context.Context, defs []config.CuratorDefinition) error {
|
||||
definitions := make([]curator.Definition, 0, len(defs))
|
||||
for _, def := range defs {
|
||||
definitions = append(definitions, controlplane.CuratorDefinition(def))
|
||||
}
|
||||
return b.curatorRuntime.ReplaceDefinitions(ctx, definitions)
|
||||
}
|
||||
|
||||
func (b *server) watchCurators(ctx context.Context, version int64) error {
|
||||
updates, err := b.controlPlane.WatchCurators(ctx, version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
watchStatus(ctx, b.applyStatus.Report, b.log, controlplane.CuratorsKind, "curators", version, updates, b.controlPlane.WatchCurators,
|
||||
func(update controlplane.AppliedCurators) int64 { return update.Version },
|
||||
func(update controlplane.AppliedCurators) error { return update.Err },
|
||||
func(update controlplane.AppliedCurators) error { return b.applyCurators(ctx, update.Definitions) })
|
||||
return nil
|
||||
}
|
||||
@@ -4,23 +4,27 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/controlplane"
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
"github.com/samcharles93/archie-core/internal/domain/access"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/events"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/rpcidentity"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/rpctls"
|
||||
"github.com/samcharles93/archie-core/internal/plugin"
|
||||
)
|
||||
|
||||
// serveGatewayListener is the serving tail of Run: the listener is
|
||||
// bound, the process declares itself serving, and the chat contract answers
|
||||
// until ctx ends.
|
||||
func (b *server) serveGatewayListener(ctx context.Context, listener net.Listener, loopback bool, contract gateway.ChatContract, opts []grpc.ServerOption) error {
|
||||
func (b *server) serveGatewayListener(ctx context.Context, listener net.Listener, contract gateway.ChatContract, opts []grpc.ServerOption) error {
|
||||
defer listener.Close()
|
||||
b.log.Info("archie-gateway running", "addr", listener.Addr().String(), "token_required", !loopback)
|
||||
b.log.Info("archie-gateway running", "addr", listener.Addr().String(), "tls", b.id != nil)
|
||||
// Boot is over and this listener is about to accept: the same fact
|
||||
// systemd's READY=1 asserts, so the announcement goes out here rather than
|
||||
// from a second notion of "started". Not later: Serve
|
||||
@@ -66,6 +70,18 @@ func (b *server) startGatewayRuntime(ctx context.Context, actor gateway.ChatTask
|
||||
if err := b.curatorRuntime.Start(ctx); err != nil {
|
||||
b.log.Error("curator runtime startup", "err", err)
|
||||
}
|
||||
defs, version, err := b.controlPlane.Curators(ctx)
|
||||
if err == nil {
|
||||
err = b.applyCurators(ctx, defs)
|
||||
}
|
||||
b.applyStatus.Report(ctx, controlplane.CuratorsKind, version, err)
|
||||
if err != nil {
|
||||
b.log.Error("curator definitions apply failed", "err", err)
|
||||
}
|
||||
if err := b.watchCurators(ctx, version); err != nil {
|
||||
return nil, fmt.Errorf("watch curators: %w", err)
|
||||
}
|
||||
|
||||
return contract, nil
|
||||
}
|
||||
|
||||
@@ -75,52 +91,30 @@ func (b *server) startGatewayRuntime(ctx context.Context, actor gateway.ChatTask
|
||||
// rather than rejected as an oversized gRPC message.
|
||||
const inboundMessageHeadroomBytes = 1 << 20
|
||||
|
||||
// gatewayServerOpts applies the transport security boundary: a loopback
|
||||
// listener is served insecure with no token; any non-loopback address
|
||||
// requires a Bearer [REDACTED], else the process fails closed. It mirrors
|
||||
// stateStoreServerOpts, minus the State Store's task-scoped grants: the
|
||||
// Gateway has one administrative token for all callers.
|
||||
// gatewayServerOpts serves listen with id's credentials; every caller
|
||||
// presents a service certificate.
|
||||
//
|
||||
// The receive limit is raised above gRPC's 4 MB default because an inbound
|
||||
// request carries a channel attachment's bytes: the channel frontend
|
||||
// downloads the file, and this process -- which runs the turn -- holds no
|
||||
// platform credential to fetch it again.
|
||||
func gatewayServerOpts(listen, token string) (opts []grpc.ServerOption, loopback bool, err error) {
|
||||
recv := grpc.MaxRecvMsgSize(messaging.MaxInboundAttachmentBytes + inboundMessageHeadroomBytes)
|
||||
loopback, err = gatewayrpc.TargetIsLoopback(listen)
|
||||
func gatewayServerOpts(listen string, id *rpctls.Identity, principals access.PrincipalSource) ([]grpc.ServerOption, error) {
|
||||
creds, err := id.ServerOption(listen, false)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if loopback {
|
||||
return []grpc.ServerOption{recv}, true, nil
|
||||
}
|
||||
if token == "" {
|
||||
return nil, false, fmt.Errorf(
|
||||
"gateway listen address %q is non-loopback; non-loopback exposure requires a Bearer [REDACTED] (--token / [services.gateway].target_token) or TLS",
|
||||
listen,
|
||||
)
|
||||
return nil, fmt.Errorf("gateway: %w", err)
|
||||
}
|
||||
callers := rpcidentity.Callers{Principals: principals}
|
||||
return []grpc.ServerOption{
|
||||
recv,
|
||||
grpc.ChainUnaryInterceptor(gatewayrpc.UnaryServerInterceptor(token)),
|
||||
grpc.ChainStreamInterceptor(gatewayrpc.StreamServerInterceptor(token)),
|
||||
}, false, nil
|
||||
creds,
|
||||
grpc.MaxRecvMsgSize(messaging.MaxInboundAttachmentBytes + inboundMessageHeadroomBytes),
|
||||
grpc.ChainUnaryInterceptor(callers.Unary()),
|
||||
grpc.ChainStreamInterceptor(callers.Stream()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func serveGateway(ctx context.Context, listener net.Listener, contract gateway.ChatContract, sessions gateway.SessionStore, catalog gatewayrpc.Catalog, opts []grpc.ServerOption) error {
|
||||
server := grpc.NewServer(opts...)
|
||||
server := grpc.NewServer(append(servicekit.ServerLimits(), opts...)...)
|
||||
gatewayrpc.RegisterServer(server, contract, sessions, catalog)
|
||||
serveErr := make(chan error, 1)
|
||||
go func() { serveErr <- server.Serve(listener) }()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// A client can keep a streaming RPC open indefinitely. Allow draining,
|
||||
// then force cancellation before closing the session store and tools.
|
||||
timer := time.AfterFunc(10*time.Second, server.Stop)
|
||||
server.GracefulStop()
|
||||
timer.Stop()
|
||||
return nil
|
||||
case err := <-serveErr:
|
||||
return err
|
||||
}
|
||||
// Serve's bounded drain returns before the session store and tools close.
|
||||
return servicekit.Serve(ctx, server, listener)
|
||||
}
|
||||
@@ -12,13 +12,15 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/buildinfo"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/agent"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
"github.com/samcharles93/archie-core/internal/taskstate"
|
||||
"github.com/samcharles93/archie-core/internal/tools"
|
||||
)
|
||||
|
||||
// setupChatRuntime wires the model runtime, tool registry, persona registry,
|
||||
// setupChatRuntime wires the model runtime, tool registry, SOUL,
|
||||
// chat task creator/controller, default chat identity and the release-update
|
||||
// service. The daemon and the standalone Gateway build through this one
|
||||
// constructor so the two processes cannot diverge.
|
||||
@@ -28,31 +30,17 @@ func (b *server) setupChatRuntime(ctx context.Context, cfg config.Config, actor
|
||||
// non-command message processing.
|
||||
providers := executionProviders(cfg)
|
||||
b.setLLM(modelloop.NewRuntime(providers, cfg.ModelLimits))
|
||||
// Transcription is a model-role capability, like the chat models it sits
|
||||
// Transcription is a model-alias capability, like the chat models it sits
|
||||
// beside: it is built here, on the model-owning side, from this process's
|
||||
// own [models]/[providers]. The Messaging Service carries a voice note's
|
||||
// bytes to the Gateway and never holds the credential.
|
||||
b.setupTranscriber(cfg, b.log)
|
||||
b.toolReg = tools.NewRegistry()
|
||||
chatModels := newChatModelManager(cfg.Models, cfg.Chat.Models)
|
||||
catalog, catalogModels := b.catalogState()
|
||||
chatModels.SetModelCatalog(catalog, catalogModels)
|
||||
chatModels := newChatModelManager(cfg.Models)
|
||||
catalog := b.catalogState()
|
||||
chatModels.SetModelCatalog(catalog)
|
||||
b.chatModels = chatModels
|
||||
|
||||
// ── Persona registry ─────────────────────────────────────────────
|
||||
if b.personas == nil {
|
||||
personas, version, err := b.controlPlane.Personas(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load personas: %w", err)
|
||||
}
|
||||
b.personas = gateway.NewPersonaRegistry(nil)
|
||||
b.applyPersonas(personas, version)
|
||||
b.applyStatus.Report(ctx, controlplane.PersonasKind, version, nil)
|
||||
if err := b.watchPersonas(ctx, version); err != nil {
|
||||
return fmt.Errorf("watch personas: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ── SOUL ─────────────────────────────────────────────────────────
|
||||
if b.soul == nil {
|
||||
soul, version, err := b.controlPlane.Soul(ctx)
|
||||
@@ -72,6 +60,14 @@ func (b *server) setupChatRuntime(ctx context.Context, cfg config.Config, actor
|
||||
// later carries both: the recorder is written by sendChatTurn, the source
|
||||
// is read by /status.
|
||||
b.providerOutcomes = newProviderOutcomeRecorder()
|
||||
b.usage = &usageSink{models: b.chatModels, log: b.log}
|
||||
if b.stateStore != nil {
|
||||
b.usage.store = b.stateStore
|
||||
b.chatModels.orgAliases = func(ctx context.Context) (map[string]string, error) {
|
||||
_, aliases, err := b.stateStore.CallerModels(ctx)
|
||||
return aliases, err
|
||||
}
|
||||
}
|
||||
b.statusHealth = newStatusHealth(b)
|
||||
|
||||
b.setupChatTasks(cfg)
|
||||
@@ -115,7 +111,7 @@ func watchStatus[T any](
|
||||
open func(ctx context.Context, after int64) (<-chan T, error),
|
||||
versionOf func(T) int64,
|
||||
errOf func(T) error,
|
||||
deliver func(T),
|
||||
deliver func(T) error,
|
||||
) {
|
||||
var lastApplyErr, streamErr error
|
||||
watchOpen := func(ctx context.Context, after int64) (<-chan T, error) {
|
||||
@@ -140,7 +136,8 @@ func watchStatus[T any](
|
||||
log.Error("control-plane watch failed", "kind", kind, "err", err)
|
||||
return
|
||||
}
|
||||
deliver(update)
|
||||
lastApplyErr = deliver(update)
|
||||
report(ctx, kind, versionOf(update), lastApplyErr)
|
||||
},
|
||||
func() {
|
||||
// A refusal already on the record outranks the outage; it is the
|
||||
@@ -156,40 +153,9 @@ func watchStatus[T any](
|
||||
})
|
||||
}
|
||||
|
||||
// watchPersonas keeps the persona stream established for the life of the
|
||||
// process. The first stream is opened synchronously, so a control plane that
|
||||
// cannot be watched at all fails the boot that asked for it rather than
|
||||
// leaving the process running personas it can no longer update; after that the
|
||||
// watch reconnects instead of ending (see servicekit.KeepWatch).
|
||||
func (b *server) watchPersonas(ctx context.Context, version int64) error {
|
||||
updates, err := b.controlPlane.WatchPersonas(ctx, version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
watchStatus(ctx, b.applyStatus.Report, b.log,
|
||||
controlplane.PersonasKind, "personas", version, updates,
|
||||
b.controlPlane.WatchPersonas,
|
||||
func(update controlplane.AppliedPersonas) int64 { return update.Version },
|
||||
func(update controlplane.AppliedPersonas) error { return update.Err },
|
||||
func(update controlplane.AppliedPersonas) {
|
||||
b.applyPersonas(update.Collection, update.Version)
|
||||
b.applyStatus.Report(ctx, controlplane.PersonasKind, update.Version, nil)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *server) applyPersonas(collection agent.PersonaCollection, version int64) {
|
||||
personas := make([]gateway.Persona, 0, len(collection.Personas))
|
||||
for _, persona := range collection.Personas {
|
||||
personas = append(personas, gateway.Persona{Name: persona.Name, Prompt: persona.Prompt})
|
||||
}
|
||||
b.personas.Replace(personas, collection.Default)
|
||||
b.log.Info("personas applied", "version", version)
|
||||
}
|
||||
|
||||
// watchSoul keeps the soul stream established for the life of the process, so
|
||||
// a dashboard edit reaches the next turn without a restart. The stream rides
|
||||
// the same outage bookkeeping as personas (watchStatus).
|
||||
// the same outage bookkeeping as curators (watchStatus).
|
||||
func (b *server) watchSoul(ctx context.Context, version int64) error {
|
||||
updates, err := b.controlPlane.WatchSoul(ctx, version)
|
||||
if err != nil {
|
||||
@@ -200,9 +166,9 @@ func (b *server) watchSoul(ctx context.Context, version int64) error {
|
||||
b.controlPlane.WatchSoul,
|
||||
func(update controlplane.AppliedSoul) int64 { return update.Version },
|
||||
func(update controlplane.AppliedSoul) error { return update.Err },
|
||||
func(update controlplane.AppliedSoul) {
|
||||
func(update controlplane.AppliedSoul) error {
|
||||
b.applySoul(update.Soul, update.Version)
|
||||
b.applyStatus.Report(ctx, controlplane.SoulKind, update.Version, nil)
|
||||
return nil
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -220,10 +186,10 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
|
||||
}
|
||||
cfg := b.cfg
|
||||
router := gateway.NewRouter(b.stateStore, nil, "web")
|
||||
router.Settings = messaging.NewSettingsCommand(controlplanerpc.NewSettingsClient(b.stateStore.ControlPlane())).WithIdentities(b.stateStore)
|
||||
router.Limiter = b.rateLimiter
|
||||
router.Version = fmt.Sprintf("Archie\nGateway: %s\nRuntime: %s", buildinfo.Version, buildinfo.Runtime)
|
||||
router.Models = b.chatModels
|
||||
router.Personas = b.personas
|
||||
router.Updates = b.updateService
|
||||
router.InitSessions(b.chatSessionStore)
|
||||
configureTaskCommands(router, b.chatTasks, b.chatController, chatTaskListerAdapter{tasks: b.stateStore.Tasks}, b.defaultChatIdentity)
|
||||
@@ -237,9 +203,10 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
|
||||
LLM: b.chatLLM, ChatModels: b.chatModels, ToolReg: b.toolReg,
|
||||
Soul: b.soul, ChatTasks: b.chatTasks,
|
||||
ChatTaskLister: chatTaskListerAdapter{tasks: b.stateStore.Tasks},
|
||||
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.taskLogs},
|
||||
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.stateStore},
|
||||
ChatTaskActor: actor,
|
||||
DefaultChatIdentity: b.defaultChatIdentity,
|
||||
Workflows: controlplanerpc.NewWorkflows(b.stateStore.ControlPlane()),
|
||||
Bus: b.bus, Log: b.log,
|
||||
MemoryEngine: b.memoryStore(),
|
||||
MemoryWriter: b.memoryWriter(),
|
||||
@@ -249,12 +216,14 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
|
||||
// The Gateway executes the web chat's turns, so it is the process
|
||||
// that must record their outcomes for /status.
|
||||
ProviderOutcomes: b.providerOutcomes,
|
||||
Usage: b.usage,
|
||||
}
|
||||
router.LLM, router.LLMStream = makeChatLLMResponder(ctx, "web", setup, b.chatSessionStore, router)
|
||||
router.Titles = newChatTitleGenerator(setup)
|
||||
router.Log = b.log
|
||||
return &gateway.LocalChatAdapter{
|
||||
Router: router, Sessions: b.chatSessionStore, Turns: gateway.NewTurns(b.log),
|
||||
Models: b.chatModels, Personas: b.personas, TaskActor: actor, Tasks: b.stateStore,
|
||||
Models: b.chatModels, TaskActor: actor, Tasks: b.stateStore,
|
||||
VoiceAvailable: b.transcriber != nil,
|
||||
}, nil
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -135,11 +136,7 @@ func (b *server) disconnectAbsentMCPServers(ctx context.Context, desired map[str
|
||||
// applyDesiredMCPServers connects, reconnects or restarts the servers the
|
||||
// stored document names, skipping the ones already running unchanged.
|
||||
func (b *server) applyDesiredMCPServers(ctx context.Context, desired map[string]config.MCPServer, state mcpRegistryState) []error {
|
||||
names := make([]string, 0, len(desired))
|
||||
for name := range desired {
|
||||
names = append(names, name)
|
||||
}
|
||||
slices.Sort(names)
|
||||
names := slices.Sorted(maps.Keys(desired))
|
||||
|
||||
var problems []error
|
||||
for _, name := range names {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/samcharles93/ai-sdk/core"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/agentexec/modelloop"
|
||||
"github.com/samcharles93/archie-core/internal/domain/usage"
|
||||
"github.com/samcharles93/archie-core/internal/tools/mcp"
|
||||
)
|
||||
|
||||
@@ -26,9 +27,9 @@ func (b *server) mcpSamplingHandler() mcp.SamplingHandler {
|
||||
if b.chatModels == nil {
|
||||
return mcp.SamplingResult{}, errors.New("mcp sampling: no chat model is configured")
|
||||
}
|
||||
model := b.chatModels.ActiveModel()
|
||||
if model == "" {
|
||||
return mcp.SamplingResult{}, errors.New("mcp sampling: no chat model is configured")
|
||||
model, err := b.chatModels.ModelFor(ctx)
|
||||
if err != nil {
|
||||
return mcp.SamplingResult{}, fmt.Errorf("mcp sampling: %w", err)
|
||||
}
|
||||
messages, err := modelloop.SamplingMessages(req)
|
||||
if err != nil {
|
||||
@@ -48,6 +49,7 @@ func (b *server) mcpSamplingHandler() mcp.SamplingHandler {
|
||||
// recorded for /status like every other one; a nil recorder records
|
||||
// nothing.
|
||||
b.providerOutcomes.record(model, err)
|
||||
b.usage.record(ctx, usage.SourceChat, model, result.TotalUsage)
|
||||
if err != nil {
|
||||
return mcp.SamplingResult{}, fmt.Errorf("mcp sampling: %w", err)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/applystatus"
|
||||
"github.com/samcharles93/archie-core/internal/domain/curator"
|
||||
"github.com/samcharles93/archie-core/internal/domain/health"
|
||||
domainmemory "github.com/samcharles93/archie-core/internal/domain/memory"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
@@ -28,6 +29,8 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/readiness"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/rpctls"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/secretengine"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/taskactions"
|
||||
@@ -49,9 +52,6 @@ type Options struct {
|
||||
// Listen is the gRPC listen address. Empty falls back to
|
||||
// [services.gateway].listen.
|
||||
Listen string
|
||||
// Token is the bearer token a non-loopback listener requires. Empty falls
|
||||
// back to [services.gateway].target_token.
|
||||
Token string
|
||||
}
|
||||
|
||||
// server is the Gateway process: the owner of conversations and of every
|
||||
@@ -61,9 +61,10 @@ type server struct {
|
||||
cfgHolder *config.Holder
|
||||
cfgPath string
|
||||
log *slog.Logger
|
||||
taskLogs *logging.TaskRegistry
|
||||
|
||||
secrets *secret.Registry
|
||||
id *rpctls.Identity
|
||||
engines *secretengine.Runner
|
||||
stateStore *staterpc.Client
|
||||
controlPlane *controlplane.Client
|
||||
applyStatus *applystatus.Reporter
|
||||
@@ -71,6 +72,7 @@ type server struct {
|
||||
catalog *modelcatalog.Catalog
|
||||
chatPool *pgxpool.Pool
|
||||
chatSessionStore gateway.SessionStore
|
||||
logFeed *logging.Feed
|
||||
taskActionsConn *natsio.Conn
|
||||
|
||||
bus *events.Bus
|
||||
@@ -83,12 +85,12 @@ type server struct {
|
||||
mcpMu sync.Mutex
|
||||
mcpApplied map[string]appliedMCPServer
|
||||
chatModels *chatModelManager
|
||||
personas *gateway.PersonaRegistry
|
||||
soul *soulSource
|
||||
memEngines *domainmemory.Registry
|
||||
curatorRegistry *curator.Registry
|
||||
curatorRuntime *curator.Runtime
|
||||
providerOutcomes *providerOutcomeRecorder
|
||||
usage *usageSink
|
||||
statusHealth gateway.HealthSource
|
||||
updateService *releaseupdate.Service
|
||||
|
||||
@@ -126,12 +128,7 @@ func Run(ctx context.Context, options Options) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
token := options.Token
|
||||
if token == "" {
|
||||
token = b.cfg.Services.ResolvedToken(config.ServiceNameGateway, b.secrets.Getenv)
|
||||
}
|
||||
//nolint:contextcheck // grpc.StreamServerInterceptor has no context.Context parameter; gatewayrpc.StreamServerInterceptor derives its context from stream.Context() instead
|
||||
opts, loopback, err := gatewayServerOpts(listen, token)
|
||||
opts, err := gatewayServerOpts(listen, b.id, b.stateStore)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -139,7 +136,7 @@ func Run(ctx context.Context, options Options) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("listen for gateway: %w", err)
|
||||
}
|
||||
return b.serveGatewayListener(ctx, listener, loopback, contract, opts)
|
||||
return b.serveGatewayListener(ctx, listener, contract, opts)
|
||||
}
|
||||
|
||||
func (b *server) addCleanup(fn func()) { b.cleanups = append(b.cleanups, fn) }
|
||||
@@ -164,10 +161,11 @@ func (b *server) loadConfig(cfgPath, overlayPath string) error {
|
||||
b.catalog = modelcatalog.NewCatalog(cfgPath)
|
||||
b.cfgHolder = config.NewHolder(b.cfg)
|
||||
logs := servicekit.Logging(b.cfg, "gateway")
|
||||
b.log, b.taskLogs = logs.Log, logs.TaskLogs
|
||||
b.log, b.logFeed = logs.Log, logs.Feed
|
||||
b.addCleanup(func() { _ = logs.Closer.Close() })
|
||||
b.secrets = secret.NewRegistry()
|
||||
return nil
|
||||
b.id, err = servicekit.Identity(b.cfg.TLS, presence.Gateway)
|
||||
return err
|
||||
}
|
||||
|
||||
// openState claims the conversation store, dials the State Store, starts the
|
||||
@@ -179,7 +177,7 @@ func (b *server) openState(ctx context.Context) error {
|
||||
if err := b.claimGatewayOwnership(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Gateway, b.cfg.Services, b.secrets)
|
||||
client, cleanup, err := servicekit.StateStoreClient(presence.Gateway, b.cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("state store client: %w", err)
|
||||
}
|
||||
@@ -191,7 +189,8 @@ func (b *server) openState(ctx context.Context) error {
|
||||
report := func(ctx context.Context, version int64, err error) {
|
||||
b.applyStatus.Report(ctx, controlplanerpc.ExtensionSettingsKind, version, err)
|
||||
}
|
||||
b.addCleanup(secretengine.Supervise(ctx, b.secrets, source, applystatus.Gateway, report, b.log).Close)
|
||||
b.engines = secretengine.Supervise(ctx, b.secrets, source, applystatus.Gateway, report, b.log)
|
||||
b.addCleanup(b.engines.Close)
|
||||
cfg, versions, err := b.runtimeConfig(ctx, b.cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load runtime settings: %w", err)
|
||||
@@ -199,12 +198,12 @@ func (b *server) openState(ctx context.Context) error {
|
||||
b.cfg, b.runtimeVersions = cfg, versions
|
||||
b.cfgHolder.Set(cfg)
|
||||
go b.applyStatus.Run(ctx)
|
||||
go presence.Run(ctx, presence.Gateway, servicekit.Build(), client, nil, b.log)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *server) runtimeConfig(ctx context.Context, base config.Config) (config.Config, map[string]int64, error) {
|
||||
return servicekit.RuntimeConfig(ctx, b.controlPlane, b.applyStatus, b.secrets, b.log, base, nil)
|
||||
return servicekit.RuntimeConfig(ctx, b.controlPlane, b.applyStatus, b.secrets, b.log, base, nil, gatewayRuntimeKinds)
|
||||
}
|
||||
|
||||
// connectNATS joins the broker task actions travel over. The daemon owns the
|
||||
@@ -230,6 +229,16 @@ func (b *server) connectNATS(ctx context.Context) (*natsio.Conn, error) {
|
||||
}
|
||||
b.addCleanup(nc.Close)
|
||||
b.taskActionsConn = nc
|
||||
registry := health.NewRegistry(
|
||||
readiness.NewContractProbe("state_store", b.cfg.Health.DependencyTimeout.Std(), func(ctx context.Context) error { _, err := b.stateStore.StatusCounts(ctx); return err }),
|
||||
readiness.NewContractProbe("nats", b.cfg.Health.DependencyTimeout.Std(), func(context.Context) error {
|
||||
if !nc.IsConnected() {
|
||||
return fmt.Errorf("broker disconnected")
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
)
|
||||
go presence.Run(ctx, presence.Gateway, servicekit.Build(), b.stateStore, registry, b.log)
|
||||
return nc, nil
|
||||
}
|
||||
|
||||
@@ -246,7 +255,7 @@ func (b *server) waitForNATSEndpoint(ctx context.Context) (servicekit.NATSEndpoi
|
||||
}
|
||||
}
|
||||
|
||||
func (b *server) catalogState() (modelcatalog.Snapshot, []string) { return b.catalog.State() }
|
||||
func (b *server) catalogState() modelcatalog.Snapshot { return b.catalog.State() }
|
||||
|
||||
// loadCatalog layers the model catalog under the running config. A catalog
|
||||
// that cannot be read leaves the configured providers and models in effect.
|
||||
@@ -256,9 +265,9 @@ func (b *server) loadCatalog(ctx context.Context) {
|
||||
b.log.Warn("model catalog unavailable; using configured providers and models", "err", err)
|
||||
return
|
||||
}
|
||||
models := modelcatalog.Apply(&b.cfg, snapshot)
|
||||
modelcatalog.Apply(&b.cfg, snapshot)
|
||||
b.cfgHolder.Set(b.cfg.Clone())
|
||||
b.catalog.Set(snapshot, models)
|
||||
b.catalog.Set(snapshot)
|
||||
}
|
||||
|
||||
func (b *server) startModelCatalogRefresh(ctx context.Context) {
|
||||
@@ -269,8 +278,8 @@ func (b *server) startModelCatalogRefresh(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
base := b.cfgHolder.Get().Clone()
|
||||
models := modelcatalog.Apply(&base, snapshot)
|
||||
b.catalog.Set(snapshot, models)
|
||||
modelcatalog.Apply(&base, snapshot)
|
||||
b.catalog.Set(snapshot)
|
||||
if err := b.relayer(ctx, base, ""); err != nil {
|
||||
b.log.Warn("model catalog refresh rejected with the settings; the running settings stay", "err", err)
|
||||
}
|
||||
@@ -281,11 +290,19 @@ func (b *server) startModelCatalogRefresh(ctx context.Context) {
|
||||
// chat runtime and tool providers are built from.
|
||||
var gatewayRuntimeKinds = []string{
|
||||
controlplane.ProviderSettingsKind,
|
||||
controlplane.ModelRoleAssignmentsKind,
|
||||
controlplane.ModelAliasesKind,
|
||||
controlplane.ToolSettingsKind,
|
||||
}
|
||||
|
||||
func (b *server) startRuntimeWatches(ctx context.Context) error {
|
||||
// An engine that starts after boot answers references that failed then, so
|
||||
// the providers resolve again.
|
||||
b.engines.OnChange(func() {
|
||||
base := b.cfgHolder.Get()
|
||||
catalog := b.catalogState()
|
||||
modelcatalog.Apply(&base, catalog)
|
||||
_ = b.relayer(ctx, base, controlplane.ProviderSettingsKind)
|
||||
})
|
||||
for _, kind := range gatewayRuntimeKinds {
|
||||
updates, err := b.controlPlane.WatchResource(ctx, kind, b.runtimeVersions[kind])
|
||||
if err != nil {
|
||||
@@ -320,7 +337,7 @@ func (b *server) startRuntimeWatches(ctx context.Context) error {
|
||||
return
|
||||
}
|
||||
base := b.cfgHolder.Get()
|
||||
catalog, _ := b.catalogState()
|
||||
catalog := b.catalogState()
|
||||
modelcatalog.Apply(&base, catalog)
|
||||
lastApplyErr = b.relayer(ctx, base, kind)
|
||||
},
|
||||
|
||||
@@ -40,10 +40,18 @@ func (b *server) refreshSkills(ctx context.Context, applied *string) {
|
||||
cfg, log := b.cfg, b.log
|
||||
catalog, err := skill.CatalogRoots(skill.DefaultRoots(cfg.WorkDir, cfg.SkillsDir)...)
|
||||
if err != nil {
|
||||
b.applyStatus.Report(ctx, controlplane.SkillsKind, 0, err)
|
||||
log.Warn("skill catalog load failed", "err", err)
|
||||
return
|
||||
}
|
||||
catalog = append(catalog, b.storedSkills(ctx, catalog)...)
|
||||
stored, version, err := b.storedSkills(ctx, catalog)
|
||||
if err != nil {
|
||||
b.applyStatus.Report(ctx, controlplane.SkillsKind, version, err)
|
||||
return
|
||||
}
|
||||
var applyErr error
|
||||
defer func() { b.applyStatus.Report(ctx, controlplane.SkillsKind, version, applyErr) }()
|
||||
catalog = append(catalog, stored...)
|
||||
b.setSkillList(catalog)
|
||||
signature := catalogSignature(catalog)
|
||||
if signature == *applied {
|
||||
@@ -52,6 +60,7 @@ func (b *server) refreshSkills(ctx context.Context, applied *string) {
|
||||
b.toolReg.Unregister(skillActivateTool)
|
||||
if entry := skill.ActivateTool(cfg.WorkDir, catalog); entry != nil {
|
||||
if err := b.toolReg.Register(*entry); err != nil {
|
||||
applyErr = err
|
||||
log.Warn("skill_activate registration failed", "err", err)
|
||||
return
|
||||
}
|
||||
@@ -61,10 +70,10 @@ func (b *server) refreshSkills(ctx context.Context, applied *string) {
|
||||
}
|
||||
|
||||
// storedSkills reads the skills resource, leaving out any name already in
|
||||
// have. An unreadable resource contributes nothing this round.
|
||||
func (b *server) storedSkills(ctx context.Context, have []skill.CatalogEntry) []skill.CatalogEntry {
|
||||
// have. An unreadable resource leaves the running catalog in place.
|
||||
func (b *server) storedSkills(ctx context.Context, have []skill.CatalogEntry) ([]skill.CatalogEntry, int64, error) {
|
||||
var out []skill.CatalogEntry
|
||||
_, _, err := b.controlPlane.Query(ctx, controlplane.SkillsKind, func(value []byte) error {
|
||||
version, _, err := b.controlPlane.Query(ctx, controlplane.SkillsKind, func(value []byte) error {
|
||||
var collection controlplane.SkillCollection
|
||||
if err := json.Unmarshal(value, &collection); err != nil {
|
||||
return err
|
||||
@@ -72,8 +81,7 @@ func (b *server) storedSkills(ctx context.Context, have []skill.CatalogEntry) []
|
||||
for _, held := range collection.Skills {
|
||||
entry, err := skill.EntryFromContent([]byte(held.Content))
|
||||
if err != nil {
|
||||
b.log.Warn("stored skill skipped", "skill", held.Name, "err", err)
|
||||
continue
|
||||
return err
|
||||
}
|
||||
if !slices.ContainsFunc(have, func(e skill.CatalogEntry) bool { return e.Name == entry.Name }) {
|
||||
out = append(out, entry)
|
||||
@@ -84,7 +92,7 @@ func (b *server) storedSkills(ctx context.Context, have []skill.CatalogEntry) []
|
||||
if err != nil {
|
||||
b.log.Warn("skills resource unavailable", "err", err)
|
||||
}
|
||||
return out
|
||||
return out, version, err
|
||||
}
|
||||
|
||||
func catalogSignature(catalog []skill.CatalogEntry) string {
|
||||
|
||||
@@ -8,11 +8,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/ai-sdk/provider/minimax"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/agentexec/modelloop"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/plugin"
|
||||
"github.com/samcharles93/archie-core/internal/tools/mcp"
|
||||
"github.com/samcharles93/archie-core/internal/tools/minimax"
|
||||
minimaxtool "github.com/samcharles93/archie-core/internal/tools/minimax"
|
||||
toolprovider "github.com/samcharles93/archie-core/internal/tools/provider"
|
||||
builtintoolprovider "github.com/samcharles93/archie-core/internal/tools/provider/builtin"
|
||||
mcptoolprovider "github.com/samcharles93/archie-core/internal/tools/provider/mcp"
|
||||
@@ -123,7 +125,13 @@ func (b *server) registerMinimaxTool(cfg config.Config, log *slog.Logger) {
|
||||
return
|
||||
}
|
||||
|
||||
entry := minimax.Tool(minimax.Config{Enabled: true, APIKey: apiKey, BaseURL: cfg.Tools.Minimax.BaseURL})
|
||||
provider, err := minimax.New(minimax.Config{APIKey: apiKey, BaseURL: cfg.Tools.Minimax.BaseURL})
|
||||
if err != nil {
|
||||
log.Warn("minimax video generation enabled but the provider could not be built; tool not registered", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
entry := minimaxtool.Tool(provider)
|
||||
if entry == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package archiegateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/ai-sdk/chat"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/usage"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
)
|
||||
|
||||
const usageWriteTimeout = 5 * time.Second
|
||||
|
||||
// usageSink records the gateway's model calls. The State Store bills each to
|
||||
// the org of the principal the call was made for. A nil sink records nothing.
|
||||
type usageSink struct {
|
||||
store usage.Recorder
|
||||
models gateway.ModelManager
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
// record appends one call's usage. It never fails the call: the write is
|
||||
// detached from the caller's cancellation and a failure is only logged.
|
||||
func (u *usageSink) record(ctx context.Context, source usage.Source, ref string, used chat.Usage) {
|
||||
if u == nil || u.store == nil || ref == "" {
|
||||
return
|
||||
}
|
||||
alias := ""
|
||||
if u.models != nil {
|
||||
if model, err := u.models.ModelFor(ctx); err == nil && model == ref {
|
||||
alias = u.models.ActiveAlias(ctx)
|
||||
}
|
||||
}
|
||||
record := usage.Record{
|
||||
Source: source, Alias: alias,
|
||||
InputTokens: int64(used.PromptTokens), OutputTokens: int64(used.CompletionTokens),
|
||||
CachedTokens: int64(used.CachedTokens), At: time.Now().UTC(),
|
||||
}.WithRef(ref)
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), usageWriteTimeout)
|
||||
defer cancel()
|
||||
if err := u.store.RecordUsage(ctx, record); err != nil && u.log != nil {
|
||||
u.log.Warn("record model usage failed", "source", source, "model", ref, "err", err)
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func channelDescriptors(instances []*channelInstance) []status.Descriptor {
|
||||
descriptors = append(descriptors, status.Descriptor{
|
||||
ID: instance.name,
|
||||
Name: instance.name,
|
||||
Configured: true,
|
||||
Configured: instance.current() != nil,
|
||||
// The capability comes from the same place the action does, so a
|
||||
// channel cannot declare reload support and then answer nothing.
|
||||
ReloadSupported: reloadable(instance),
|
||||
@@ -35,7 +35,14 @@ func channelDescriptors(instances []*channelInstance) []status.Descriptor {
|
||||
// a reload performs; deriving them separately is how a dashboard ends up offering
|
||||
// a button that reports success and changes nothing.
|
||||
func reloadable(instance *channelInstance) bool {
|
||||
gateway, ok := instance.current().(*telegram.Gateway)
|
||||
return channelReloadable(instance.current())
|
||||
}
|
||||
|
||||
// channelReloadable reports whether a built channel can re-read its
|
||||
// configuration in place. A disabled channel (nil) cannot, which is what a
|
||||
// channel that enablement turned off should declare.
|
||||
func channelReloadable(ch channels.Channel) bool {
|
||||
gateway, ok := ch.(*telegram.Gateway)
|
||||
return ok && gateway.Reload != nil
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ type deps struct {
|
||||
}
|
||||
|
||||
// channelInstance is one composed channel and what is needed to restart it.
|
||||
// mu guards channel and cancel.
|
||||
// mu guards every field below.
|
||||
type channelInstance struct {
|
||||
name string
|
||||
rebuild func(ResolvedConfig) (channels.Channel, error)
|
||||
@@ -68,6 +68,9 @@ type channelInstance struct {
|
||||
cancel context.CancelFunc
|
||||
supervised bool
|
||||
restartPending bool
|
||||
// notify wakes a supervisor that is between runs, so an explicit restart
|
||||
// starts the replacement instead of waiting out a backoff or a park.
|
||||
notify chan struct{}
|
||||
}
|
||||
|
||||
// current returns the channel instance currently serving, under the lock.
|
||||
@@ -108,6 +111,9 @@ type Service struct {
|
||||
appliedVersion atomic.Int64
|
||||
// reconcileInterval is how often the stored settings are re-read.
|
||||
reconcileInterval time.Duration
|
||||
// retry bounds how a supervisor retries a channel that fails on its own
|
||||
// before parking it for an explicit restart.
|
||||
retry channelRetryPolicy
|
||||
|
||||
mu sync.Mutex
|
||||
running bool
|
||||
@@ -135,6 +141,7 @@ func compose(ctx context.Context, d deps) (*Service, error) {
|
||||
if srv.reconcileInterval <= 0 {
|
||||
srv.reconcileInterval = applystatus.RestampInterval
|
||||
}
|
||||
srv.retry = defaultChannelRetry()
|
||||
|
||||
instances, err := composeChannels(ctx, d)
|
||||
if err != nil {
|
||||
@@ -153,13 +160,15 @@ func compose(ctx context.Context, d deps) (*Service, error) {
|
||||
// still restarted alone rather than through a process restart.
|
||||
func composeChannels(ctx context.Context, d deps) ([]*channelInstance, error) {
|
||||
instances := make([]*channelInstance, 0, 3)
|
||||
if d.Config.TelegramToken != "" {
|
||||
instance, err := composeTelegram(ctx, d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instances = append(instances, instance)
|
||||
// Telegram is composed whether or not it is enabled: a channel that
|
||||
// enablement can turn on has to exist for the supervisor to start. Its
|
||||
// channel is nil until a token is configured (composeTelegram). The other
|
||||
// channels are fixed by what the process can build at startup.
|
||||
telegramInstance, err := composeTelegram(ctx, d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instances = append(instances, telegramInstance)
|
||||
for _, instance := range d.ExtensionChannels {
|
||||
if slices.ContainsFunc(instances, func(have *channelInstance) bool { return have.name == instance.name }) {
|
||||
d.Log.Warn("channel extension skipped: a built-in channel has the same name", "channel", instance.name)
|
||||
@@ -167,18 +176,21 @@ func composeChannels(ctx context.Context, d deps) ([]*channelInstance, error) {
|
||||
}
|
||||
instances = append(instances, instance)
|
||||
}
|
||||
for _, instance := range instances {
|
||||
instance.notify = make(chan struct{}, 1)
|
||||
}
|
||||
return instances, nil
|
||||
}
|
||||
|
||||
func composeTelegram(ctx context.Context, d deps) (*channelInstance, error) {
|
||||
if len(d.Config.Telegram.AllowedUserIDs) == 0 {
|
||||
d.Log.Warn("chat.telegram has no allowed_user_ids: every sender will be rejected. " +
|
||||
"Add your Telegram user id to chat.telegram.allowed_user_ids to enable the bot.")
|
||||
}
|
||||
build := func(cfg ResolvedConfig) (channels.Channel, error) {
|
||||
if cfg.TelegramToken == "" {
|
||||
return nil, nil
|
||||
}
|
||||
if len(cfg.Telegram.AllowedUserIDs) == 0 {
|
||||
d.Log.Warn("chat.telegram has no allowed_user_ids: every sender will be rejected. " +
|
||||
"Add your Telegram user id to chat.telegram.allowed_user_ids to enable the bot.")
|
||||
}
|
||||
tg := telegram.New(cfg.TelegramToken, cfg.Telegram.AllowedUserIDs, d.Log)
|
||||
tg.Settings = d.Settings
|
||||
configureTelegram(ctx, tg, cfg, d)
|
||||
|
||||
@@ -8,22 +8,23 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/rpctls"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
|
||||
// ResolvedConfig contains the resolved inputs needed by the Messaging Service.
|
||||
type ResolvedConfig struct {
|
||||
Options Options
|
||||
Options Options
|
||||
// Identity is this process's certificate; nil is plaintext, loopback only.
|
||||
Identity *rpctls.Identity
|
||||
TelegramToken string
|
||||
Telegram config.TelegramConfig
|
||||
// WorkDir, BotUser and HealthURL are not channel transport settings. They
|
||||
// locate this identity's release-announcement and update-report state
|
||||
// files, and give the update installer the daemon health endpoint to poll
|
||||
// after it applies one.
|
||||
// WorkDir and BotUser are not channel transport settings. They locate
|
||||
// this identity's release-announcement and update-report state files.
|
||||
WorkDir string
|
||||
BotUser string
|
||||
HealthURL string
|
||||
ShowToolCalls bool
|
||||
}
|
||||
|
||||
@@ -31,10 +32,10 @@ type projection struct {
|
||||
gateway ServiceTarget
|
||||
stateStore ServiceTarget
|
||||
messaging config.ServiceConnection
|
||||
tls config.TLS
|
||||
telegram config.TelegramConfig
|
||||
workDir string
|
||||
botUser string
|
||||
healthURL string
|
||||
showToolCalls bool
|
||||
}
|
||||
|
||||
@@ -55,17 +56,20 @@ func Resolve(o Options, log *slog.Logger) (ResolvedConfig, error) {
|
||||
}
|
||||
}
|
||||
o = withDefaults(o)
|
||||
o = withEnvTokens(o)
|
||||
if err := o.validate(); err != nil {
|
||||
return ResolvedConfig{}, err
|
||||
}
|
||||
id, err := rpctls.Load(proj.tls.CAFile, proj.tls.CertDir, presence.Messaging)
|
||||
if err != nil {
|
||||
return ResolvedConfig{}, err
|
||||
}
|
||||
|
||||
return ResolvedConfig{
|
||||
Options: o,
|
||||
Identity: id,
|
||||
Telegram: proj.telegram,
|
||||
WorkDir: proj.workDir,
|
||||
BotUser: proj.botUser,
|
||||
HealthURL: proj.healthURL,
|
||||
ShowToolCalls: proj.showToolCalls,
|
||||
}, nil
|
||||
}
|
||||
@@ -83,52 +87,27 @@ func readProjection(path, overlay string, log *slog.Logger) (projection, bool, e
|
||||
|
||||
func project(cfg config.Config) projection {
|
||||
return projection{
|
||||
gateway: ServiceTarget{
|
||||
Target: cfg.Services.Get(config.ServiceNameGateway).Target,
|
||||
Token: cfg.Services.Get(config.ServiceNameGateway).TargetToken,
|
||||
},
|
||||
stateStore: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameState).Target, Token: cfg.Services.Get(config.ServiceNameState).TargetToken},
|
||||
gateway: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameGateway).Target},
|
||||
stateStore: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameState).Target},
|
||||
messaging: cfg.Services.Get(config.ServiceNameMessaging),
|
||||
tls: cfg.TLS,
|
||||
telegram: cfg.Chat.Telegram,
|
||||
workDir: cfg.WorkDir,
|
||||
botUser: cfg.BotUser,
|
||||
healthURL: cfg.Health.URL(),
|
||||
showToolCalls: cfg.Chat.ShowToolCalls,
|
||||
}
|
||||
}
|
||||
|
||||
func withEnvTokens(o Options) Options {
|
||||
if o.Gateway.Token == "" {
|
||||
o.Gateway.Token = os.Getenv("GATEWAY_TOKEN")
|
||||
}
|
||||
if o.StateStore.Token == "" {
|
||||
o.StateStore.Token = os.Getenv("STATE_STORE_TOKEN")
|
||||
}
|
||||
if o.Token == "" {
|
||||
o.Token = os.Getenv("MESSAGING_TOKEN")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func merge(o Options, p projection) Options {
|
||||
if o.Gateway.Target == "" {
|
||||
o.Gateway.Target = p.gateway.Target
|
||||
}
|
||||
if o.Gateway.Token == "" {
|
||||
o.Gateway.Token = p.gateway.Token
|
||||
}
|
||||
if o.StateStore.Target == "" {
|
||||
o.StateStore.Target = p.stateStore.Target
|
||||
}
|
||||
if o.StateStore.Token == "" {
|
||||
o.StateStore.Token = p.stateStore.Token
|
||||
}
|
||||
if o.Listen == "" {
|
||||
o.Listen = p.messaging.Listen
|
||||
}
|
||||
if o.Token == "" {
|
||||
o.Token = p.messaging.TargetToken
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
package archiemessaging
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/channels"
|
||||
"github.com/samcharles93/archie-core/internal/channels/status"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
|
||||
// servingChannel reports itself running once it starts, which is what an
|
||||
// enable is reported active on: a channel that only reaches "starting" is not
|
||||
// serving yet.
|
||||
type servingChannel struct {
|
||||
mu sync.Mutex
|
||||
starts int
|
||||
}
|
||||
|
||||
func (c *servingChannel) Name() string { return "telegram" }
|
||||
|
||||
func (c *servingChannel) Start(ctx context.Context, _ messaging.ChatContract, lifecycle channels.Lifecycle) error {
|
||||
c.mu.Lock()
|
||||
c.starts++
|
||||
c.mu.Unlock()
|
||||
if lifecycle.Starting != nil {
|
||||
lifecycle.Starting()
|
||||
}
|
||||
if lifecycle.Running != nil {
|
||||
lifecycle.Running()
|
||||
}
|
||||
<-ctx.Done()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *servingChannel) Stop(context.Context) error { return nil }
|
||||
|
||||
func (c *servingChannel) ConfigSchema() json.RawMessage { return nil }
|
||||
|
||||
func (c *servingChannel) ValidateConfig(map[string]any) error { return nil }
|
||||
|
||||
func (c *servingChannel) count() int {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
return c.starts
|
||||
}
|
||||
|
||||
// waitCount blocks until count reaches want, so an async start is observed
|
||||
// rather than slept for.
|
||||
func waitCount(t *testing.T, count func() int, want int) {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if count() >= want {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
t.Fatalf("channel started %d times, want at least %d", count(), want)
|
||||
}
|
||||
|
||||
// startEnablementService composes and starts a service with the Telegram
|
||||
// channel's factory replaced by a scripted channel, so enablement can be driven
|
||||
// without a real bot.
|
||||
func startEnablementService(t *testing.T, ch *servingChannel) *Service {
|
||||
t.Helper()
|
||||
srv, err := compose(context.Background(), deps{Log: slog.Default()})
|
||||
if err != nil {
|
||||
t.Fatalf("compose: %v", err)
|
||||
}
|
||||
inst := srv.instanceByID("telegram")
|
||||
if inst == nil {
|
||||
t.Fatal("telegram channel was not composed")
|
||||
}
|
||||
inst.rebuild = func(ResolvedConfig) (channels.Channel, error) { return ch, nil }
|
||||
srv.retry = channelRetryPolicy{attempts: 3, backoff: time.Millisecond, maxBackoff: time.Millisecond}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
_ = srv.Start(ctx)
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Error("service did not stop after cancel")
|
||||
}
|
||||
})
|
||||
waitSupervised(t, srv, "telegram")
|
||||
return srv
|
||||
}
|
||||
|
||||
// waitSupervised blocks until the channel's supervisor exists, so an enable
|
||||
// issued right after Start is not refused for racing it.
|
||||
func waitSupervised(t *testing.T, srv *Service, id string) {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
inst := srv.instanceByID(id)
|
||||
inst.mu.Lock()
|
||||
supervised := inst.supervised
|
||||
inst.mu.Unlock()
|
||||
if supervised {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
t.Fatalf("channel %q was never supervised", id)
|
||||
}
|
||||
|
||||
func channelByID(t *testing.T, srv *Service, id string) status.Status {
|
||||
t.Helper()
|
||||
for _, st := range srv.ChannelStatus() {
|
||||
if st.ID == id {
|
||||
return st
|
||||
}
|
||||
}
|
||||
t.Fatalf("no channel %q in status", id)
|
||||
return status.Status{}
|
||||
}
|
||||
|
||||
// TestChannelEnablementAppliesLive pins that enabling and disabling a channel
|
||||
// starts and stops it without a service restart, and that its declaration
|
||||
// follows: a channel that was never configured is not reported as configured,
|
||||
// and one that enablement stopped is reported stopped and unconfigured.
|
||||
func TestChannelEnablementAppliesLive(t *testing.T) {
|
||||
ch := &servingChannel{}
|
||||
srv := startEnablementService(t, ch)
|
||||
|
||||
if before := channelByID(t, srv, "telegram"); before.Configured || before.State != status.StateStopped {
|
||||
t.Fatalf("telegram before enable = %+v, want not configured and stopped", before)
|
||||
}
|
||||
|
||||
if err := srv.enableChannel("telegram", ResolvedConfig{TelegramToken: "token"}); err != nil {
|
||||
t.Fatalf("enable: %v", err)
|
||||
}
|
||||
waitCount(t, ch.count, 1)
|
||||
if enabled := channelByID(t, srv, "telegram"); !enabled.Configured || enabled.State != status.StateRunning {
|
||||
t.Fatalf("telegram after enable = %+v, want configured and running", enabled)
|
||||
}
|
||||
|
||||
if err := srv.disableChannel("telegram"); err != nil {
|
||||
t.Fatalf("disable: %v", err)
|
||||
}
|
||||
if disabled := channelByID(t, srv, "telegram"); disabled.Configured || disabled.State != status.StateStopped {
|
||||
t.Fatalf("telegram after disable = %+v, want not configured and stopped", disabled)
|
||||
}
|
||||
}
|
||||
|
||||
// fakeSettings serves a stored chat config at a version, the way the
|
||||
// control-plane client does.
|
||||
type fakeSettings struct {
|
||||
chat config.ChatConfig
|
||||
version int64
|
||||
}
|
||||
|
||||
func (f fakeSettings) RuntimeChatConfig(context.Context, config.ChatConfig) (config.ChatConfig, int64, error) {
|
||||
return f.chat, f.version, nil
|
||||
}
|
||||
|
||||
// fakeEngine resolves every key, so a stored token reference is resolvable.
|
||||
type fakeEngine struct{}
|
||||
|
||||
func (fakeEngine) Name() string { return "test" }
|
||||
func (fakeEngine) Resolve(key string) (string, error) { return "token-" + key, nil }
|
||||
|
||||
// TestReconcileOnceEnablesAndDisables drives the whole stored-settings path:
|
||||
// a settings version that configures a token enables the channel and is
|
||||
// recorded as applied only once the channel is running it; a later version
|
||||
// that clears the token disables it.
|
||||
func TestReconcileOnceEnablesAndDisables(t *testing.T) {
|
||||
ch := &servingChannel{}
|
||||
srv := startEnablementService(t, ch)
|
||||
srv.secrets = secret.NewRegistry()
|
||||
srv.secrets.Register(fakeEngine{})
|
||||
|
||||
srv.settingsSource = fakeSettings{
|
||||
chat: config.ChatConfig{Telegram: config.TelegramConfig{Token: secret.SecretRef{Engine: "test", Key: "bot"}}},
|
||||
version: 1,
|
||||
}
|
||||
if err := srv.reconcileOnce(context.Background()); err != nil {
|
||||
t.Fatalf("reconcile enable: %v", err)
|
||||
}
|
||||
waitCount(t, ch.count, 1)
|
||||
if got := channelByID(t, srv, "telegram"); !got.Configured {
|
||||
t.Fatalf("telegram not enabled by reconcile: %+v", got)
|
||||
}
|
||||
if srv.appliedVersion.Load() != 1 {
|
||||
t.Fatalf("appliedVersion = %d after enable, want 1", srv.appliedVersion.Load())
|
||||
}
|
||||
|
||||
srv.settingsSource = fakeSettings{version: 2}
|
||||
if err := srv.reconcileOnce(context.Background()); err != nil {
|
||||
t.Fatalf("reconcile disable: %v", err)
|
||||
}
|
||||
if got := channelByID(t, srv, "telegram"); got.Configured || got.State != status.StateStopped {
|
||||
t.Fatalf("telegram not disabled by reconcile: %+v", got)
|
||||
}
|
||||
if srv.appliedVersion.Load() != 2 {
|
||||
t.Fatalf("appliedVersion = %d after disable, want 2", srv.appliedVersion.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// TestApplyChannelSettingsEnablesAndDisables pins the reconcile entry point:
|
||||
// a settings change that turns a channel on or off starts or stops it and
|
||||
// reports applied, and a tick that changes nothing is a no-op.
|
||||
func TestApplyChannelSettingsEnablesAndDisables(t *testing.T) {
|
||||
ch := &servingChannel{}
|
||||
srv := startEnablementService(t, ch)
|
||||
|
||||
applied, err := srv.applyChannelSettings(ResolvedConfig{TelegramToken: "token"})
|
||||
if err != nil || !applied {
|
||||
t.Fatalf("enable: applied=%v err=%v", applied, err)
|
||||
}
|
||||
waitCount(t, ch.count, 1)
|
||||
if got := channelByID(t, srv, "telegram"); !got.Configured || got.State == status.StateStopped {
|
||||
t.Fatalf("telegram not enabled: %+v", got)
|
||||
}
|
||||
|
||||
applied, err = srv.applyChannelSettings(ResolvedConfig{})
|
||||
if err != nil || !applied {
|
||||
t.Fatalf("disable: applied=%v err=%v", applied, err)
|
||||
}
|
||||
if got := channelByID(t, srv, "telegram"); got.Configured || got.State != status.StateStopped {
|
||||
t.Fatalf("telegram not disabled: %+v", got)
|
||||
}
|
||||
|
||||
applied, err = srv.applyChannelSettings(ResolvedConfig{})
|
||||
if err != nil || !applied {
|
||||
t.Fatalf("no-op tick: applied=%v err=%v", applied, err)
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,6 @@ package archiemessaging
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -18,11 +15,9 @@ const (
|
||||
defaultShutdownTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
// ServiceTarget is one remote contract's endpoint and the service-to-service
|
||||
// bearer token this process presents to it.
|
||||
// ServiceTarget is one remote contract's endpoint.
|
||||
type ServiceTarget struct {
|
||||
Target string
|
||||
Token string
|
||||
}
|
||||
|
||||
// Options contains the process inputs for the Messaging Service.
|
||||
@@ -32,10 +27,8 @@ type Options struct {
|
||||
|
||||
Gateway ServiceTarget
|
||||
StateStore ServiceTarget
|
||||
// Listen is where MessagingService is served; Token is the bearer token
|
||||
// its callers present on a non-loopback address.
|
||||
// Listen is where MessagingService is served.
|
||||
Listen string
|
||||
Token string
|
||||
DependencyTimeout time.Duration
|
||||
ShutdownTimeout time.Duration
|
||||
}
|
||||
@@ -60,35 +53,5 @@ func (o Options) validate() error {
|
||||
if o.Gateway.Target == "" {
|
||||
return errors.New("gateway target is required (pass -gateway-target or configure [services.gateway].target)")
|
||||
}
|
||||
if err := validateServiceTarget("gateway", o.Gateway); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.StateStore.Target != "" {
|
||||
if err := validateServiceTarget("state store", o.StateStore); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return validateServiceTarget("messaging listen", ServiceTarget{Target: o.Listen, Token: o.Token})
|
||||
}
|
||||
|
||||
func validateServiceTarget(serviceName string, target ServiceTarget) error {
|
||||
host, _, err := net.SplitHostPort(target.Target)
|
||||
if err != nil {
|
||||
host = target.Target
|
||||
}
|
||||
if isLoopback(host) {
|
||||
return nil
|
||||
}
|
||||
if target.Token == "" {
|
||||
return fmt.Errorf("%s target %q is non-loopback and requires a bearer token", serviceName, target.Target)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isLoopback(host string) bool {
|
||||
if host == "localhost" {
|
||||
return true
|
||||
}
|
||||
ip := net.ParseIP(strings.Trim(host, "[]"))
|
||||
return ip != nil && ip.IsLoopback()
|
||||
}
|
||||
@@ -85,30 +85,32 @@ func resolveChatSecrets(base ResolvedConfig, layered config.ChatConfig, secrets
|
||||
return next, nil
|
||||
}
|
||||
|
||||
// applyChannelSettings restarts only channels whose transport settings
|
||||
// changed and reports whether every restart succeeded. Enabling or
|
||||
// disabling a channel or changing a listen address needs a process restart.
|
||||
// applyChannelSettings applies the changed channel settings: channels whose
|
||||
// enablement changed are started or stopped, channels whose transport settings
|
||||
// changed are restarted, and the report is success only once every change is in
|
||||
// effect.
|
||||
func (s *Service) applyChannelSettings(next ResolvedConfig) (bool, error) {
|
||||
current := s.currentConfig()
|
||||
effective, outstanding := pinProcessBindings(current, next)
|
||||
|
||||
if next.ShowToolCalls != current.ShowToolCalls {
|
||||
s.applyShowToolCalls(next.ShowToolCalls)
|
||||
}
|
||||
|
||||
applied := true
|
||||
for _, id := range channelChanges(current, effective) {
|
||||
if err := s.restartChannel(id, effective); err != nil {
|
||||
outstanding := s.applyChannelEnablement(current, next)
|
||||
if len(outstanding) > 0 {
|
||||
applied = false
|
||||
}
|
||||
for _, id := range channelChanges(current, next) {
|
||||
if err := s.restartChannel(id, next); err != nil {
|
||||
outstanding = append(outstanding, err.Error())
|
||||
applied = false
|
||||
}
|
||||
}
|
||||
// A failed restart leaves the running configuration in place, so the next
|
||||
// tick sees the same change and retries it. A change that was carried out
|
||||
// (including a binding change that was refused and reported) is recorded, so
|
||||
// it is not applied again on every tick.
|
||||
// A failed change leaves the running configuration in place, so the next
|
||||
// tick sees the same difference and retries it.
|
||||
if applied {
|
||||
s.setConfig(effective)
|
||||
s.setConfig(next)
|
||||
}
|
||||
if len(outstanding) == 0 {
|
||||
return applied, nil
|
||||
@@ -116,6 +118,24 @@ func (s *Service) applyChannelSettings(next ResolvedConfig) (bool, error) {
|
||||
return applied, errors.New(strings.Join(outstanding, "; "))
|
||||
}
|
||||
|
||||
// applyChannelEnablement starts or stops the channels whose enablement the
|
||||
// stored settings changed, and reports only once the requested state is in
|
||||
// effect. A channel whose enablement did not change is left alone.
|
||||
func (s *Service) applyChannelEnablement(current, next ResolvedConfig) []string {
|
||||
var outstanding []string
|
||||
switch {
|
||||
case current.TelegramToken != "" && next.TelegramToken == "":
|
||||
if err := s.disableChannel("telegram"); err != nil {
|
||||
outstanding = append(outstanding, err.Error())
|
||||
}
|
||||
case current.TelegramToken == "" && next.TelegramToken != "":
|
||||
if err := s.enableChannel("telegram", next); err != nil {
|
||||
outstanding = append(outstanding, err.Error())
|
||||
}
|
||||
}
|
||||
return outstanding
|
||||
}
|
||||
|
||||
// applyShowToolCalls updates the running Telegram gateways in place. Nothing
|
||||
// else consumes the setting, and it is read per reply, so it needs no restart.
|
||||
func (s *Service) applyShowToolCalls(show bool) {
|
||||
@@ -126,28 +146,14 @@ func (s *Service) applyShowToolCalls(show bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// pinProcessBindings holds the values a running process cannot change in place:
|
||||
// the set of channels it composed.
|
||||
// The returned configuration keeps the running value for each, and the returned
|
||||
// problems name what the operator changed and when it takes effect.
|
||||
func pinProcessBindings(current, next ResolvedConfig) (ResolvedConfig, []string) {
|
||||
effective := next
|
||||
var problems []string
|
||||
|
||||
if (current.TelegramToken != "") != (next.TelegramToken != "") {
|
||||
problems = append(problems, "chat.telegram enabled/disabled; takes effect on restart")
|
||||
effective.Telegram, effective.TelegramToken = current.Telegram, current.TelegramToken
|
||||
}
|
||||
return effective, problems
|
||||
}
|
||||
|
||||
// channelChanges returns the composed channels whose transport settings differ
|
||||
// between the running and the effective configuration. A channel absent from
|
||||
// current (not composed) never appears, and an unchanged channel is not
|
||||
// restarted.
|
||||
// between the running and the next configuration while remaining enabled. A
|
||||
// channel absent from current (not composed) never appears, an unchanged
|
||||
// channel is not restarted, and an enable or disable is applied as enablement
|
||||
// rather than as a transport change.
|
||||
func channelChanges(current, next ResolvedConfig) []string {
|
||||
var changed []string
|
||||
if current.TelegramToken != "" &&
|
||||
if current.TelegramToken != "" && next.TelegramToken != "" &&
|
||||
(current.TelegramToken != next.TelegramToken || !slices.Equal(current.Telegram.AllowedUserIDs, next.Telegram.AllowedUserIDs)) {
|
||||
changed = append(changed, "telegram")
|
||||
}
|
||||
|
||||
Loaded 100 of 892 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user