# Magpie PowerContext independent-service integration experiment

The experiment uses real Magpie, PowerContext Server, and SQLite. Generation and upstream model responses use deterministic local HTTP fixtures. It verifies automatic Source capture, scheduled Memory extraction, Artifact provenance, recall in a new session after restarting both services, and isolation from an unrelated Scope. It does not evaluate real-model quality, interactive client behavior, provider prompt-cache hits, or production performance.

## Prerequisites and isolation

- Bun; the recorded run used 1.4.3.
- uv, able to download Python 3.12 and `powercontext[cli,server]==1.3.0`.
- A Magpie executable; the recorded run used 0.1.2700.
- The community repository's `packages/powercontext/` directory. The record used plugin 0.2.1 at commit `1a05a77431c5d6c64a43c3a80a2cc2562048e666`; the report records the hook file's SHA-256.

The script creates temporary HOME and database directories and separate listening ports. It does not use everyday Magpie settings or a personal memory store. Success stops the processes it started and removes the temporary directory. Failure preserves that run's directory for diagnosis; do not publish its credentials or complete logs.

## Run

Download `extraction.mjs`, check out [magpie-community/plugins](https://github.com/magpie-community/plugins), then set the absolute plugin directory:

```sh
export POWERCONTEXT_PLUGIN_DIR="/absolute/path/to/plugins/packages/powercontext"
bun "extraction.mjs" \
  --magpie "/absolute/path/to/magpie" \
  --report "result.json"
```

`--report` writes a new result for that run. Omitting `--magpie` invokes the shipped hooks directly and does not verify a real gateway. With mise or similar tools, `POWERCONTEXT_UV` can name the absolute uv executable.

If uv's shared dependency cache is damaged, point to a new cache without deleting the shared one:

```sh
export POWERCONTEXT_UV_CACHE="/absolute/path/to/fresh-cache"
```

The experiment sets `idleCaptureMs` to 1000 milliseconds and the Memory schedule to one second. These shorten acceptance-test waiting; ordinary plugin idle capture defaults to ten minutes, and the independent service owns its background schedule.

`--generation-env /absolute/path/to/private-server.env` can configure the service's generation model. The published record uses the default deterministic fixture. A real provider may charge for calls, and results depend on the model. This flag changes only service-side generation; the client-facing upstream model remains a fixture.

## Passing conditions

1. The initial Scope has no Sources or Memory.
2. The plugin captures the user and assistant messages, excluding injected reference blocks.
3. Scheduled extraction produces Memory whose Artifact revision cites that Source.
4. Memory remains after restarting Magpie and PowerContext.
5. A fresh session sends only one question. Its upstream request contains a reference with the random codename, without old conversation messages.
6. An unrelated Scope cannot recall that codename.

No remember or flush call seeds the answer or forces extraction. Failed assertions exit nonzero. A report is written only after every check passes.

## Files

- `extraction.mjs`: reproducible experiment adapted from the author's independent-service acceptance script.
- `result.json`: the actual run record used by the article. The random codename and temporary service identifiers are public demonstration data; the record contains no real service credentials.

PowerContext 1.3.0 is a historical service-contract pin for this experiment, not a recommendation for the latest release. Recheck APIs and the harness before applying this result to other versions.
