Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
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:
|
||||
@@ -73,22 +73,6 @@ jobs:
|
||||
- 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
|
||||
@@ -39,22 +46,6 @@ jobs:
|
||||
|
||||
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
|
||||
@@ -5,6 +5,82 @@ release's per-component sections are labelled beneath its heading.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
+34
-10
@@ -125,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:
|
||||
@@ -147,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)
|
||||
@@ -175,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]
|
||||
@@ -245,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:
|
||||
@@ -273,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
|
||||
@@ -285,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
|
||||
@@ -343,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:
|
||||
|
||||
+3
-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,8 +246,8 @@ _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. |
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ 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
|
||||
@@ -90,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")
|
||||
|
||||
@@ -27,19 +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.StringVar(&options.Harness.Token, "harness-token", "", "bearer token presented to the daemon's harness contract")
|
||||
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))
|
||||
}
|
||||
|
||||
+20
-21
@@ -246,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
|
||||
@@ -259,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)
|
||||
@@ -267,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
|
||||
@@ -283,25 +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 target_token (or HARNESS_TOKEN) is set, and
|
||||
# archie-ui dials it only when a target is set.
|
||||
# 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.
|
||||
# target_token = "..." # REQUIRED, even on loopback: a session is a
|
||||
# # shell in a container that holds an org credential.
|
||||
# # The daemon reads the same value to authenticate its
|
||||
# # clients. Leave unset to disable the listener.
|
||||
|
||||
# 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.
|
||||
@@ -78,6 +78,11 @@
|
||||
"/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.6.0/": "/news/1.6.0/",
|
||||
"/news/archie/1.7.0/": "/news/1.7.0/",
|
||||
"/news/archie/1.8.0/": "/news/1.8.0/",
|
||||
@@ -172,6 +177,11 @@
|
||||
"/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.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,29 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -193,11 +193,51 @@ established egress phase differ.
|
||||
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.** Deferred (`archie-core-qi91`). `Open` answers `Unimplemented`
|
||||
for it in the setup slice. A finished or absent attempt will be `NotFound`,
|
||||
not `Unavailable`.
|
||||
- **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.
|
||||
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.
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -4,34 +4,28 @@ 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-20261008225312-e8a9660d7aea // indirect
|
||||
github.com/Microsoft/go-winio v0.6.3 // 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.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/hashicorp/yamux v0.1.2 // indirect
|
||||
@@ -39,38 +33,27 @@ require (
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // 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.1 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect
|
||||
github.com/magiconair/properties v1.18.12 // 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.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.5.0 // indirect
|
||||
github.com/shirou/gopsutil/v4 v4.26.9 // 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.72.0 // indirect
|
||||
go.opentelemetry.io/otel v1.47.0 // indirect
|
||||
@@ -79,26 +62,27 @@ require (
|
||||
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-20261007192929-f45ad48fbe92 // 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-20261005182115-fad411399dd8 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8 // 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/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
|
||||
@@ -107,24 +91,23 @@ require (
|
||||
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.43
|
||||
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.60.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
|
||||
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,16 +2,10 @@ 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-20261008225312-e8a9660d7aea h1:NdVLskj4PaItpD133shAdyHicndDbcDGpManoqR032g=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20261008225312-e8a9660d7aea/go.mod h1:Ue4ymb+lBljb9NjkybMTsOYOSjH/cJTim9nrhvRJAUU=
|
||||
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.3 h1:M/52tsoyTfwaxajLnXZm7PqkbMGRH8iSWP+8fcg9MQ4=
|
||||
github.com/Microsoft/go-winio v0.6.3/go.mod h1:ma0QpxizD4fyyzJ1C7MIblymTD2Nxz5Mho/3CepwIZg=
|
||||
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=
|
||||
@@ -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,10 +34,6 @@ 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=
|
||||
@@ -54,12 +42,10 @@ github.com/docker/go-connections v0.8.2 h1:9d9DEokx5W7qlr0shkFXIxEA7+TTD+llwzcyk
|
||||
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,6 +53,8 @@ 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=
|
||||
@@ -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=
|
||||
@@ -121,8 +114,8 @@ github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5Xum
|
||||
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.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
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=
|
||||
@@ -130,12 +123,6 @@ 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.16 h1:+2YjeAe7xP1OQbZW1jERPWWCDLlNqFNCvjiqGiAt84A=
|
||||
@@ -144,69 +131,51 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
|
||||
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.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/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/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/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/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.43 h1:u/OER6FuRv/KkS/5xnRttABPD2UNHR2BmcJeRe07hyw=
|
||||
github.com/samcharles93/ai-sdk v0.1.43/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=
|
||||
@@ -215,31 +184,21 @@ 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.5.0 h1:JYfFKmVJ8ER06GReN1efzc5cm52BrVsFVzmcHiKJwfY=
|
||||
github.com/sethvargo/go-retry v0.5.0/go.mod h1:tvsjdKG6xfiCx4LSiUZ06kcv38xvdVQwv8R6/VnnVWg=
|
||||
github.com/shirou/gopsutil/v4 v4.26.9 h1:CaBo/hBFqvlJoLvAQEKdHdf5GD97/MN2ACfyv63+2Ig=
|
||||
github.com/shirou/gopsutil/v4 v4.26.9/go.mod h1:nKH+8wX2zxr/mDbsR+AAy6Qd2z4ZOQ7wfQaEp+yrYmg=
|
||||
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=
|
||||
@@ -262,47 +221,47 @@ go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV
|
||||
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-20261007192929-f45ad48fbe92 h1:kc+Gi2MFkd0KWtdDlVxVwjw4KB98/77usJDFj+6YFQ8=
|
||||
golang.org/x/exp v0.0.0-20261007192929-f45ad48fbe92/go.mod h1:SRjTzy5WcYqRRqquLUvHeeovSwLO0CZ3xcltZNO4Fck=
|
||||
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.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
|
||||
golang.org/x/net v0.60.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-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.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI=
|
||||
golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA=
|
||||
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-20261005182115-fad411399dd8 h1:cFbkNigDInw+wVTXc+CyhUsoHGJCw0BR6mlNoRVfre0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261005182115-fad411399dd8/go.mod h1:QK6p7IgD7IZEZJBhhSUCib5X2vMOzlrGCGUw2XyVDh0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8 h1:0SXBqli5dnuCKMjI/X3FM226zEaEa0GUcSCJtN1vL2o=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||
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=
|
||||
@@ -318,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
"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"
|
||||
@@ -48,6 +50,15 @@ 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 {
|
||||
@@ -115,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
|
||||
@@ -130,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"
|
||||
|
||||
@@ -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"
|
||||
@@ -66,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
|
||||
@@ -96,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.
|
||||
@@ -105,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
|
||||
@@ -161,6 +163,9 @@ type boot struct {
|
||||
// kitLauncher starts Kit profile tasks; nil when the egress path cannot
|
||||
// be built on this host.
|
||||
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
|
||||
@@ -197,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()
|
||||
}
|
||||
|
||||
@@ -260,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
|
||||
@@ -459,20 +474,21 @@ 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
|
||||
}
|
||||
@@ -522,7 +538,7 @@ 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
|
||||
@@ -562,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,
|
||||
@@ -574,6 +591,8 @@ 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,
|
||||
@@ -671,14 +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) configViewInput() webui.ConfigViewInput {
|
||||
catalog, _ := b.catalogState()
|
||||
catalog := b.catalogState()
|
||||
in := webui.ConfigViewInput{
|
||||
Config: b.cfgHolder.Get(),
|
||||
Catalog: catalogView(catalog),
|
||||
Config: b.cfgHolder.Get(),
|
||||
Catalog: catalogView(catalog),
|
||||
SecretEngines: b.secrets.List(),
|
||||
}
|
||||
if b.lastReload != nil {
|
||||
status := b.lastReload()
|
||||
@@ -776,6 +797,7 @@ func (b *boot) runLoop(ctx context.Context, once bool) error {
|
||||
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
|
||||
@@ -799,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.
|
||||
@@ -811,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))
|
||||
}
|
||||
|
||||
@@ -826,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
|
||||
@@ -841,7 +863,22 @@ func (b *boot) startModelCatalogRefresh(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (b *boot) livePlaybooks() *controlplane.LivePlaybooks {
|
||||
live := controlplane.NewLivePlaybooks(b.controlPlaneRPC, b.log)
|
||||
live.ApplyStatus = b.applyStatus
|
||||
return live
|
||||
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
|
||||
@@ -264,7 +264,7 @@ func (b *boot) startLiveSettings(ctx context.Context) error {
|
||||
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 {
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -17,8 +16,9 @@ import (
|
||||
|
||||
"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/infrastructure/harnessrpc"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/harnesssession"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/kitrun"
|
||||
)
|
||||
@@ -69,11 +69,13 @@ func (g *sessionGrants) GrantedFor(token string) (string, []string, bool) {
|
||||
type harnessServer struct {
|
||||
pb.UnimplementedHarnessServiceServer
|
||||
sessions *harnesssession.Manager
|
||||
log *slog.Logger
|
||||
// runs serves the run target; nil answers Unavailable.
|
||||
runs *runView
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
// Open dispatches on the first frame's target. Setup sessions are served; the
|
||||
// run-scoped target is reserved for archie-core-qi91.
|
||||
// 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 {
|
||||
@@ -90,7 +92,10 @@ func (h *harnessServer) Open(stream pb.HarnessService_OpenServer) error {
|
||||
}
|
||||
return h.openSetup(stream, target.GetOrg(), t.Setup.GetProfile(), first.GetSize())
|
||||
case *pb.OpenTarget_Run:
|
||||
return status.Error(codes.Unimplemented, "run-scoped sessions are not served yet")
|
||||
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")
|
||||
}
|
||||
@@ -183,9 +188,18 @@ func (b *boot) setupHarness(ctx context.Context) {
|
||||
b.log.Warn("harness sessions disabled", "err", err)
|
||||
return
|
||||
}
|
||||
token := b.cfg.Services.ResolvedToken(config.ServiceNameHarness, os.Getenv)
|
||||
if token == "" {
|
||||
b.log.Warn("harness sessions disabled: [services.harness].target_token or HARNESS_TOKEN is required, even on loopback")
|
||||
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)
|
||||
@@ -199,11 +213,8 @@ func (b *boot) setupHarness(ctx context.Context) {
|
||||
Profile: func(name string) (config.AgentProfile, error) { return b.cfgHolder.Get().Containers.Profile(name) },
|
||||
TTL: setupSessionTTL,
|
||||
}
|
||||
srv := grpc.NewServer(
|
||||
//nolint:contextcheck // grpc.StreamServerInterceptor has no context.Context parameter; the interceptor derives its context from stream.Context()
|
||||
grpc.StreamInterceptor(harnessrpc.StreamServerInterceptor(token)),
|
||||
)
|
||||
pb.RegisterHarnessServiceServer(srv, &harnessServer{sessions: manager, log: b.log})
|
||||
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)
|
||||
@@ -222,3 +233,19 @@ func (b *boot) setupHarness(ctx context.Context) {
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -63,7 +58,7 @@ func (b *boot) setupKitLauncher(ctx context.Context) {
|
||||
// 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, config: b.cfgHolder, secrets: b.secrets}
|
||||
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)
|
||||
@@ -74,6 +69,15 @@ 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(),
|
||||
|
||||
@@ -126,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 {
|
||||
@@ -185,7 +185,7 @@ 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 {
|
||||
@@ -207,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 {
|
||||
@@ -356,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 {
|
||||
@@ -365,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)
|
||||
|
||||
@@ -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"}
|
||||
}
|
||||
@@ -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"
|
||||
)
|
||||
@@ -24,16 +26,21 @@ type runCredentialResolver struct {
|
||||
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(org, services, service)
|
||||
return r.resolveBinding(ctx, org, services, service)
|
||||
}
|
||||
}
|
||||
task, err := r.runs.TaskForCredential(ctx, credential)
|
||||
@@ -41,14 +48,20 @@ func (r runCredentialResolver) Resolve(ctx context.Context, credential, service
|
||||
return "", egress.ErrUnbound
|
||||
}
|
||||
cfg := r.config.Get()
|
||||
org, granted := cfg.CredentialAccess(task.Identity)
|
||||
return r.resolveBinding(org, granted, service)
|
||||
_, 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(org string, granted []string, service string) (string, error) {
|
||||
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 {
|
||||
@@ -60,5 +73,24 @@ func (r runCredentialResolver) resolveBinding(org string, granted []string, serv
|
||||
if r.secrets == nil {
|
||||
return "", egress.ErrUnbound
|
||||
}
|
||||
return r.secrets.Resolve(binding.Secret)
|
||||
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) {
|
||||
@@ -79,7 +87,7 @@ func TestEgressResolvesASessionGrant(t *testing.T) {
|
||||
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"}},
|
||||
runs: runsByToken{"acme-run": {ID: 1, Identity: "acme-bot", Org: "acme"}},
|
||||
sessions: sessions,
|
||||
config: config.NewHolder(cfg),
|
||||
secrets: secretValues{"ACME_GH": "acme-gh"},
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -25,9 +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{
|
||||
Logs: b.recentLogs,
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"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"
|
||||
@@ -23,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
|
||||
@@ -34,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 {
|
||||
@@ -107,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) {
|
||||
@@ -136,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
|
||||
}
|
||||
|
||||
@@ -4,26 +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
|
||||
@@ -90,53 +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, principals access.PrincipalSource) (opts []grpc.ServerOption, loopback bool, err error) {
|
||||
callers := rpcidentity.Callers{Principals: principals}
|
||||
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, grpc.ChainUnaryInterceptor(callers.Unary()), grpc.ChainStreamInterceptor(callers.Stream())}, 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), callers.Unary()),
|
||||
grpc.ChainStreamInterceptor(gatewayrpc.StreamServerInterceptor(token), callers.Stream()),
|
||||
}, 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)
|
||||
}
|
||||
@@ -30,15 +30,15 @@ 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 ─────────────────────────────────────────────
|
||||
@@ -74,6 +74,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)
|
||||
@@ -244,6 +252,7 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
|
||||
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(),
|
||||
@@ -253,6 +262,7 @@ 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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"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"
|
||||
@@ -51,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
|
||||
@@ -65,6 +63,7 @@ type server struct {
|
||||
log *slog.Logger
|
||||
|
||||
secrets *secret.Registry
|
||||
id *rpctls.Identity
|
||||
engines *secretengine.Runner
|
||||
stateStore *staterpc.Client
|
||||
controlPlane *controlplane.Client
|
||||
@@ -92,6 +91,7 @@ type server struct {
|
||||
curatorRegistry *curator.Registry
|
||||
curatorRuntime *curator.Runtime
|
||||
providerOutcomes *providerOutcomeRecorder
|
||||
usage *usageSink
|
||||
statusHealth gateway.HealthSource
|
||||
updateService *releaseupdate.Service
|
||||
|
||||
@@ -129,12 +129,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, b.stateStore)
|
||||
opts, err := gatewayServerOpts(listen, b.id, b.stateStore)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -142,7 +137,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) }
|
||||
@@ -170,7 +165,8 @@ func (b *server) loadConfig(cfgPath, overlayPath string) error {
|
||||
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
|
||||
@@ -182,7 +178,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)
|
||||
}
|
||||
@@ -208,7 +204,7 @@ func (b *server) openState(ctx context.Context) error {
|
||||
}
|
||||
|
||||
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
|
||||
@@ -260,7 +256,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.
|
||||
@@ -270,9 +266,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) {
|
||||
@@ -283,8 +279,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)
|
||||
}
|
||||
@@ -295,7 +291,7 @@ 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,
|
||||
}
|
||||
|
||||
@@ -304,7 +300,7 @@ func (b *server) startRuntimeWatches(ctx context.Context) error {
|
||||
// the providers resolve again.
|
||||
b.engines.OnChange(func() {
|
||||
base := b.cfgHolder.Get()
|
||||
catalog, _ := b.catalogState()
|
||||
catalog := b.catalogState()
|
||||
modelcatalog.Apply(&base, catalog)
|
||||
_ = b.relayer(ctx, base, controlplane.ProviderSettingsKind)
|
||||
})
|
||||
@@ -342,7 +338,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)
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/extension"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
|
||||
"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/logging"
|
||||
@@ -36,7 +37,7 @@ func Run(ctx context.Context, o Options) error {
|
||||
return fmt.Errorf("resolve messaging options: %w", err)
|
||||
}
|
||||
|
||||
chat, closeGateway, err := gatewayrpc.Dial(cfg.Options.Gateway.Target, cfg.Options.Gateway.Token)
|
||||
chat, closeGateway, err := gatewayrpc.Dial(cfg.Options.Gateway.Target, cfg.Identity)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dial gateway (%s): %w", cfg.Options.Gateway.Target, err)
|
||||
}
|
||||
@@ -59,7 +60,7 @@ func Run(ctx context.Context, o Options) error {
|
||||
var updates *releaseupdate.Service
|
||||
var extensionChannels []*channelInstance
|
||||
if cfg.Options.StateStore.Target != "" {
|
||||
stateStore, closeClient, dialErr := staterpc.Dial(cfg.Options.StateStore.Target, presence.Messaging, cfg.Options.StateStore.Token, staterpc.WaitForPeer)
|
||||
stateStore, closeClient, dialErr := staterpc.Dial(cfg.Options.StateStore.Target, presence.Messaging, cfg.Identity, staterpc.WaitForPeer)
|
||||
if dialErr != nil {
|
||||
return fmt.Errorf("dial state store control plane (%s): %w", cfg.Options.StateStore.Target, dialErr)
|
||||
}
|
||||
@@ -86,7 +87,7 @@ func Run(ctx context.Context, o Options) error {
|
||||
settings = messaging.NewSettingsCommand(controlplanerpc.NewSettingsClient(stateStore.ControlPlane())).WithIdentities(stateStore)
|
||||
channelStatusStore, presenceStore = stateStore, stateStore
|
||||
settingsSource, applyReporter, appliedVersion = controlPlaneClient, reporter, channelVersion
|
||||
updates = controlplanerpc.UpdateService(controlPlaneClient, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"), cfg.HealthURL)
|
||||
updates = controlplanerpc.UpdateService(controlPlaneClient, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"))
|
||||
}
|
||||
|
||||
if cfg.Options.StateStore.Target == "" {
|
||||
@@ -112,29 +113,37 @@ func Run(ctx context.Context, o Options) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return serve(ctx, cfg.Options, srv, log, feed)
|
||||
return serve(ctx, cfg.Options.Listen, cfg.Identity, srv, log, feed)
|
||||
}
|
||||
|
||||
// serve runs srv and serves MessagingService over it until ctx is cancelled.
|
||||
func serve(ctx context.Context, o Options, srv *Service, log *slog.Logger, feed *logging.Feed) error {
|
||||
opts, err := messagingrpc.ServerOptions(o.Listen, o.Token)
|
||||
func serve(ctx context.Context, listen string, id *rpctls.Identity, srv *Service, log *slog.Logger, feed *logging.Feed) error {
|
||||
opts, err := messagingrpc.ServerOptions(listen, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listener, err := (&net.ListenConfig{}).Listen(ctx, "tcp", o.Listen)
|
||||
listener, err := (&net.ListenConfig{}).Listen(ctx, "tcp", listen)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listen messaging (%s): %w", o.Listen, err)
|
||||
return fmt.Errorf("listen messaging (%s): %w", listen, err)
|
||||
}
|
||||
server := grpc.NewServer(opts...)
|
||||
server := grpc.NewServer(append(servicekit.ServerLimits(), opts...)...)
|
||||
messagingrpc.RegisterServer(server, srv, feed)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
// A dead listener stops the channels too: the process exits and its
|
||||
// supervisor restarts it, rather than it running on without Deliver.
|
||||
serveErr := make(chan error, 1)
|
||||
go func() {
|
||||
if err := server.Serve(listener); err != nil {
|
||||
log.Error("messaging gRPC server stopped", "err", err)
|
||||
}
|
||||
serveErr <- servicekit.Serve(ctx, server, listener)
|
||||
cancel()
|
||||
}()
|
||||
defer server.GracefulStop()
|
||||
log.Info("messaging service listening", "listen", o.Listen)
|
||||
return srv.Start(ctx)
|
||||
log.Info("messaging service listening", "listen", listen)
|
||||
startErr := srv.Start(ctx)
|
||||
cancel()
|
||||
if err := <-serveErr; err != nil {
|
||||
return fmt.Errorf("serve messaging: %w", err)
|
||||
}
|
||||
return startErr
|
||||
}
|
||||
|
||||
// superviseSecretEngines runs the secret-engine extensions and reports their
|
||||
|
||||
@@ -36,32 +36,21 @@ func Run(args []string, stderr io.Writer) int {
|
||||
return cmd(args[1:], stderr)
|
||||
}
|
||||
|
||||
// runLint validates routing binding directories (-dir) and an EDA playbook
|
||||
// directory (-eda-dir) against the loaders the daemon runs at startup.
|
||||
// Exit codes: 0 clean, 1 findings, 2 usage error.
|
||||
// runLint validates an EDA playbook directory against the compiler the daemon
|
||||
// runs. Exit codes: 0 clean, 1 findings, 2 usage error.
|
||||
func runLint(args []string, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("archied playbooks lint", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
var dirs multiFlag
|
||||
flags.Var(&dirs, "dir", "routing binding directory to lint (repeatable)")
|
||||
edaDir := flags.String("eda-dir", "", "EDA playbook directory to lint")
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 2 // flag.ContinueOnError already printed the message
|
||||
}
|
||||
if len(dirs) == 0 && *edaDir == "" {
|
||||
fmt.Fprintln(stderr, "lint: at least one -dir or an -eda-dir is required")
|
||||
if *edaDir == "" {
|
||||
fmt.Fprintln(stderr, "lint: -eda-dir is required")
|
||||
flags.Usage()
|
||||
return 2
|
||||
}
|
||||
|
||||
code := 0
|
||||
if len(dirs) > 0 {
|
||||
code = max(code, Lint(dirs, stderr).ExitCode)
|
||||
}
|
||||
if *edaDir != "" {
|
||||
code = max(code, LintEDA(*edaDir, stderr).ExitCode)
|
||||
}
|
||||
return code
|
||||
return LintEDA(*edaDir, stderr).ExitCode
|
||||
}
|
||||
|
||||
// runServe runs the language server on stdin/stdout until the editor
|
||||
@@ -87,13 +76,3 @@ type stdio struct{}
|
||||
func (stdio) Read(p []byte) (int, error) { return os.Stdin.Read(p) }
|
||||
func (stdio) Write(p []byte) (int, error) { return os.Stdout.Write(p) }
|
||||
func (stdio) Close() error { return os.Stdin.Close() }
|
||||
|
||||
// multiFlag collects repeated -dir flags.
|
||||
type multiFlag []string
|
||||
|
||||
func (m *multiFlag) String() string { return fmt.Sprint([]string(*m)) }
|
||||
|
||||
func (m *multiFlag) Set(v string) error {
|
||||
*m = append(*m, v)
|
||||
return nil
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/eda/module"
|
||||
"github.com/samcharles93/archie-core/internal/domain/eda/playbook"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
)
|
||||
|
||||
// Result is the outcome of one lint run: the exit code for the process and
|
||||
@@ -18,25 +17,6 @@ type Result struct {
|
||||
Findings []string
|
||||
}
|
||||
|
||||
// Lint validates playbook directories with workflow.LoadPlaybookDirs and
|
||||
// reports every finding. It returns 0 when clean, 1 otherwise.
|
||||
func Lint(dirs []string, stderr io.Writer) Result {
|
||||
var findings []string
|
||||
|
||||
_, _, err := workflow.LoadPlaybookDirs(dirs)
|
||||
if err != nil {
|
||||
findings = append(findings, err.Error())
|
||||
}
|
||||
|
||||
if len(findings) > 0 {
|
||||
for _, f := range findings {
|
||||
fmt.Fprintln(stderr, f)
|
||||
}
|
||||
return Result{ExitCode: 1, Findings: findings}
|
||||
}
|
||||
return Result{ExitCode: 0, Findings: nil}
|
||||
}
|
||||
|
||||
// LintEDA validates a directory of EDA playbook documents with the compiler
|
||||
// the eda-playbooks resource validates against.
|
||||
func LintEDA(dir string, stderr io.Writer) Result {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package archieplaybooks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -14,7 +12,6 @@ import (
|
||||
"go.lsp.dev/jsonrpc2"
|
||||
"go.lsp.dev/protocol"
|
||||
"go.lsp.dev/uri"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Serve runs the language server over rwc until the client disconnects or ctx
|
||||
@@ -87,12 +84,7 @@ func diagnose(u uri.URI) *protocol.PublishDiagnosticsParams {
|
||||
return out
|
||||
}
|
||||
path := u.FsPath()
|
||||
var result Result
|
||||
if isEDAPlaybook(path) {
|
||||
result = LintEDA(filepath.Dir(path), io.Discard)
|
||||
} else {
|
||||
result = Lint([]string{filepath.Dir(path)}, io.Discard)
|
||||
}
|
||||
result := LintEDA(filepath.Dir(path), io.Discard)
|
||||
for _, finding := range result.Findings {
|
||||
line, ok := findingLine(finding, path)
|
||||
if !ok {
|
||||
@@ -108,21 +100,6 @@ func diagnose(u uri.URI) *protocol.PublishDiagnosticsParams {
|
||||
return out
|
||||
}
|
||||
|
||||
// isEDAPlaybook reports whether the file is an EDA playbook document (it has
|
||||
// a top-level `trigger` key) rather than a routing binding file.
|
||||
func isEDAPlaybook(path string) bool {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
var doc map[string]yaml.Node
|
||||
if yaml.NewDecoder(bytes.NewReader(data)).Decode(&doc) != nil {
|
||||
return false
|
||||
}
|
||||
_, ok := doc["trigger"]
|
||||
return ok
|
||||
}
|
||||
|
||||
// findingLine places a finding on path. A compiler-style `path:line:` prefix
|
||||
// gives the 0-based line; a finding naming path without a line goes on line
|
||||
// 0; a finding naming another file is not path's.
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package archieui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/oidc"
|
||||
)
|
||||
|
||||
// accountOIDC reloads browser-managed provider settings without restarting UI.
|
||||
// The provider retains its discovery and signing-key cache until settings change.
|
||||
type accountOIDC struct {
|
||||
fallbackFlow identity.LoginFlow
|
||||
fallbackProvider *oidc.Provider
|
||||
settings identity.AuthenticationSettingsStore
|
||||
subjects identity.SubjectResolver
|
||||
fallback identity.AuthenticationSettings
|
||||
mu sync.Mutex
|
||||
current identity.AuthenticationSettings
|
||||
provider *oidc.Provider
|
||||
}
|
||||
|
||||
func (a *accountOIDC) flow(ctx context.Context) (identity.LoginFlow, *oidc.Verifier, error) {
|
||||
settings, err := a.settings.AuthenticationSettings(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if settings.PublicURL == "" {
|
||||
settings = a.fallback
|
||||
if a.fallbackFlow != nil {
|
||||
return a.fallbackFlow, oidc.NewVerifierForAudience(a.fallbackProvider, a.fallback.OIDCClientID), nil
|
||||
}
|
||||
}
|
||||
if settings.OIDCIssuer == "" {
|
||||
return nil, nil, identity.ErrNoCredential
|
||||
}
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.provider == nil || a.current != settings {
|
||||
provider, err := oidc.NewProvider(oidc.Config{Issuer: settings.OIDCIssuer, Audience: settings.OIDCAudience})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
a.provider, a.current = provider, settings
|
||||
}
|
||||
flow, err := oidc.NewFlow(a.provider, settings.OIDCClientID, "", settings.PublicURL+"/oauth2/callback")
|
||||
return flow, oidc.NewVerifierForAudience(a.provider, settings.OIDCClientID), err
|
||||
}
|
||||
|
||||
func (a *accountOIDC) AuthenticateBrowser(ctx context.Context, credential string) (identity.Identity, error) {
|
||||
_, verifier, err := a.flow(ctx)
|
||||
if err != nil {
|
||||
return identity.Identity{}, err
|
||||
}
|
||||
value, _, err := identity.Authenticate(ctx, a.subjects, verifier, credential)
|
||||
return value, err
|
||||
}
|
||||
|
||||
func (a *accountOIDC) AuthCodeURL(ctx context.Context, state string) (string, string, error) {
|
||||
flow, _, err := a.flow(ctx)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return flow.AuthCodeURL(ctx, state)
|
||||
}
|
||||
|
||||
func (a *accountOIDC) Exchange(ctx context.Context, code, verifier string) (identity.ProviderSession, error) {
|
||||
flow, _, err := a.flow(ctx)
|
||||
if err != nil {
|
||||
return identity.ProviderSession{}, err
|
||||
}
|
||||
return flow.Exchange(ctx, code, verifier)
|
||||
}
|
||||
|
||||
func (a *accountOIDC) Authenticate(ctx context.Context, credential string) (identity.Identity, error) {
|
||||
if subject, ok := identity.PersonalTokenSubject(credential); ok {
|
||||
return identity.Resolve(ctx, a.subjects, identity.Credential{Subject: subject})
|
||||
}
|
||||
if _, _, err := a.flow(ctx); err != nil {
|
||||
return identity.Identity{}, err
|
||||
}
|
||||
a.mu.Lock()
|
||||
provider := a.provider
|
||||
if provider == nil {
|
||||
provider = a.fallbackProvider
|
||||
}
|
||||
a.mu.Unlock()
|
||||
value, _, err := identity.Authenticate(ctx, a.subjects, oidc.NewVerifier(provider), credential)
|
||||
return value, err
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package archieui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -20,25 +18,6 @@ func signInProvider(opts Options) (*oidc.Provider, error) {
|
||||
return oidc.NewProvider(oidc.Config{Issuer: opts.OidcIssuer, Audience: opts.OidcAudience})
|
||||
}
|
||||
|
||||
// dashboardAuthenticator builds the credential check, or nil when no provider
|
||||
// is configured.
|
||||
func dashboardAuthenticator(provider *oidc.Provider, opts Options, subjects identity.SubjectResolver, log *slog.Logger) func(context.Context, string) (identity.Identity, error) {
|
||||
if provider == nil {
|
||||
return nil
|
||||
}
|
||||
verifier := oidc.NewVerifier(provider)
|
||||
log.Info("dashboard authenticates provider credentials", "issuer", opts.OidcIssuer, "audience", opts.OidcAudience)
|
||||
return func(ctx context.Context, credential string) (identity.Identity, error) {
|
||||
// A personal token is bound in the State Store, not issued by the
|
||||
// provider, so it resolves without the provider's verifier.
|
||||
if subject, ok := identity.PersonalTokenSubject(credential); ok {
|
||||
return identity.Resolve(ctx, subjects, identity.Credential{Subject: subject})
|
||||
}
|
||||
value, _, err := identity.Authenticate(ctx, subjects, verifier, credential)
|
||||
return value, err
|
||||
}
|
||||
}
|
||||
|
||||
// dashboardLoginFlow builds the browser sign-in flow, or nil when not
|
||||
// configured. The client secret is read from the named env var.
|
||||
func dashboardLoginFlow(provider *oidc.Provider, opts Options) (identity.LoginFlow, error) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package archieui
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
@@ -37,7 +38,8 @@ type deps struct {
|
||||
Identities identity.Repository
|
||||
// Authenticate resolves a presented credential to the identity that may
|
||||
// act. Nil when no provider is configured, which keeps the shared token.
|
||||
Authenticate func(context.Context, string) (identity.Identity, error)
|
||||
Authenticate func(context.Context, string) (identity.Identity, error)
|
||||
AuthenticateBrowser func(context.Context, string) (identity.Identity, error)
|
||||
// Login drives the browser sign-in flow, or nil when no provider is
|
||||
// configured for it.
|
||||
Login identity.LoginFlow
|
||||
@@ -55,13 +57,17 @@ func compose(ctx context.Context, d deps) *webui.Server {
|
||||
srv := &webui.Server{
|
||||
Store: d.Store,
|
||||
Log: d.Log,
|
||||
Token: d.Options.Token,
|
||||
Authenticate: d.Authenticate,
|
||||
AuthenticateBrowser: d.AuthenticateBrowser,
|
||||
Login: d.Login,
|
||||
TrustForwardedHeaders: d.Options.trustForwardedHeaders(),
|
||||
Health: d.Health,
|
||||
ControlPlane: d.ControlPlane,
|
||||
Identities: d.Identities,
|
||||
Issuer: strings.TrimSpace(d.Options.OidcIssuer),
|
||||
}
|
||||
if subjects, ok := d.Identities.(identity.SubjectBinding); ok {
|
||||
srv.Subjects = subjects
|
||||
}
|
||||
if snapshots, ok := d.Store.(storecontract.ConfigSnapshotStore); ok {
|
||||
srv.ConfigSource = webui.RemoteConfigView(snapshots)
|
||||
@@ -89,6 +95,7 @@ func compose(ctx context.Context, d deps) *webui.Server {
|
||||
srv.Policies = policies
|
||||
}
|
||||
wireOrgSurface(srv, d.Store)
|
||||
wireAlerts(srv, d.Store)
|
||||
if presence, ok := d.Store.(storecontract.PresenceStore); ok {
|
||||
srv.Presence = presence
|
||||
srv.RunningVersions = servicekit.RunningVersions(ctx, presence, 0)
|
||||
@@ -116,10 +123,8 @@ func compose(ctx context.Context, d deps) *webui.Server {
|
||||
wireCatalog(d, srv)
|
||||
// The policy chain: wired together or not at all.
|
||||
srv.Refusals = refusalStore(d.Store)
|
||||
if d.Access != nil {
|
||||
srv.Access = d.Access
|
||||
srv.ReloadAccess = d.Access.Reload
|
||||
}
|
||||
srv.Access = d.Access
|
||||
srv.ReloadAccess = d.Access.Reload
|
||||
srv.Principals = d.Principals
|
||||
srv.Denials = d.Denials
|
||||
wireTaskLogs(d, srv)
|
||||
@@ -130,6 +135,9 @@ func compose(ctx context.Context, d deps) *webui.Server {
|
||||
// wireOrgSurface attaches the dashboard's org surface when the state client
|
||||
// carries it.
|
||||
func wireOrgSurface(srv *webui.Server, store storecontract.TaskStore) {
|
||||
if accounts, ok := store.(identity.Accounts); ok {
|
||||
srv.Accounts = accounts
|
||||
}
|
||||
if orgs, ok := store.(org.API); ok {
|
||||
srv.Orgs = orgs
|
||||
}
|
||||
@@ -147,6 +155,7 @@ func wireCatalog(d deps, srv *webui.Server) {
|
||||
}
|
||||
srv.Skills = skillCatalog{client: catalog}
|
||||
srv.Curators = curatorStatus{client: catalog}
|
||||
srv.CheckSecret = catalog.CheckSecret
|
||||
}
|
||||
|
||||
// wireTaskLogs attaches the task-log read when the store client carries the
|
||||
@@ -195,7 +204,7 @@ func wireCaptureSurfaces(d deps, srv *webui.Server) {
|
||||
MaxEvents: capture.MaxEvents,
|
||||
MaxBodyBytes: int64(capture.MaxBodyBytes),
|
||||
Publish: captureArrivalPublisher(d),
|
||||
Delivery: deliveryAuthorizer(d.Access),
|
||||
Delivery: d.Access,
|
||||
Refusals: refusalStore(d.Store),
|
||||
Log: d.Log,
|
||||
}
|
||||
@@ -221,16 +230,15 @@ func captureArrivalPublisher(d deps) func(context.Context, events.Event) {
|
||||
// a hung State Store must not hold the sender's webhook past this.
|
||||
const captureEventTimeout = 5 * time.Second
|
||||
|
||||
// deliveryAuthorizer keeps a missing chain a nil authorizer, which admits
|
||||
// every sender.
|
||||
func deliveryAuthorizer(chain *infraaccess.Live) access.DeliveryAuthorizer {
|
||||
if chain == nil {
|
||||
return nil
|
||||
}
|
||||
return chain
|
||||
}
|
||||
|
||||
func refusalStore(store storecontract.TaskStore) storecontract.CaptureRefusalStore {
|
||||
refusals, _ := store.(storecontract.CaptureRefusalStore)
|
||||
return refusals
|
||||
}
|
||||
|
||||
// wireAlerts gives the dashboard the State Store's alert surface when the
|
||||
// store has one.
|
||||
func wireAlerts(srv *webui.Server, store any) {
|
||||
if alerts, ok := store.(webui.AlertSource); ok {
|
||||
srv.Alerts = alerts
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,16 @@ 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/webui"
|
||||
)
|
||||
|
||||
// Resolve returns the effective Options: flags first, then the config file's
|
||||
// projection, then defaults, and validates the result.
|
||||
func Resolve(o Options, log *slog.Logger) (Options, error) {
|
||||
var tls config.TLS
|
||||
if o.Config != "" {
|
||||
cfg, found, err := readProjection(o.Config, o.Overlay, log)
|
||||
if err != nil {
|
||||
@@ -22,15 +25,15 @@ func Resolve(o Options, log *slog.Logger) (Options, error) {
|
||||
}
|
||||
if found {
|
||||
o = merge(o, cfg)
|
||||
tls = cfg.tls
|
||||
}
|
||||
}
|
||||
o = withDefaults(o)
|
||||
o = withEnvTokens(o)
|
||||
token, err := resolveToken(o)
|
||||
id, err := rpctls.Load(tls.CAFile, tls.CertDir, presence.UI)
|
||||
if err != nil {
|
||||
return Options{}, err
|
||||
}
|
||||
o.Token = token
|
||||
o.identity = id
|
||||
if err := o.validate(); err != nil {
|
||||
return Options{}, err
|
||||
}
|
||||
@@ -60,6 +63,7 @@ type projection struct {
|
||||
state ServiceTarget
|
||||
messaging ServiceTarget
|
||||
harness ServiceTarget
|
||||
tls config.TLS
|
||||
capture CaptureOptions
|
||||
}
|
||||
|
||||
@@ -67,10 +71,11 @@ func project(cfg config.Config) projection {
|
||||
return projection{
|
||||
listen: cfg.Web.Listen,
|
||||
trustForwardedHeaders: cfg.Web.TrustForwardedHeaders,
|
||||
gateway: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameGateway).Target, Token: cfg.Services.Get(config.ServiceNameGateway).TargetToken},
|
||||
messaging: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameMessaging).Target, Token: cfg.Services.Get(config.ServiceNameMessaging).TargetToken},
|
||||
state: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameState).Target, Token: cfg.Services.Get(config.ServiceNameState).TargetToken},
|
||||
harness: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameHarness).Target, Token: cfg.Services.Get(config.ServiceNameHarness).TargetToken},
|
||||
gateway: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameGateway).Target},
|
||||
messaging: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameMessaging).Target},
|
||||
state: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameState).Target},
|
||||
harness: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameHarness).Target},
|
||||
tls: cfg.TLS,
|
||||
capture: CaptureOptions{
|
||||
Retention: cfg.Capture.Retention.Std(),
|
||||
MaxEvents: cfg.Capture.MaxEvents,
|
||||
@@ -81,23 +86,6 @@ func project(cfg config.Config) projection {
|
||||
}
|
||||
}
|
||||
|
||||
// withEnvTokens fills service tokens left unset from the environment.
|
||||
func withEnvTokens(o Options) Options {
|
||||
if o.Gateway.Token == "" {
|
||||
o.Gateway.Token = os.Getenv("GATEWAY_TOKEN")
|
||||
}
|
||||
if o.State.Token == "" {
|
||||
o.State.Token = os.Getenv("STATE_STORE_TOKEN")
|
||||
}
|
||||
if o.Messaging.Token == "" {
|
||||
o.Messaging.Token = os.Getenv("MESSAGING_TOKEN")
|
||||
}
|
||||
if o.Harness.Token == "" {
|
||||
o.Harness.Token = os.Getenv("HARNESS_TOKEN")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// merge fills only the fields the flags left empty.
|
||||
func merge(o Options, p projection) Options {
|
||||
if o.Listen == "" {
|
||||
@@ -153,20 +141,7 @@ func withDefaults(o Options) Options {
|
||||
return o
|
||||
}
|
||||
|
||||
// resolveToken returns the dashboard token, minting and persisting one when
|
||||
// the operator named a token file and gave no token directly. Naming the file
|
||||
// is how a non-loopback listener opts in to a generated token instead of
|
||||
// being refused.
|
||||
func resolveToken(o Options) (string, error) {
|
||||
if o.Token != "" || o.TokenFile == "" {
|
||||
return o.Token, nil
|
||||
}
|
||||
return webui.LoadOrCreateToken(o.TokenFile)
|
||||
}
|
||||
|
||||
// Unlike the daemon, which mints a token silently, this process refuses to
|
||||
// start -- an operator who exposed the dashboard by accident learns about it
|
||||
// here rather than from the log.
|
||||
// Browser access is gated by accounts; service endpoints must still be configured.
|
||||
func (o Options) validate() error {
|
||||
if o.Gateway.Target == "" {
|
||||
return fmt.Errorf("gateway target is required (-gateway-target or [services.gateway].target)")
|
||||
@@ -174,12 +149,7 @@ func (o Options) validate() error {
|
||||
if o.State.Target == "" {
|
||||
return fmt.Errorf("state store target is required (-state-target or [services.state].target)")
|
||||
}
|
||||
if !webui.IsLoopback(o.Listen) && o.Token == "" {
|
||||
return fmt.Errorf(
|
||||
"ui listen address %q is non-loopback; a reachable dashboard requires a token (-token) or a token file to mint one (-token-file) (docs/prds/ui-service-boundary.md, listen and authentication)",
|
||||
o.Listen,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -187,8 +157,5 @@ func mergeTarget(o, p ServiceTarget) ServiceTarget {
|
||||
if o.Target == "" {
|
||||
o.Target = p.Target
|
||||
}
|
||||
if o.Token == "" {
|
||||
o.Token = p.Token
|
||||
}
|
||||
return o
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func wireServiceLogs(opts Options, srv *webui.Server, tasks *staterpc.Client, ch
|
||||
return chat.RecentLogs(ctx, presence.Daemon, q)
|
||||
},
|
||||
}
|
||||
messaging, closeMessaging, dialErr := messagingrpc.Dial(opts.Messaging.Target, opts.Messaging.Token)
|
||||
messaging, closeMessaging, dialErr := messagingrpc.Dial(opts.Messaging.Target, opts.identity)
|
||||
if dialErr != nil {
|
||||
return nil, dialErr
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/rpctls"
|
||||
)
|
||||
|
||||
// Process defaults. Listen matches the dashboard's historical bind
|
||||
@@ -18,12 +19,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. It is an endpoint reference, not
|
||||
// a resolved daemon credential: the UI authenticates each client itself.
|
||||
// ServiceTarget is one remote contract's endpoint.
|
||||
type ServiceTarget struct {
|
||||
Target string
|
||||
Token string
|
||||
}
|
||||
|
||||
// Options is the UI-owned input DTO. It carries process-local settings and
|
||||
@@ -39,15 +37,8 @@ type Options struct {
|
||||
|
||||
// Listen is the dashboard HTTP bind address.
|
||||
Listen string
|
||||
// Token gates browser access. Empty is permitted only for a loopback
|
||||
// listener; see Options.validate.
|
||||
Token string
|
||||
// TokenFile is where the dashboard token is persisted, minted on first
|
||||
// use. It is the explicit opt-in to a non-loopback listener: without it
|
||||
// a reachable bind must be given a token.
|
||||
TokenFile string
|
||||
// OidcIssuer and OidcAudience configure the identity provider. Both empty
|
||||
// keeps the shared token; an issuer without an audience is refused.
|
||||
// OidcIssuer and OidcAudience configure the identity provider. Local accounts remain available;
|
||||
// an issuer without an audience is refused.
|
||||
OidcIssuer string
|
||||
OidcAudience string
|
||||
// OidcClientID and OidcClientSecretEnv register the browser sign-in; the
|
||||
@@ -83,6 +74,10 @@ type Options struct {
|
||||
// ReadHeaderTimeout and ShutdownTimeout bound the HTTP lifecycle.
|
||||
ReadHeaderTimeout time.Duration
|
||||
ShutdownTimeout time.Duration
|
||||
|
||||
// identity is this process's certificate, loaded by Resolve from
|
||||
// [tls]; nil is plaintext, loopback only.
|
||||
identity *rpctls.Identity
|
||||
}
|
||||
|
||||
// CaptureOptions carries the [capture] settings the capture receiver needs.
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// Store and, when one is configured, the sign-in provider.
|
||||
func newReadinessRegistry(o Options, tasks storecontract.TaskStore, chat messaging.ChatContract, chain *infraaccess.Live, provider *oidc.Provider) *health.Registry {
|
||||
probes := []health.Probe{
|
||||
readiness.NewProblemProbe("access_policies", problemSource(chain)),
|
||||
readiness.NewProblemProbe("access_policies", chain),
|
||||
captureRefusalProbe{store: refusalStore(tasks)},
|
||||
readiness.NewContractProbe("state_db", o.DependencyTimeout, func(ctx context.Context) error {
|
||||
_, err := tasks.StatusCounts(ctx)
|
||||
@@ -35,15 +35,6 @@ func newReadinessRegistry(o Options, tasks storecontract.TaskStore, chat messagi
|
||||
return health.NewRegistry(probes...)
|
||||
}
|
||||
|
||||
// problemSource keeps a missing chain a nil source, which the probe reports
|
||||
// as not wired.
|
||||
func problemSource(chain *infraaccess.Live) readiness.PolicyProblems {
|
||||
if chain == nil {
|
||||
return nil
|
||||
}
|
||||
return chain
|
||||
}
|
||||
|
||||
// captureRefusalProbe degrades when any source refused more events than it
|
||||
// accepted over the last hour: a sender being blocked, or someone probing.
|
||||
type captureRefusalProbe struct {
|
||||
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/servicekit"
|
||||
"github.com/samcharles93/archie-core/internal/domain/access"
|
||||
"github.com/samcharles93/archie-core/internal/domain/applystatus"
|
||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||
"github.com/samcharles93/archie-core/internal/domain/presence"
|
||||
infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
@@ -27,19 +27,19 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/webui"
|
||||
)
|
||||
|
||||
// buildAccessChain builds the live access engine over the stored policies.
|
||||
// An unreachable State Store returns nil and logs a warning.
|
||||
func buildAccessChain(ctx context.Context, store *staterpc.Client, log *slog.Logger) (*infraaccess.Live, error) {
|
||||
live, err := infraaccess.NewLive(ctx, store.ListPolicies, log)
|
||||
if status.Code(err) == codes.Unavailable {
|
||||
log.Warn("access chain unavailable; the credential check is the gate", "err", err)
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// buildAccessChain starts the live access engine over the stored policies.
|
||||
// It refuses every request until Run's first load succeeds and keeps
|
||||
// retrying, so a State Store or database that is down or slow at start
|
||||
// closes the dashboard rather than opening it or stopping it.
|
||||
func buildAccessChain(ctx context.Context, store *staterpc.Client, log *slog.Logger) *infraaccess.Live {
|
||||
// The chain decides for every org, so it loads as the dashboard service,
|
||||
// never as the person whose policy edit triggered a reload.
|
||||
load := func(ctx context.Context) ([]access.Policy, error) {
|
||||
return store.ListPolicies(access.WithoutPrincipal(ctx))
|
||||
}
|
||||
live := infraaccess.NewPending(load, log)
|
||||
go live.Run(ctx, applystatus.RestampInterval)
|
||||
return live, nil
|
||||
return live
|
||||
}
|
||||
|
||||
// Run serves the dashboard until ctx is cancelled. It resolves its own
|
||||
@@ -53,49 +53,49 @@ func Run(ctx context.Context, options Options) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
warnPlainHTTP(log, opts)
|
||||
var cleanups []func()
|
||||
defer func() {
|
||||
for _, cleanup := range slices.Backward(cleanups) {
|
||||
cleanup()
|
||||
}
|
||||
}()
|
||||
tasks, closeState, err := staterpc.Dial(opts.State.Target, presence.UI, opts.State.Token)
|
||||
tasks, closeState, err := staterpc.Dial(opts.State.Target, presence.UI, opts.identity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cleanups = append(cleanups, closeState)
|
||||
chat, closeGateway, err := gatewayrpc.Dial(opts.Gateway.Target, opts.Gateway.Token)
|
||||
chat, closeGateway, err := gatewayrpc.Dial(opts.Gateway.Target, opts.identity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cleanups = append(cleanups, closeGateway)
|
||||
chain, err := buildAccessChain(ctx, tasks, log)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chain := buildAccessChain(ctx, tasks, log)
|
||||
provider, err := signInProvider(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
authenticate := dashboardAuthenticator(provider, opts, tasks, log)
|
||||
|
||||
login, err := dashboardLoginFlow(provider, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
runtimeOIDC := &accountOIDC{settings: tasks, subjects: tasks, fallbackFlow: login, fallbackProvider: provider, fallback: identity.AuthenticationSettings{PublicURL: strings.TrimSuffix(opts.OidcRedirectURL, "/oauth2/callback"), OIDCIssuer: opts.OidcIssuer, OIDCAudience: opts.OidcAudience, OIDCClientID: opts.OidcClientID}}
|
||||
srv := compose(ctx, deps{
|
||||
Options: opts,
|
||||
Log: log,
|
||||
Store: tasks,
|
||||
Chat: chat,
|
||||
Updates: controlplanerpc.UpdateService(controlplanerpc.NewRPCClient(tasks.ControlPlane()), filepath.Join(configuration.DefaultWorkDir(), "ui-update-deferrals.json"), ""),
|
||||
Health: newReadinessRegistry(opts, tasks, chat, chain, provider),
|
||||
ControlPlane: tasks.ControlPlane(),
|
||||
Identities: tasks,
|
||||
Authenticate: authenticate,
|
||||
Login: login,
|
||||
Access: chain,
|
||||
Principals: tasks,
|
||||
Denials: tasks,
|
||||
Options: opts,
|
||||
Log: log,
|
||||
Store: tasks,
|
||||
Chat: chat,
|
||||
Updates: controlplanerpc.UpdateService(controlplanerpc.NewRPCClient(tasks.ControlPlane()), filepath.Join(configuration.DefaultWorkDir(), "ui-update-deferrals.json")),
|
||||
Health: newReadinessRegistry(opts, tasks, chat, chain, provider),
|
||||
ControlPlane: tasks.ControlPlane(),
|
||||
Identities: tasks,
|
||||
Authenticate: runtimeOIDC.Authenticate,
|
||||
AuthenticateBrowser: runtimeOIDC.AuthenticateBrowser,
|
||||
Login: runtimeOIDC,
|
||||
Access: chain,
|
||||
Principals: tasks,
|
||||
Denials: tasks,
|
||||
})
|
||||
stopLogs, err := wireServiceLogs(opts, srv, tasks, chat, feed)
|
||||
if err != nil {
|
||||
@@ -122,26 +122,35 @@ func Run(ctx context.Context, options Options) error {
|
||||
"gateway", opts.Gateway.Target,
|
||||
"state", opts.State.Target,
|
||||
}
|
||||
// Name the file holding the token, never the token itself: this line
|
||||
// reaches the journal and any log an operator pastes.
|
||||
if opts.TokenFile != "" {
|
||||
attrs = append(attrs, "token_file", opts.TokenFile)
|
||||
}
|
||||
log.Info("archie-ui running", attrs...)
|
||||
return serve(ctx, listener, srv.Handler(), opts)
|
||||
}
|
||||
|
||||
// wireHarness attaches the setup terminal to the daemon's session contract
|
||||
// warnPlainHTTP names the exposure of a dashboard published off-host. The
|
||||
// process serves plain HTTP, so the session cookie and the provider token
|
||||
// cross the network in clear unless a TLS-terminating proxy sits in front of
|
||||
// it -- which [web].trust_forwarded_headers declares. A loopback bind is
|
||||
// reached over a tunnel or on the host, so it needs no warning.
|
||||
func warnPlainHTTP(log *slog.Logger, opts Options) {
|
||||
if webui.IsLoopback(opts.Listen) || opts.trustForwardedHeaders() {
|
||||
return
|
||||
}
|
||||
log.Warn("dashboard is reachable off-host over plain HTTP; session and provider tokens travel in clear unless TLS terminates in front of it (set [web].trust_forwarded_headers behind a TLS proxy)",
|
||||
"listen", opts.Listen)
|
||||
}
|
||||
|
||||
// wireHarness attaches the setup terminal and the run-scoped sandbox view to the daemon's session contract
|
||||
// when the operator configured one, and registers its cleanup.
|
||||
func wireHarness(opts Options, srv *webui.Server, cleanups *[]func()) error {
|
||||
if opts.Harness.Target == "" {
|
||||
return nil
|
||||
}
|
||||
harness, closeHarness, err := harnessrpc.Dial(opts.Harness.Target, opts.Harness.Token)
|
||||
harness, closeHarness, err := harnessrpc.Dial(opts.Harness.Target, opts.identity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
srv.HarnessTerminal = harness
|
||||
srv.SandboxView = harness
|
||||
*cleanups = append(*cleanups, closeHarness)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
type Writer struct {
|
||||
Enqueue func(
|
||||
ctx context.Context,
|
||||
owner, repo, title, body, workflow, identity, origin string,
|
||||
owner, repo, title, body, workflow, identity, origin, draft string,
|
||||
inputs map[string]any,
|
||||
) (*workflow.Task, error)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ func (a Writer) EnqueueChatTask(
|
||||
owner, repo, title, body, workflow, identity, origin string,
|
||||
inputs map[string]any,
|
||||
) (int64, error) {
|
||||
task, err := a.Enqueue(ctx, owner, repo, title, body, workflow, identity, origin, inputs)
|
||||
task, err := a.Enqueue(ctx, owner, repo, title, body, workflow, identity, origin, "", inputs)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const ChannelSettingsKind = controlplanerpc.ChannelSettingsKind
|
||||
func seedChannels(cfg config.Config) any {
|
||||
chat := cfg.Chat
|
||||
return channelSettings{
|
||||
Operator: chat.Operator, Workspace: chat.Workspace, UnrestrictedFilesystem: chat.UnrestrictedFilesystem, ShowToolCalls: chat.ShowToolCalls, MaxSteps: chat.MaxSteps, Models: chat.Models,
|
||||
Operator: chat.Operator, Workspace: chat.Workspace, UnrestrictedFilesystem: chat.UnrestrictedFilesystem, ShowToolCalls: chat.ShowToolCalls, MaxSteps: chat.MaxSteps,
|
||||
Telegram: telegramSettings{AllowedUserIDs: chat.Telegram.AllowedUserIDs, Token: chat.Telegram.Token, CredentialConfigured: chat.Telegram.Token != (config.SecretRef{})},
|
||||
RateLimit: rateLimitSettings{Window: channelDuration(chat.RateLimit.Window), MaxRequests: chat.RateLimit.MaxRequests},
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package controlplane_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/controlplane"
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/workflowsteps"
|
||||
)
|
||||
|
||||
func TestStoredChannelSettingsCanBeEdited(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
db := pgstore.Open(t)
|
||||
if err := db.BootstrapIdentities(ctx, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.UpgradeDefaultOrg(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
steps, err := workflowsteps.NewManager()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
server, err := controlplane.NewServer(db, steps)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
client := workflowRPC(t, server, db).ControlPlane()
|
||||
stored, err := db.PutResource(ctx, storecontract.ResourceWrite{
|
||||
OrgID: storecontract.DefaultOrgID, Kind: controlplane.ChannelSettingsKind,
|
||||
Value: []byte(`{"email":{"listen_addr":""},"webhook":{},"webhook_addr":"","telegram":{"allowed_user_ids":[42],"token_ref":{"engine":"bws","key":"telegram"}},"workspace":"/workspace","max_steps":17,"rate_limit":{"window":"30s","max_requests":5}}`),
|
||||
Actor: "operator", Source: "test", RequestID: "old-settings",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := client.Query(ctx, &pb.QueryRequest{Kind: controlplane.ChannelSettingsKind})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var settings controlplanerpc.ChannelSettings
|
||||
if err := json.Unmarshal(got.Resource.ValueJson, &settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var document map[string]json.RawMessage
|
||||
if err := json.Unmarshal(got.Resource.ValueJson, &document); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, retired := range []string{"email", "webhook", "webhook_addr"} {
|
||||
if _, exists := document[retired]; exists {
|
||||
t.Fatalf("served retired %s field in editable settings", retired)
|
||||
}
|
||||
}
|
||||
if settings.Telegram.Token.Key != "telegram" || len(settings.Telegram.AllowedUserIDs) != 1 || settings.Telegram.AllowedUserIDs[0] != 42 || settings.Workspace != "/workspace" || settings.MaxSteps != 17 || settings.RateLimit.MaxRequests != 5 {
|
||||
t.Fatalf("lost supported settings: %+v", settings)
|
||||
}
|
||||
settings.Telegram.AllowedUserIDs = []int64{42, 43}
|
||||
value, err := json.Marshal(settings)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
changed, err := client.Command(ctx, &pb.CommandRequest{Kind: controlplane.ChannelSettingsKind, Command: "replace", ValueJson: value, ExpectedVersion: got.Resource.Version, Actor: "operator", Source: "test", RequestId: "edit"})
|
||||
if err != nil {
|
||||
t.Fatalf("saving edited channel settings: %v", err)
|
||||
}
|
||||
if changed.Resource.Version != stored.Version+1 {
|
||||
t.Fatalf("saved version %d", changed.Resource.Version)
|
||||
}
|
||||
}
|
||||
Loaded 100 of 766 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user