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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ The Deploy workflow attempts a staging update after every `dev` push. The `stagi

Use the guarded production wrapper for the first protocol-3 cutover and any later compatibility-contract change. It validates the protocol-3 device map, published extension, canary credential, immutable source snapshot, Worker provenance, and deployment evidence. Follow the [production rollout runbook](docs/unattended-production-rollout.md).

For protocol changes, deploy Smart Compliance Platform's matching protocol fork
before promoting the Understudy release to `master` and submitting the store
build. Follow the [extension release order](apps/extension/RUNBOOK.md#release-a-protocol-change).

## Preserve attended proof history

The completed attended design and production proof remain in Git at Understudy `master@797d0e489df2772d0f5d597141982547861881bb` and Metamind `master@0814deb`. Attended mode remains compatible in the current extension and API.
45 changes: 38 additions & 7 deletions apps/backend/src/dashboard/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ for (const button of document.querySelectorAll("[data-copy]")) {
});
}
const countdown = document.querySelector("[data-expires]");
const expiresAt = Number(countdown?.getAttribute("data-expires"));
if (countdown) {
const expiresAt = Number(countdown.getAttribute("data-expires"));
const tick = () => {
const left = Math.max(0, Math.floor((expiresAt - Date.now()) / 1000));
countdown.textContent = left > 0
Expand All @@ -69,15 +69,46 @@ if (pairing) {
const extensionId = pairing.getAttribute("data-extension-id");
const status = document.getElementById("pairing-status");
pairing.removeAttribute("data-offer");
if (offer && extensionId && globalThis.chrome?.runtime?.sendMessage) {
if (offer && extensionId && status && globalThis.chrome?.runtime?.sendMessage) {
const failure = "The extension did not accept the offer. Confirm it is installed, then generate a new offer.";
const showReply = (reply, confirmationId) => {
if (chrome.runtime.lastError) {
status.textContent = failure;
return;
}
if (reply?.status === "confirmation_pending" || reply?.status === "pairing") {
const id = confirmationId ?? reply.confirmationId;
if (typeof id !== "string") {
status.textContent = failure;
return;
}
status.textContent = reply.status === "confirmation_pending"
? "Open the Understudy side panel to confirm pairing."
: "Pairing this browser…";
setTimeout(() => chrome.runtime.sendMessage(
extensionId,
{ type: "understudy_pair_status", confirmationId: id },
(next) => showReply(next, id),
), 1_000);
return;
}
status.textContent = reply?.ok !== true
? failure
: reply.status === "closing_previous_sessions"
? "Pairing saved. The previous service’s sessions are closing."
: "This browser is paired. You can close this page.";
};
// Store builds with the two-field offer schema accept this first message.
const message = { type: "understudy_pair_offer", offer };
chrome.runtime.sendMessage(
extensionId,
{ type: "understudy_pair_offer", offer },
message,
(reply) => {
if (!status) return;
status.textContent = chrome.runtime.lastError || reply?.ok !== true
? "The extension did not accept the offer. Confirm it is installed, then generate a new offer."
: "This browser is paired. You can close this page.";
if (reply?.status === "expiry_required") {
chrome.runtime.sendMessage(extensionId, { ...message, expiresAt }, showReply);
} else {
showReply(reply);
}
},
);
} else if (status) {
Expand Down
12 changes: 8 additions & 4 deletions apps/extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,24 @@ pnpm --filter @understudy/extension build:store
pnpm --filter @understudy/extension zip:store
```

`test:e2e` launches local Chrome with the store build. It verifies bounded
`test:e2e` validates the store manifest and launches local Chrome with the internal E2E build. It verifies bounded
semantic capture on a 10,000-element document, offscreen find, inspect,
pagination, same-process and OOPIF frames, shadow DOM, structured deltas, and
stale refs. It also verifies that worker eviction expires refs and cursors.

Load `.output/chrome-mv3/` for internal testing, `.output/chrome-mv3-staging/` for hosted staging, or `.output/chrome-mv3-store/` for store acceptance. The staging build has the stable extension ID `ebpcldlibljfjhcfknagjcdmhggeknfc` and connects only to `https://staging.understudy.proofof.tech`. The store build connects only to `https://understudy.proofof.tech` and has no pinned key.
Load `.output/chrome-mv3/` for internal testing, `.output/chrome-mv3-staging/` for hosted staging, or `.output/chrome-mv3-store/` for store acceptance. The staging build has the stable extension ID `ebpcldlibljfjhcfknagjcdmhggeknfc` and connects only to `https://staging.understudy.proofof.tech`. The store build omits a pinned key and connects to Understudy at `https://understudy.proofof.tech` and Smart Compliance Platform (SCP) at `https://browser.nomixhq.com`.

