Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6cc4015
test(tooling): add the AWS Emulator integration tier (ADR-013 Tier 2a)
Nov 15, 2026
15fb17b
test(tooling): test the emulator guard's refusals
Nov 16, 2026
0d243bd
fix(cdk): add an index for a user's tasks by creation time (#51)
Nov 16, 2026
82a45c0
fix(api): list tasks newest first and fill filtered pages (#51)
Nov 16, 2026
727d469
fix(api): fill filtered pages of the webhook list
Nov 16, 2026
0bd0f25
fix(api): pass the per-user concurrency cap to confirm-uploads
Nov 16, 2026
ac54c32
fix(cli): recognise a GitHub token by its format
Nov 16, 2026
947871a
docs: replace admission_rejected and the failed-at-limit examples
Nov 16, 2026
3fa067c
fix(cli): ops ages by time in status and shows the deployed cap
Nov 16, 2026
c90eb00
fix(agent): approval transitions maintain status_created_at
Nov 16, 2026
7cea3d2
fix(api): write completed_at and status_created_at on Slack cancel
Nov 16, 2026
132ae27
fix(api): a task failed at presigning is written as a terminal row
Nov 16, 2026
c8a3cde
fix(api): set ttl on stranded tasks and completed_at on blocked ones
Nov 16, 2026
44e3ff3
fix(api): link handlers refuse a code whose ttl has passed
Nov 16, 2026
0115c96
fix(agent): assume the session role when the session is built
Nov 16, 2026
865c8ba
fix(agent): retry trajectory log-stream creation
Nov 16, 2026
0655961
test(agent): reset the blocker latch between unit tests
Nov 16, 2026
6e47c45
fix(cdk): say that the agent stores cost and duration as strings
Nov 16, 2026
21171df
chore(cdk): correct the comments on the Linear webhook dedup
Nov 16, 2026
13ae172
ci: add the advisory emulator workflow
Nov 16, 2026
34a9696
ci: run the integ task without cdk deploy arguments
Nov 16, 2026
5dc5888
docs: document the emulator tier and record the investigation
Nov 16, 2026
7e20f87
fix(agent): build the image with gh 2.103.3, Go 1.27.4 and uv 0.13.7
Nov 16, 2026
c91c402
fix(deps): clear two OpenTelemetry advisories, renew two ignores
Nov 16, 2026
72b1814
test(tooling): move the AWS Emulator pin to 1.0.481
Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ agent/**/*.pyc
# Deployment profile (ADR-024): infrastructure selection only; editing it must not rebuild the image
abca.deployment*.json

# Emulator test tooling: never part of the agent image, and bumping its pinned
# version must not change the image hash
scripts/aws-emulator/

# Git and tooling
.git/
.prek/
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/emulator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: emulator
# ADR-013 Tier 2a: runs ABCA's real handler, CLI and agent code against the AWS Emulator
# (https://github.com/aws/aws-emulator) instead of module-level SDK mocks. No AWS account,
# role or secret is involved, so it runs unchanged for fork pull requests.
#
# Advisory: the job is not in the required status checks of the `main` ruleset, so a red run
# is visible on the pull request but does not block the merge. To make it required, add the
# job name ("Emulator integration tests") to the ruleset; it already runs on merge_group,
# which a required check must do or the merge queue deadlocks (#327).
#
# Kept out of build.yml on purpose: deploy.yml and integ.yml start from `workflow_run` on
# build and need its conclusion to be `success`.
on:
pull_request: {}
merge_group: {}
workflow_dispatch: {}

permissions:
contents: read

concurrency:
group: emulator-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
emulator:
name: Emulator integration tests
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
env:
CI: "true"
MISE_EXPERIMENTAL: "1"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Install mise
uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7
with:
version: 2026.10.25 # exact mise release for every workflow (#890); bump by PR
cache: true

- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22.x

- name: Install dependencies
run: mise run install

# Builds the pinned, signature-verified emulator image, starts a fresh emulator on
# loopback, runs the cdk, cli and agent emulator suites, and stops it.
- name: Emulator integration tests
run: mise run test:integration

- name: Emulator log (on failure)
if: failure()
run: |
docker ps -a --filter name=abca-aws-emulator --format '{{.Names}}' \
| xargs -r -n1 docker logs --tail 200 || true
8 changes: 1 addition & 7 deletions .github/workflows/integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,7 @@ jobs:
set -euo pipefail
export INTEG_STACK_NAME="int-${HEAD_SHA:0:12}-${RUN_NUMBER}"
echo "Integ stack name: $INTEG_STACK_NAME"
mise //cdk:integ -- --all --require-approval never \
-c stackName="integ-${{ github.run_id }}-${{ github.run_attempt }}" \
-c github:sha="$(git rev-parse HEAD)" \
-c github:ref="$(git branch --show-current || echo "detached")" \
-c github:actor="${{ github.triggering_actor }}" \
-c github:repository="$(gh repo view --json nameWithOwner --jq .nameWithOwner)" \
-c github:clean="$([ -z "$(git status --porcelain)" ] && echo true || echo false)"
mise //cdk:integ

# Post the final integ-smoke status back to the PR head so the check flips from
# pending to success/failure. Skipped for workflow_dispatch (no PR to gate).
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mise run check:fast # lint + drift-prevention (drift and file-hygiene chec
mise run security # secrets, deps, sast, grype, retire, gh-actions, agent
mise run hooks:install # prek git hooks (also runs at end of install)
mise run hooks:run # pre-commit + pre-push locally
mise run test:integration # emulator-backed tests of cdk, cli and agent (needs Docker, no AWS account; not part of build)
```

Security subtasks: `mise run security:secrets`, `security:sast`, `security:sast:range` (the same rule packs, reporting only the findings a branch adds: the per-PR check), `security:sast:masking`, `security:deps`, `security:retire`, `security:gh-actions`. The secret scans print the rule, file and line of each finding. A 12-digit number that reads as an AWS account id fails them, in tests and workflows too, unless it is an AWS-published placeholder (`123456789012`, `111122223333`, `444455556666`, `000000000000`) or, when it is not an account id, its line carries `gitleaks:allow -- <reason>`. Use that marker only on a line that holds no identifier, key or token: it exempts the whole line from every rule of the secret scan, not only the number. For `security:sast:masking` allowlist intentional fallbacks with an inline `nosemgrep: <rule-id> -- <reason>` comment on the flagged `return` line (or the line immediately above) — the rule anchors on the `return`, so a token placed higher does not bind.
Expand Down Expand Up @@ -56,6 +57,7 @@ Branch names: `(feat|fix|chore|docs)/<issue-number>-short-description` (e.g. `do
| Operator web console | `web/src/`, `web/test/` | `web/src/core/api/types.ts` if API changes | [web/AGENTS.md](./web/AGENTS.md) |
| Agent runtime | `agent/src/` | `agent/tests/`, `agent/README.md` | [agent/AGENTS.md](./agent/AGENTS.md) |
| Progress events | `agent/src/progress_writer.py`, `agent/src/pipeline.py`, `agent/src/runner.py` | `agent/tests/test_progress_writer.py`; `cli/src/commands/watch.ts` | [agent/AGENTS.md](./agent/AGENTS.md), [cli/AGENTS.md](./cli/AGENTS.md) |
| Emulator-backed integration tests (ADR-013 Tier 2a) | `cdk/test/emulator/`, `cli/test/emulator/`, `agent/tests_emulator/`; tooling in `scripts/aws-emulator/` | [scripts/aws-emulator/README.md](./scripts/aws-emulator/README.md) when a rule or a known difference from AWS changes; run with `mise run test:integration` | [cdk/AGENTS.md](./cdk/AGENTS.md), [cli/AGENTS.md](./cli/AGENTS.md), [agent/AGENTS.md](./agent/AGENTS.md) |
| User-facing / design prose | `docs/guides/`, `docs/design/` | `mise //docs:sync` | [docs/AGENTS.md](./docs/AGENTS.md) |
| ADRs | `docs/decisions/` | `mise //docs:sync` | [docs/AGENTS.md](./docs/AGENTS.md) |
| Deployment profiles / regional capabilities | `cdk/src/deployment/`, `contracts/deployment-capabilities.json` | **`cli/src/deployment-capabilities.ts`**, `cli/src/deployment-profile.ts`, `docs/guides/DEPLOYMENT_GUIDE.md#deployment-profiles` | [cdk/AGENTS.md](./cdk/AGENTS.md), [cli/AGENTS.md](./cli/AGENTS.md) |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The `upgrade-main` GitHub workflow runs `mise run upgrade` daily and opens a PR

PRs labeled `auto-approve` are approved automatically by the `auto-approve` workflow; only apply the label to automated PRs whose changes are gated by the full build (e.g. the dependency-upgrade PRs).

The tools that the gates run are not part of that upgrade. `prek`, `gitleaks`, `uv`, `semgrep`, `osv-scanner`, `grype` and `zizmor` are pinned to exact versions in the root `mise.toml` (`uv` and `trivy` in `agent/mise.toml`), and every workflow that installs mise pins the mise version (`version:` under `jdx/mise-action`). Nothing bumps these pins automatically: bump them by pull request, to a release that is at least 7 days old, and keep `uv` the same in both files. After pulling a change to a pin, run `mise install`.
The tools that the gates run are not part of that upgrade. `prek`, `gitleaks`, `uv`, `semgrep`, `osv-scanner`, `grype` and `zizmor` are pinned to exact versions in the root `mise.toml` (`uv` and `trivy` in `agent/mise.toml`), and every workflow that installs mise pins the mise version (`version:` under `jdx/mise-action`). Nothing bumps these pins automatically: bump them by pull request, to a release that is at least 7 days old, and keep `uv` the same in both files and in the `uv` image that `agent/Dockerfile` copies from. After pulling a change to a pin, run `mise install`.

### Git hooks

Expand Down
14 changes: 14 additions & 0 deletions agent/.trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Findings accepted temporarily in the agent image scan (`mise //agent:security:image`).
# An entry applies to the whole image. Each one expires (exp:YYYY-MM-DD is the first
# day, in UTC, on which it no longer applies) so that the scan fails again and the
# finding is re-reviewed. Nothing warns ahead of that day: the weekly expiry warning
# reads only the osv-scanner.toml files. Remove an entry as soon as a fixed release is
# available.

# golang.org/x/net/html, quadratic text-node parsing (GO-2026-6860), reported for
# usr/local/bin/gh. On 2026-11-16 no gh release requires x/net >= 0.62.0, which has the
# fix: 2.103.3 requires 0.60.0, 2.104.0 requires 0.61.0, cli/cli trunk 0.62.0. The
# functions the advisory names (html.Parse and the parser behind it) are not linked into
# the binary: gh keeps only the tokenizer (`govulncheck -mode binary` and `go tool nm`).
# Remove this with the GH_VERSION bump in agent/Dockerfile that brings x/net 0.62.0.
CVE-2026-78661 exp:2026-12-16
1 change: 1 addition & 0 deletions agent/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Unit tests cannot reach AWS through botocore. `tests/conftest.py` removes the cr
| `agent/src/prompts/` | WRITE | System prompts per workflow |
| `agent/src/progress_writer.py` | WRITE | TaskEvents emission |
| `agent/tests/` | WRITE | pytest suite |
| `agent/tests_emulator/` | WRITE | Emulator-backed tests: real agent code against a local AWS Emulator. The unit run does not collect them: `mise run test:integration` from the repository root (needs Docker). Rules and known differences from AWS: [scripts/aws-emulator/README.md](../scripts/aws-emulator/README.md). |
| `agent/README.md` | WRITE | Env vars, PAT notes |
| `cli/src/commands/watch.ts` | WRITE (if event schema changes) | Event consumer |

Expand Down
8 changes: 5 additions & 3 deletions agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG TARGETPLATFORM=linux/arm64
ARG GH_VERSION=2.93.0
ARG GH_VERSION=2.103.3

# Every external image is pinned by DIGEST, not by tag.
#
Expand All @@ -22,7 +22,7 @@ ARG GH_VERSION=2.93.0
FROM --platform=$TARGETPLATFORM jdxcode/mise:latest@sha256:df5adf538c92d86f9807e738c7c7a9b32a1ae06edf441ede141333e3fe6a2cd9 AS mise

# Build gh with a patched Go toolchain; upstream packages can lag Go CVE fixes.
FROM --platform=$TARGETPLATFORM golang:1.27.1-bookworm@sha256:648f440f42a0958804efb24df176f806f9d353b41f1c0627f666428e40310f6b AS gh-builder
FROM --platform=$TARGETPLATFORM golang:1.27.4-bookworm@sha256:4fa7c968ba93f1635670522dbb01a2c78150443e1385746924566079f36570ea AS gh-builder
ARG GH_VERSION
RUN GOPROXY=direct GOBIN=/out go install "github.com/cli/cli/v2/cmd/gh@v${GH_VERSION}"

Expand Down Expand Up @@ -99,7 +99,9 @@ RUN npm install -g npm@latest && \
# Install uv (fast Python package manager) — pinned by digest, not just version:
# a published tag can be re-pushed, and this COPY sits above the dependency sync,
# so a silent move here invalidates it. See the digest note at the top of the file.
COPY --from=ghcr.io/astral-sh/uv:0.11.14@sha256:1025398289b62de8269e70c45b91ffa37c373f38118d7da036fb8bb8efc85d97 /uv /usr/local/bin/uv
# Dependabot's docker updates have only ever changed the FROM lines of this file:
# bump this line by hand, to the `uv` version of mise.toml and agent/mise.toml.
COPY --from=ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b981e1334471a90c4a1d93bb490 /uv /usr/local/bin/uv

# Install Python dependencies via uv. Build context is repo root (set in
# ``cdk/src/stacks/agent.ts``) so source paths are prefixed with ``agent/``.
Expand Down
1 change: 1 addition & 0 deletions agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ agent/
│ ├── test_pipeline.py Pipeline tests (cedar_policies injection, _resolve_overall_task_status, _chain_prior_agent_error)
│ ├── test_shell.py Shell utility tests (slugify, redact_secrets, truncate, format_bytes)
│ └── ...
├── tests_emulator/ Emulator-backed tests: real agent code against a local AWS Emulator (`mise run test:integration`; not collected by the unit run)
```

The container **CMD** runs the app under `opentelemetry-instrument` with **uvicorn** using the **asyncio** event loop (not uvloop), avoiding known subprocess issues with uvloop.
Expand Down
14 changes: 2 additions & 12 deletions agent/osv-scanner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
# the finding is re-reviewed; remove an entry once aws-opentelemetry-distro
# allows the fixed OpenTelemetry versions.

[[IgnoredVulns]]
id = "GHSA-xcq7-p3pf-p88h"
ignoreUntil = 2026-11-28
reason = "opentelemetry-api tracestate parsing DoS (fixed in 1.45.1). aws-opentelemetry-distro pins opentelemetry-api exactly; the latest release (0.21.0) still pins 1.44.0."

[[IgnoredVulns]]
id = "GHSA-f5m9-jfrj-jjj7"
ignoreUntil = 2026-11-28
reason = "opentelemetry-propagator-jaeger baggage allocation (fixed in 1.45.0). Pinned exactly by aws-opentelemetry-distro; only affects services that enable the optional Jaeger propagator."

[[IgnoredVulns]]
id = "GHSA-mf5v-w3w3-f6cg"
ignoreUntil = 2026-11-28
reason = "opentelemetry-api denial of service through quadratic-time traceparent parsing (fixed in 1.45.2). aws-opentelemetry-distro pins opentelemetry-api exactly; the latest release (0.22.0) pins 1.45.1, so no release of the distro allows the fix yet."
ignoreUntil = 2026-12-16
reason = "opentelemetry-api denial of service through quadratic-time traceparent parsing (fixed in 1.45.2). aws-opentelemetry-distro pins opentelemetry-api exactly. On 2026-11-16 its latest release, 0.22.0 (the one locked), pins 1.45.1, so no release of the distro allows the fix yet (aws-observability/aws-otel-python-instrumentation#975 asks for it)."
3 changes: 2 additions & 1 deletion agent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"requests==2.34.2", #https://pypi.org/project/requests/
"fastapi==0.139.0", #https://pypi.org/project/fastapi/
"uvicorn==0.50.0", #https://pypi.org/project/uvicorn/
"aws-opentelemetry-distro==0.18.0", #https://pypi.org/project/aws-opentelemetry-distro/
"aws-opentelemetry-distro==0.22.0", #https://pypi.org/project/aws-opentelemetry-distro/ (0.22.0 clears GHSA-xcq7-p3pf-p88h and GHSA-f5m9-jfrj-jjj7)
"mcp==1.30.0", #https://pypi.org/project/mcp/ (1.30.0 clears GHSA-84m7-p3x7-pcfv)
# CEDAR ENGINE PARITY — DO NOT BUMP IN ISOLATION.
# cedarpy (Python, agent runtime) and @cedar-policy/cedar-wasm (TypeScript,
Expand Down Expand Up @@ -166,6 +166,7 @@ ignore = [
max-complexity = 15

[tool.ruff.lint.per-file-ignores]
"tests_emulator/**" = ["S101", "S106", "S108", "PLR2004", "ARG", "TID251"] # emulator-backed tests (mise run test:integration): assert; test tokens; /tmp paths; literal assertions; fixtures taken for their effect; their own boto3 session
"src/entrypoint.py" = ["E402"] # re-export shim: importlib.reload() call must precede re-export from-imports
# aws_session.py is the one module that builds boto3 clients, resources and sessions:
# it attaches the solution User-Agent (#319). TID251 is one rule for the whole
Expand Down
18 changes: 12 additions & 6 deletions agent/src/aws_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def configure_session(user_id: str, repo: str, task_id: str) -> None:

Called once at agent startup from the resolved ``TaskConfig``. Idempotent;
safe to call before any tenant-data client is created. Does not itself
assume the role — assumption is deferred until the first client is built so
that a missing SessionRole never delays startup. Values are stored in a
assume the role — the first ``get_session()`` call does, with these tags,
so this must run first. Values are stored in a
module global (not ``os.environ``) so tenant identifiers do not leak into
spawned subprocesses.
"""
Expand Down Expand Up @@ -183,9 +183,9 @@ def _refresh() -> dict[str, str]:
# propagates to every client AND resource derived from this session, so
# all tenant-data calls carry it. (#319)
botocore_session.user_agent_extra = ua.static_user_agent_extra()
# Deferred: the first assume_role happens on first credential use, not now,
# so a transient STS hiccup at startup doesn't crash the agent before it
# has even begun.
# No credentials yet: get_session() resolves them once, right after this
# returns, so a role that cannot be assumed fails closed there instead of
# on every later tenant-data call. botocore re-assumes before expiry.
botocore_session._credentials = DeferredRefreshableCredentials(
method="sts-assume-role-session-tags",
refresh_using=_refresh,
Expand Down Expand Up @@ -216,7 +216,13 @@ def get_session() -> Any:
# reach every tenant's data (that is exactly what this control
# prevents).
try:
_session = _build_scoped_session(role_arn)
session = _build_scoped_session(role_arn)
# Assume the role now. Left to botocore it happens on the first
# signed request, where an STS refusal is one more error behind
# a best-effort wrapper and the task carries on. Cache nothing
# until it succeeded.
session.get_credentials().get_frozen_credentials()
_session = session
_scoped = True
except Exception as exc:
from shell import log_error_cw
Expand Down
16 changes: 11 additions & 5 deletions agent/src/task_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ def write_running(task_id: str) -> None:
Updates ``status_created_at`` alongside ``status`` so the
``UserStatusIndex`` GSI sort key reflects the current status. Writers
that transition the task (``create-task-core``, ``cancel-task``,
``reconcile-stranded-tasks``) all rewrite this field; keeping Python
in sync is required for ``bga list`` to return tasks in the expected
order.
``reconcile-stranded-tasks``) all rewrite this field, and Python must
too. Its readers take the prefix for the current status (the
queue-position lookup in ``get-task``) and the timestamp for when that
status was entered (the stranded-task sweep in
``reconcile-stranded-tasks`` and ``bgagent ops stuck-tasks``).
"""
try:
table = _get_table()
Expand Down Expand Up @@ -703,14 +705,16 @@ def transact_write_approval_request(
"TableName": task_table,
"Key": {"task_id": {"S": task_id}},
"UpdateExpression": (
"SET #s = :awaiting, awaiting_approval_request_id = :rid"
"SET #s = :awaiting, awaiting_approval_request_id = :rid, "
"status_created_at = :sca"
),
"ConditionExpression": "#s = :running",
"ExpressionAttributeNames": {"#s": "status"},
"ExpressionAttributeValues": {
":awaiting": {"S": _STATUS_AWAITING_APPROVAL},
":running": {"S": _STATUS_RUNNING},
":rid": {"S": request_id},
":sca": {"S": f"{_STATUS_AWAITING_APPROVAL}#{_now_iso()}"},
},
}
},
Expand Down Expand Up @@ -759,13 +763,15 @@ def transact_resume_from_approval(
"TableName": task_table,
"Key": {"task_id": {"S": task_id}},
"UpdateExpression": (
"SET #s = :running REMOVE awaiting_approval_request_id"
"SET #s = :running, status_created_at = :sca "
"REMOVE awaiting_approval_request_id"
),
"ConditionExpression": (
"#s = :awaiting AND awaiting_approval_request_id = :rid"
),
"ExpressionAttributeNames": {"#s": "status"},
"ExpressionAttributeValues": {
":sca": {"S": f"{_STATUS_RUNNING}#{_now_iso()}"},
":running": {"S": _STATUS_RUNNING},
":awaiting": {"S": _STATUS_AWAITING_APPROVAL},
":rid": {"S": request_id},
Expand Down
Loading
Loading