Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
74 changes: 35 additions & 39 deletions .github/workflows/core-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
exit 1
fi
if [[ -n "$EXPECTED_CORE_SHA" && "$head_sha" != "$EXPECTED_CORE_SHA" ]]; then
echo "The Core run did not build the reviewed alpha.1 commit." >&2
echo "The Core run did not build the requested candidate commit." >&2
exit 1
fi
example_sha="${EXPECTED_EXAMPLE_SHA:-$head_sha}"
Expand All @@ -115,6 +115,13 @@ jobs:
matrix:
component: [toolkit, mcp, a2a, cli]
core: [minimum, candidate]
exclude: &candidate-only-hosts
- component: mcp
core: minimum
- component: a2a
core: minimum
- component: cli
core: minimum
defaults:
run:
working-directory: ${{ matrix.component }}/python
Expand Down Expand Up @@ -194,7 +201,7 @@ jobs:
assert core_path == installed.locate_file("apcore/__init__.py").resolve()
assert toolkit_path == toolkit_expected.resolve()
if os.environ["CORE_MODE"] == "candidate":
assert installed.version == "1.0.0a1"
assert installed.version == "1.0.0a2"
origin = json.loads(installed.read_text("direct_url.json") or "{}")
assert origin.get("url") == Path(os.environ["CORE_INSTALL"]).resolve().as_uri()
assert callable(getattr(Executor, "stream_with_completion", None))
Expand Down Expand Up @@ -234,6 +241,7 @@ jobs:
matrix:
component: [toolkit, mcp, a2a, cli]
core: [minimum, candidate]
exclude: *candidate-only-hosts
defaults:
run:
working-directory: ${{ matrix.component }}/typescript
Expand Down Expand Up @@ -267,27 +275,6 @@ jobs:
env:
EXPECTED_SHA256: ${{ inputs.npm_sha256 }}
run: |
toolkit="$GITHUB_WORKSPACE/toolkit/typescript"
roots=("$PWD")
if [[ "$COMPONENT" == toolkit ]]; then
pnpm install --frozen-lockfile
else
pnpm --dir "$toolkit" install --frozen-lockfile
# The release lock refers to the registry package. Test the candidate
# sources before that package is published by using a local override.
TOOLKIT="$toolkit" node --input-type=module <<'JS'
import { readFileSync, writeFileSync } from 'node:fs';

const file = 'package.json';
const manifest = JSON.parse(readFileSync(file, 'utf8'));
manifest.pnpm ??= {};
manifest.pnpm.overrides ??= {};
manifest.pnpm.overrides['apcore-toolkit'] = 'link:' + process.env.TOOLKIT;
writeFileSync(file, JSON.stringify(manifest, null, 2) + '\n');
JS
pnpm install --no-frozen-lockfile
roots+=("$toolkit")
fi
core_package="[email protected]"
if [[ "$CORE_MODE" == candidate ]]; then
shopt -s nullglob
Expand All @@ -309,14 +296,29 @@ jobs:
installed=$(mktemp -d)
npm install --prefix "$installed" --ignore-scripts --no-save --no-package-lock --no-audit --no-fund "$core_package"
core_root="$installed/node_modules/apcore-js"
for root in "${roots[@]}"; do
rm -f "$root/node_modules/apcore-js"
ln -s "$core_root" "$root/node_modules/apcore-js"
done
toolkit="$GITHUB_WORKSPACE/toolkit/typescript"
roots=("$toolkit")
if [[ "$COMPONENT" != toolkit ]]; then
pnpm --dir "$toolkit" build
roots+=("$PWD")
fi
pnpm build
for root in "${roots[@]}"; do
CORE_ROOT="$core_root" TOOLKIT_ROOT="$toolkit" ROOT="$root" node --input-type=module <<'JS'
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';