`store-release.json` records the manually submitted or published Chrome Web Store artifact for ID `lbmbdjjaodgipnleaggclnobbijpadee`. Production deployment requires `status: "published"` and normalized build contents equal to that record. ZIP timestamps and compression do not affect this gate.

## Pair a browser

Sign in at `https://understudy.proofof.tech/dashboard` and select **Pair this browser**. The CSRF-protected POST mints an opaque single-use offer. The dashboard sends it directly to the installed extension with `chrome.runtime.sendMessage`; the offer never enters a URL, browser history, or referrer.
For Understudy, sign in at `https://understudy.proofof.tech/dashboard` and select **Pair this browser**. The CSRF-protected POST creates a single-use offer. The dashboard sends it directly to the installed extension with `chrome.runtime.sendMessage` and keeps it out of the URL.

The extension accepts only the exact sender page `https://understudy.proofof.tech/dashboard/pair`, an exact two-field schema, and a 43-character base64url offer. Re-pairing a live installation rotates the existing device credential without releasing its assignments. A locally detected revocation omits its dead credential. If a browser was revoked while offline and still submits that credential, pairing returns a fresh device identity and the extension durably fences and discards stale local ownership before activating it, including across service-worker restarts. A different Chrome profile creates a separate browser.
For SCP, create an offer in the SCP console and open its pairing link in the Chrome profile you want to enroll. SCP's API creates the offer. The gateway serves `https://browser.nomixhq.com/dashboard/pair`, which removes the offer fragment from the current history entry with `history.replaceState` on load before sending the offer to the extension. The fragment stays out of the HTTP request. Chrome may briefly record it in history before the page runs. The offer expires after 10 minutes and is single-use.

The extension accepts the exact `/dashboard/pair` page at any service origin compiled into the build. It ignores a fragment and refuses sender URLs with a query string. It requires the two-field message schema and a 43-character base64url offer. The sender page determines where the extension claims the offer, and the extension saves that origin with the profile for future connections.

Re-pairing with the same service rotates the existing device credential without releasing its assignments. Pairing with a different service creates a device there while the extension releases any old assignments. A locally detected revocation omits its dead credential. If a browser was revoked while offline and still submits that credential, pairing returns a fresh device identity and the extension durably fences and discards stale local ownership before activating it, including across service-worker restarts. A different Chrome profile creates a separate browser.

An empty default origin policy is valid, but the device cannot accept a session until configured.

Expand Down
39 changes: 31 additions & 8 deletions apps/extension/RUNBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ pnpm --filter @understudy/extension build:store
pnpm --filter @understudy/extension zip:store
```

`test:e2e` uses local Chrome and the existing `ws` package. It loads the store
build, configures hosting through the side panel, and exercises bounded
`test:e2e` validates the store manifest and loads the internal E2E build in local Chrome.
It configures hosting through the side panel and exercises bounded
semantic discovery across large pages, frames, and shadow DOM.

## Release a protocol change

1. Merge the Understudy protocol change to `dev`.
2. Deploy the matching protocol fork to the hosted Smart Compliance Platform
(SCP) browser gateway.
3. Promote Understudy's release commit from `dev` to `master`.
4. Submit the store ZIP for that commit and record it once Chrome Web Store
publishes it. Follow [the store submission procedure](WEBSTORE.md).

Expect `master`’s Deploy run to fail at `verify:store-release` until you promote the store record to `published`.

## Verify semantic discovery

1. Confirm `device_hello` advertises `semantic-elements-v1` before enabling the
Expand Down Expand Up @@ -53,8 +64,10 @@ semantic discovery across large pages, frames, and shadow DOM.
1. Build with `pnpm --filter @understudy/extension build:store`.
2. Open `chrome://extensions`, enable Developer mode, and choose Load unpacked.
3. Select `apps/extension/.output/chrome-mv3-store/`.
4. Confirm the manifest requests only the expected debugger, storage, alarms,
side-panel, and canonical-host permissions.
4. Confirm the manifest requests the expected debugger, storage, alarms, and
side-panel permissions. Check that both host permissions and external
message matches contain exactly `https://understudy.proofof.tech/*` and
`https://browser.nomixhq.com/*`.

Do not use WXT development mode for release acceptance.