const file = join(process.env.ROOT, 'package.json');
const manifest = JSON.parse(readFileSync(file, 'utf8'));
manifest.pnpm ??= {};
const overrides = manifest.pnpm.overrides ??= {};
overrides['apcore-js'] = 'link:' + process.env.CORE_ROOT;
if (process.env.ROOT !== process.env.TOOLKIT_ROOT) {
overrides['apcore-toolkit'] = 'link:' + process.env.TOOLKIT_ROOT;
}
writeFileSync(file, JSON.stringify(manifest, null, 2) + '\n');
JS
pnpm --dir "$root" install --no-frozen-lockfile
pnpm --dir "$root" build
done
for root in "${roots[@]}"; do
(
cd "$root"
Expand All @@ -338,7 +340,7 @@ jobs:
assert.ok(coreEntry.startsWith(core + sep));
assert.equal(toolkitEntry, realpathSync(resolve(process.env.TOOLKIT_ROOT, 'dist/index.js')));
if (process.env.CORE_MODE === 'candidate') {
assert.equal(coreVersion, '1.0.0-alpha.1');
assert.equal(coreVersion, '1.0.0-alpha.2');
assert.equal(typeof Executor.prototype.streamWithCompletion, 'function');
assert.equal(typeof APCore.prototype.streamWithCompletion, 'function');
} else {
Expand All @@ -361,13 +363,7 @@ jobs:
matrix:
component: [toolkit, mcp, a2a, cli]
core: [minimum, candidate]
# For C2-required packages, the first alpha is both the minimum and
# the current candidate. The candidate entry covers both.
exclude:
- component: mcp
core: minimum
- component: cli
core: minimum
exclude: *candidate-only-hosts
env:
CORE_MODE: ${{ matrix.core }}
COMPONENT: ${{ matrix.component }}
Expand Down Expand Up @@ -410,8 +406,8 @@ jobs:
crate="${crates[0]}"
version="${crate##*/apcore-}"
version="${version%.crate}"
if [[ "$version" != 1.0.0-alpha.1 ]]; then
echo "Expected the alpha.1 Core crate." >&2
if [[ "$version" != 1.0.0-alpha.2 ]]; then
echo "Expected the alpha.2 Core crate." >&2
exit 1
fi
if [[ "$CORE_MODE" == candidate && -n "$EXPECTED_SHA256" ]]; then
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
permissions:
contents: read

env:
CORE_REF: 3b5fb5defb7e32900da4e826a848bb23258cd91e

jobs:
test:
name: Python ${{ matrix.version }} (${{ matrix.component }})
Expand All @@ -31,16 +34,31 @@ jobs:
working-directory: ${{ matrix.component }}/python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- &checkout-core
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: aiperceivable/apcore
ref: ${{ env.CORE_REF }}
path: .ci-apcore-core
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.version }}
- &build-core-wheel
name: Build the in-review Core wheel
run: |
python -m pip install build
python -m build --wheel --outdir "$RUNNER_TEMP/core-wheel" "$GITHUB_WORKSPACE/.ci-apcore-core/python"
- name: Install and verify local dependencies
shell: bash
run: |
args=(-e '.[dev]')
args=("$RUNNER_TEMP"/core-wheel/apcore-*.whl -e '.[dev]')
if [[ "${{ matrix.component }}" != toolkit ]]; then
args+=(-e "$GITHUB_WORKSPACE/toolkit/python")
fi
if [[ "${{ matrix.component }}" == a2a ]]; then
args+=(aiohttp)
fi
if [[ -f constraints.txt ]]; then
args+=(-c constraints.txt)
fi
Expand Down Expand Up @@ -68,9 +86,11 @@ jobs:
working-directory: ${{ matrix.component }}/python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- *checkout-core
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.12'
- *build-core-wheel
- name: Build wheel and sdist
run: |
python -m pip install build
Expand All @@ -80,7 +100,7 @@ jobs:
env:
COMPONENT: ${{ matrix.component }}
run: |
wheels=( "$PWD"/dist/*.whl )
wheels=( "$PWD"/dist/*.whl "$RUNNER_TEMP"/core-wheel/apcore-*.whl )
temporary=$(mktemp -d)
if [[ "$COMPONENT" == a2a || "$COMPONENT" == cli ]]; then
python -m build --wheel --outdir "$temporary/wheels" "$GITHUB_WORKSPACE/toolkit/python"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ permissions:
env:
# The released lockfiles already reference these prereleases. Bootstrap CI
# from the reviewed Core commit while those versions are unpublished.
CORE_REF: b28e1bfd01b804c8662e9e418d8487d0e08cc0ce
CORE_CRATE_VERSION: 1.0.0-alpha.1
CORE_CRATE_SHA256: bbc1db3680f3d81b7096fa5eb70476a2c043b333681c2a7bba3597a49bbf11f6
CORE_REF: 0384a3d4e7688c47eaa1feea6032fb4739813f20
CORE_CRATE_VERSION: 1.0.0-alpha.2
CORE_CRATE_SHA256: 54e630a6f3c82ee9e01aec1f58ad14a06e21d8082414a1f4d398bce2f45b4de3

jobs:
source:
Expand Down
59 changes: 40 additions & 19 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
permissions:
contents: read

env:
CORE_REF: 3b5fb5defb7e32900da4e826a848bb23258cd91e

jobs:
test:
name: TypeScript (${{ matrix.component }})
Expand All @@ -27,41 +30,57 @@ jobs:
working-directory: ${{ matrix.component }}/typescript
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- &checkout-core
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: aiperceivable/apcore
ref: ${{ env.CORE_REF }}
path: .ci-apcore-core
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: pnpm/action-setup@v4
with:
version: '10.30.1'
- &build-core-npm
name: Build the in-review Core npm distribution
run: |
core="$GITHUB_WORKSPACE/.ci-apcore-core/typescript"
pnpm --dir "$core" install --frozen-lockfile
pnpm --dir "$core" build
pnpm --dir "$core" pack --pack-destination "$RUNNER_TEMP"
- &install-dependencies
name: Install dependencies with the checkout's Toolkit
name: Install dependencies with the Core archive and checkout Toolkit
shell: bash
run: |
toolkit="$GITHUB_WORKSPACE/toolkit/typescript"
if [[ "$PWD" == "$toolkit" ]]; then
pnpm install --frozen-lockfile
exit
fi

pnpm --dir "$toolkit" install --frozen-lockfile
pnpm --dir "$toolkit" build

# Use the local Toolkit before pnpm attempts to fetch the registry
# artifact. Restore both inputs before running build or pack.
saved=$(mktemp -d)
cp package.json pnpm-lock.yaml "$saved/"
trap 'cp "$saved/package.json" "$saved/pnpm-lock.yaml" .; rm -rf "$saved"' EXIT
TOOLKIT="$toolkit" node --input-type=module <<'JS'
archive=( "$RUNNER_TEMP"/apcore-js-*.tgz )
installed=$(mktemp -d)
npm install --prefix "$installed" --ignore-scripts --no-save --no-package-lock "${archive[0]}"
core_root="$installed/node_modules/apcore-js"
install_deps() (
cd "$1"
saved=$(mktemp -d)
cp package.json pnpm-lock.yaml "$saved/"
trap 'cp "$saved/package.json" "$saved/pnpm-lock.yaml" .; rm -rf "$saved"' EXIT
CORE_ROOT="$core_root" TOOLKIT="$toolkit" node --input-type=module <<'JS'
import { readFileSync, writeFileSync } from 'node:fs';

const file = 'package.json';
const manifest = JSON.parse(readFileSync(file, 'utf8'));
manifest.pnpm ??= {};
manifest.pnpm.overrides ??= {};
manifest.pnpm.overrides['apcore-toolkit'] = 'link:' + process.env.TOOLKIT;
const overrides = manifest.pnpm.overrides ??= {};
overrides['apcore-js'] = 'link:' + process.env.CORE_ROOT;
if (process.cwd() !== process.env.TOOLKIT) overrides['apcore-toolkit'] = 'link:' + process.env.TOOLKIT;
writeFileSync(file, JSON.stringify(manifest, null, 2) + '\n');
JS
pnpm install --no-frozen-lockfile
pnpm install --no-frozen-lockfile
)
install_deps "$toolkit"
if [[ "$PWD" == "$toolkit" ]]; then exit; fi
pnpm --dir "$toolkit" build
install_deps "$PWD"
TOOLKIT="$toolkit" node --input-type=module <<'JS'
import assert from 'node:assert/strict';
import { realpathSync } from 'node:fs';
Expand Down Expand Up @@ -100,12 +119,14 @@ jobs:
working-directory: ${{ matrix.component }}/typescript
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- *checkout-core
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: pnpm/action-setup@v4
with:
version: '10.30.1'
- *build-core-npm
- *install-dependencies
- run: pnpm build
- name: Pack and install as an external consumer
Expand All @@ -119,7 +140,7 @@ jobs:
toolkit="$GITHUB_WORKSPACE/toolkit/typescript"
pnpm --dir "$toolkit" pack --pack-destination "$temporary"
fi
archives=( "$temporary"/*.tgz )
archives=( "$temporary"/*.tgz "$RUNNER_TEMP"/apcore-js-*.tgz )
toolkit_archive=( "$temporary"/apcore-toolkit-*.tgz )
cd "$temporary"
npm init -y
Expand Down
2 changes: 1 addition & 1 deletion a2a/docs/spec/srs.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ The ACL SHALL be consulted with **no arguments projection**, because a card is d

**Description:** At server construction, the system SHALL read apcore's `Executor.governance_state()` (`governanceState()` in TypeScript) and, when `unprotected_control_surface` is `true`, emit a warning naming the condition. The system SHALL NOT refuse to start, and SHALL NOT alter the card on account of the flag.

**Rationale:** `system.control.*` modules are annotated `requires_approval`, but apcore's approval gate warns once and continues when no `ApprovalHandler` is configured, failing closed only under `ExecutionPolicy(strict=True)`. So a deployment with `sys_modules.events` enabled, no `acl/` directory and no approval handler has write modules that nothing gates — and FR-AGC-003 criterion 12 removes them from the *card* without removing them from the *dispatch table*. Visibility and invocability are separate questions with separate answers, and the card rule must not be mistaken for a fix to the second.
**Rationale** — The Core default approval gate denies calls to `system.control.*` modules that require approval when no `ApprovalHandler` is configured. An explicit non-strict policy without an ACL or a strategy without governance gates can leave controls unprotected. FR-AGC-003 criterion 12 omits these modules from the public card while their dispatch routes remain registered.

`governance_state()` is the accessor apcore added for exactly this (apcore `PROTOCOL_SPEC` §6.6.5). It answers "is a gate *engaging*", not "is an ACL *attached*" — the ACL and approval gates are pipeline *steps*, and the `internal`, `testing` and `minimal` strategies remove them, so an executor can hold an ACL that no step ever consults. Re-deriving the question per binding from the raw `acl` / `approval_handler` fields would answer the wrong one, and only apcore-rust exposes those fields anyway. apcore made the accessor a **pure read** and left the reaction to the caller, naming "a serve-time adapter may warn or refuse" as the two options; warning is the reaction this project takes, for the reason FR-AGC-003 gives for not refusing.

Expand Down
22 changes: 8 additions & 14 deletions a2a/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,18 @@ serve(registry, auth=auth)

### A2A event subscriptions

Call `register_a2a_subscriber()` during application startup, before creating the
APCore client. Existing `sys_modules.events.subscribers` entries with
`type: a2a` then use the adapter's HTTP transport. The same factory resolves
Register the A2A factory on the APCore client's subscriber registry. The
client uses the factory for `type: a2a` configuration entries, including
`delegate_type: a2a` in a filter.

```python
from apcore import APCore, Config
from apcore.events import SubscriberRegistry
from apcore.full import APCore, Config
from apcore_a2a import register_a2a_subscriber

register_a2a_subscriber()
client = APCore(config=Config.discover())
subscribers = SubscriberRegistry()
register_a2a_subscriber(subscribers)
client = APCore(config=Config.discover(), subscriber_registry=subscribers)
try:
# Use the client with the application's configured subscribers.
pass
Expand All @@ -200,14 +201,7 @@ finally:

The transport uses `httpx` and sends one delivery attempt to the configured
`platform_url`. APCore applies retry, circuit breaker and dead-letter policy.
Core 0.33.0's configuration-driven circuit breaker records failures without
forwarding them to the retry and dead-letter pipeline. Use a Core release with
that forwarding enabled when those guarantees are required.

The factory change applies to future APCore clients in the process. To restore
the built-in transport, remove the registration call and restart with the same
subscriber configuration. The built-in transport requires the optional
`apcore[events]` extra.
Each client can use its own subscriber registry.

### `serve()`

Expand Down
Loading
Loading