Expand All @@ -67,7 +80,9 @@ Use the pinned staging build to test hosted changes before store submission:
3. Load `apps/extension/.output/chrome-mv3-staging/` through `chrome://extensions`.
4. Confirm Chrome reports extension ID `ebpcldlibljfjhcfknagjcdmhggeknfc`.
5. Sign in at `https://staging.understudy.proofof.tech/dashboard` and pair the browser.
6. Reject pairing messages from production, loopback, query-bearing, fragment-bearing, and trailing-slash sender URLs.
6. Confirm the extension rejects pairing messages from either production host
and from loopback. On staging, verify that a fragment on the exact pairing
page is accepted and that a query or trailing slash is refused.
7. Verify hosted control, OAuth, Model Context Protocol (MCP), dashboard, privacy, and side-panel links remain on staging.

The staging extension retains internal controls and broad host permissions. Do not submit it to the Chrome Web Store.
Expand All @@ -85,9 +100,17 @@ The staging extension retains internal controls and broad host permissions. Do n
acknowledges the new version, then become available without re-pairing.
6. Remove an origin used by a controlled tab. The backend must fence the lease,
terminalize the session, and push the narrower policy immediately.
7. Replay or alter the pairing offer and try it from another origin. Each must
fail. Pairing the same installation again must rotate its credential rather
than leave a live predecessor.
7. Replay or alter the pairing offer and try it from an unlisted origin. Each
must fail. Re-pair with Understudy and verify that the device credential
rotates and the previous credential stops working.

## Verify SCP pairing

1. In the SCP console, create a pairing offer. Open the link in the Chrome
profile with the store extension installed.
2. Confirm the gateway page at `https://browser.nomixhq.com/dashboard/pair`
removes the fragment from the current history entry and pairs the extension.
3. Restart Chrome and verify that the same device reconnects to the SCP gateway.

## Exercise lifecycle convergence

Expand Down
22 changes: 15 additions & 7 deletions apps/extension/WEBSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ curl --fail --silent --show-error https://understudy.proofof.tech/privacy >/dev/
Confirm `manifest.json` is at the archive root. Distribution is unlisted, free,
all regions, category Productivity → Tools.

Submit the exact ZIP built from the final clean `dev` release commit. Record that commit and the raw ZIP SHA-256 outside Git while review is pending. Do not reuse an artifact built before the deployment and staging changes.
For a protocol change, submit after SCP's matching protocol fork is live and
the release commit has reached `master`. Follow [the protocol release order](RUNBOOK.md#release-a-protocol-change).
Submit the exact ZIP built from the final clean `dev` release commit. Record
that commit and the raw ZIP SHA-256 outside Git while review is pending.

After Chrome Web Store reports the item as published, return to the exact source commit and record the published artifact:

Expand All @@ -26,7 +29,12 @@ pnpm --filter @understudy/extension record:store-release -- \
pnpm --filter @understudy/extension verify:store-release
```

Run the recorder from a clean checkout of the exact submitted commit and replace `source_commit_sha` with that checkout's full `HEAD`. The recorder rejects a dirty tree, a different commit, or an abbreviated SHA. Commit the resulting `store-release.json` separately on `dev`, then promote `dev` to `master`. Never set `published` while the item remains in review.
Run the recorder from a clean checkout of the exact submitted commit and replace
`source_commit_sha` with that checkout's full `HEAD`. The recorder rejects a dirty
tree, a different commit, or an abbreviated SHA. Commit the resulting
`store-release.json` separately on `dev` and promote the marker to `master`.
The production deployment gate requires the published marker and the matching
build contents.

## Listing copy

Expand All @@ -40,9 +48,9 @@ can operate controlled tabs on exact origins you allow.
```text
UNDERSTUDY IS BETA SOFTWARE.

Understudy pairs a dedicated Chrome profile with the hosted Understudy service. An AI client you authorize can open and operate extension-owned tabs only on exact website origins you allow.
Understudy pairs a dedicated Chrome profile with the hosted Understudy service or the Smart Compliance Platform gateway. An AI client you authorize can open and operate extension-owned tabs only on exact website origins you allow.

Pairing is approved directly between the Understudy dashboard and the installed extension. The side panel shows device and policy state, controlled-window inventory, connection recovery, an emergency stop, and a local troubleshooting log.
Pair from your service's dashboard. The side panel shows device and policy state, controlled-window inventory, connection recovery, an emergency stop, and a local troubleshooting log.

Understudy does not choose tasks or approve actions. Your connected AI client selects bounded semantic page elements and requests actions. Element references are opaque and checked again before use; the extension does not expose selectors or automatically redirect an action to a changed target. You control pairing, allowed origins, API or OAuth connections, and device revocation.

Expand Down Expand Up @@ -72,9 +80,9 @@ Pair Chrome with Understudy so an AI client the user authorizes can operate exte
- `alarms`: provide a Manifest V3 wake-up backstop for connection recovery,
policy/inventory reconciliation, and exact controlled-window cleanup.
- `sidePanel`: pair, show connection and policy state, and stop hosting.
- `https://understudy.proofof.tech/*`: receive direct one-time pairing offers,
request short-lived connect tickets, and exchange validated control/session
frames over HTTPS and WSS.
- `https://understudy.proofof.tech/*` and `https://browser.nomixhq.com/*` allow
the extension to receive pairing offers, request short-lived connect tickets,
and exchange control and session frames with the service that paired the profile.

The package requests neither `tabs` nor `activeTab`. Select **No remote code**:
all executable code is bundled; remote commands are validated data, not code.
Expand Down
4 changes: 3 additions & 1 deletion apps/extension/scripts/e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
import path from "node:path";
import process from "node:process";
import WebSocket, { WebSocketServer } from "ws";
import { validateStoreManifest } from "./store-release.mjs";

class CdpClient {
static connect(url) {
Expand Down Expand Up @@ -53,7 +54,8 @@ const storeManifest = JSON.parse(
await readFile(path.join(storeExtensionDir, "manifest.json"), "utf8"),
);
const manifest = JSON.parse(await readFile(path.join(extensionDir, "manifest.json"), "utf8"));
if (storeManifest.version !== "0.2.0" || manifest.version !== "0.2.0") {
validateStoreManifest(storeManifest, "0.2.0");
if (manifest.version !== "0.2.0") {
throw new Error("unexpected extension build version");
}

Expand Down
5 changes: 3 additions & 2 deletions apps/extension/scripts/store-release.integration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ function run(command, args, cwd) {
}

function storeManifest() {
const matches = ["https://understudy.proofof.tech/*", "https://browser.nomixhq.com/*"];
return {
name: "Understudy Beta",
version: "0.2.0",
homepage_url: "https://understudy.proofof.tech/dashboard",
host_permissions: ["https://understudy.proofof.tech/*"],
host_permissions: [...matches],
externally_connectable: {
matches: ["https://understudy.proofof.tech/*"],
matches: [...matches],
},
};
}
33 changes: 19 additions & 14 deletions apps/extension/scripts/store-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const targets = JSON.parse(
);
const EXTENSION_ID = targets.production.extensionId;
const PRODUCTION_ORIGIN = targets.production.origin;
const STORE_MATCHES = [
PRODUCTION_ORIGIN,
...targets.production.additionalServiceOrigins,
].map((origin) => `${origin}/*`);
const SHA256_PATTERN = /^[0-9a-f]{64}$/;
const COMMIT_PATTERN = /^[0-9a-f]{40}$/;

Expand Down Expand Up @@ -86,16 +90,21 @@ export function validateStoreManifest(manifest, expectedVersion, allowLegacyPair
if (manifest.homepage_url !== `${PRODUCTION_ORIGIN}/dashboard`) {
throw new Error("store manifest homepage is not production");
}
const externalMatches = manifest.externally_connectable?.matches;
const legacyPairing = allowLegacyPairing && externalMatches === undefined;
if (
JSON.stringify(manifest.host_permissions) !==
JSON.stringify([`${PRODUCTION_ORIGIN}/*`]) ||
(!legacyPairing &&
JSON.stringify(externalMatches) !== JSON.stringify([`${PRODUCTION_ORIGIN}/*`]))
) {
throw new Error("store manifest network origins are not production-only");
const hostMatches = JSON.stringify(manifest.host_permissions);
const externalMatches = JSON.stringify(manifest.externally_connectable?.matches);
const expectedMatches = JSON.stringify(STORE_MATCHES);
if (hostMatches === expectedMatches && externalMatches === expectedMatches) return;

if (allowLegacyPairing && expectedVersion === "0.1.2") {
const legacyMatches = JSON.stringify([`${PRODUCTION_ORIGIN}/*`]);
if (
hostMatches === legacyMatches &&
(externalMatches === undefined || externalMatches === legacyMatches)
) {
return;
}
}
throw new Error("store manifest network origins do not match the store allowlist");
}

export async function verifyStoreRelease({
Expand All @@ -111,11 +120,7 @@ export async function verifyStoreRelease({
allowInReview,
);
const manifest = JSON.parse(await readFile(join(directory, "manifest.json"), "utf8"));
validateStoreManifest(
manifest,
release.version,
allowInReview && release.version === "0.1.2",
);
validateStoreManifest(manifest, release.version, allowInReview);
const directoryDigest = await contentDigest(directory);
if (directoryDigest !== release.contentSha256) {
throw new Error("store build content does not match the recorded release");
Expand Down
Loading