openadapt-kernel 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openadapt_kernel-0.1.0/.gitignore +87 -0
- openadapt_kernel-0.1.0/CHANGELOG.md +9 -0
- openadapt_kernel-0.1.0/LICENSE +21 -0
- openadapt_kernel-0.1.0/PKG-INFO +52 -0
- openadapt_kernel-0.1.0/README.md +22 -0
- openadapt_kernel-0.1.0/pyproject.toml +80 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/__init__.py +147 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/aci.py +82 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/cli.py +215 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/copilot.py +338 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/extension_bridge.py +134 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/fsm.py +198 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/interceptor.py +262 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/ledger.py +379 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/macro.py +354 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/mcp_server.py +224 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/oracles.py +317 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/probe.py +100 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/registry.py +145 -0
- openadapt_kernel-0.1.0/src/openadapt_kernel/runner.py +292 -0
- openadapt_kernel-0.1.0/tests/test_copilot_e2e.py +170 -0
- openadapt_kernel-0.1.0/tests/test_fsm_and_registry.py +146 -0
- openadapt_kernel-0.1.0/tests/test_kernel_boundaries.py +33 -0
- openadapt_kernel-0.1.0/tests/test_kernel_browser.py +162 -0
- openadapt_kernel-0.1.0/tests/test_kernel_cli.py +65 -0
- openadapt_kernel-0.1.0/tests/test_kernel_core.py +238 -0
- openadapt_kernel-0.1.0/tests/test_kernel_hardening.py +468 -0
- openadapt_kernel-0.1.0/tests/test_kernel_runner_e2e.py +177 -0
- openadapt_kernel-0.1.0/tests/test_oracles_and_mcp.py +237 -0
- openadapt_kernel-0.1.0/tests/test_probe_aci_and_suite.py +260 -0
- openadapt_kernel-0.1.0/uv.lock +663 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Envirionment
|
|
2
|
+
.env
|
|
3
|
+
config.json
|
|
4
|
+
data
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__
|
|
8
|
+
.cache
|
|
9
|
+
*.egg-info
|
|
10
|
+
*~
|
|
11
|
+
.venv
|
|
12
|
+
|
|
13
|
+
# Vim
|
|
14
|
+
*.sw[m-p]
|
|
15
|
+
|
|
16
|
+
# db
|
|
17
|
+
*.db
|
|
18
|
+
*.db-journal
|
|
19
|
+
|
|
20
|
+
# VSCode
|
|
21
|
+
.VSCode
|
|
22
|
+
.vsCode
|
|
23
|
+
|
|
24
|
+
# Idea
|
|
25
|
+
.idea
|
|
26
|
+
|
|
27
|
+
# Generated performance charts
|
|
28
|
+
performance
|
|
29
|
+
|
|
30
|
+
# Generated when adding editable dependencies in requirements.txt (-e)
|
|
31
|
+
src
|
|
32
|
+
|
|
33
|
+
# MacOS file
|
|
34
|
+
.DS_Store
|
|
35
|
+
|
|
36
|
+
*.pyc
|
|
37
|
+
*.pt
|
|
38
|
+
|
|
39
|
+
dist/
|
|
40
|
+
build/
|
|
41
|
+
|
|
42
|
+
OpenAdapt.spec
|
|
43
|
+
build_scripts/OpenAdapt.iss
|
|
44
|
+
|
|
45
|
+
# Temporary files
|
|
46
|
+
install.sh
|
|
47
|
+
*.txt
|
|
48
|
+
# The review brief for AI reviewers is generated but published.
|
|
49
|
+
!/llms-full.txt
|
|
50
|
+
output.png
|
|
51
|
+
|
|
52
|
+
# Legacy untracked directories (not part of repo)
|
|
53
|
+
omnimcp/
|
|
54
|
+
omnimcp.bak/
|
|
55
|
+
performance/
|
|
56
|
+
|
|
57
|
+
# Secrets (should never be committed)
|
|
58
|
+
*.key
|
|
59
|
+
*.key.*
|
|
60
|
+
*.key~
|
|
61
|
+
*.[kK][eE][yY]
|
|
62
|
+
*.[kK][eE][yY].*
|
|
63
|
+
*.p12
|
|
64
|
+
*.pfx
|
|
65
|
+
*.jks
|
|
66
|
+
*.keystore
|
|
67
|
+
*.pem
|
|
68
|
+
.env.backup
|
|
69
|
+
deploy/.env
|
|
70
|
+
|
|
71
|
+
# Never-publish workspace material (strategy, prospect research, counsel packs,
|
|
72
|
+
# personal contact details). Created ad hoc; must never reach a remote.
|
|
73
|
+
.private/
|
|
74
|
+
|
|
75
|
+
# Cover every .env variant, not one at a time. A .env.bak holding live
|
|
76
|
+
# API keys sat in a stash for six weeks and was one `git add -A` from being
|
|
77
|
+
# committed; .env.backup had already been added by hand after an earlier
|
|
78
|
+
# near-miss. Negate the committed template so it stays tracked.
|
|
79
|
+
.env.*
|
|
80
|
+
!.env.example
|
|
81
|
+
|
|
82
|
+
# Monorepo packages: the unanchored `src` and `*.txt` patterns above would hide
|
|
83
|
+
# package sources and the root llms.txt.
|
|
84
|
+
!/packages/*/src/
|
|
85
|
+
!/llms.txt
|
|
86
|
+
/.smoke/
|
|
87
|
+
!packages/flow/tests/nightly_only.txt
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v0.1.0 (2026-11-25)
|
|
4
|
+
|
|
5
|
+
- Initial release of `openadapt-kernel` with zero `openadapt-flow` dependencies and zero per-app engine code.
|
|
6
|
+
- Added default-deny `ObligationLedger`, typed `<MANDATORY_CONSTRAINTS>` + `<VERIFIED_CAPABILITIES>`, SSA opaque-ID provenance, and durable Saga checkpointing.
|
|
7
|
+
- Added wire/DOM-effect `CommitInterceptor`, full-DOM `observe_schema` + transactional `stage_form`, and `StepwiseHealer` for live-mounted modal re-grounding.
|
|
8
|
+
- Added cross-rail read-back oracles (`verify_sqlite_ro`, FlateDecode PDF `3 Tr`/`7 Tr`-filtered `verify_pdf_readback`, and `verify_cross_tab_dom`).
|
|
9
|
+
- Added `ShadowObserver` multi-trace `PortalPack` induction, 4-mutant offline qualification, `MicroHandoffSession`, `probe_before_click` occlusion/hover check, `OnlineACICalibrator`, Ed25519 receipts, live CDP/Playwright `runner`, CLI (`openadapt-kernel`), and stdio JSON-RPC 2.0 MCP server.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MLDSAI Inc. (OpenAdapt.AI)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openadapt-kernel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Minimal commit-boundary verification, macro-action staging, stepwise live-DOM healing, and shadow-to-autopilot kernel for GUI agents
|
|
5
|
+
Project-URL: Homepage, https://github.com/OpenAdaptAI/OpenAdapt/tree/main/packages/kernel
|
|
6
|
+
Project-URL: Repository, https://github.com/OpenAdaptAI/OpenAdapt/tree/main/packages/kernel
|
|
7
|
+
Project-URL: Documentation, https://github.com/OpenAdaptAI/OpenAdapt/blob/main/packages/kernel/README.md
|
|
8
|
+
Project-URL: Changelog, https://github.com/OpenAdaptAI/OpenAdapt/blob/main/packages/kernel/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/OpenAdaptAI/OpenAdapt/issues
|
|
10
|
+
Author-email: OpenAdapt <admin@openadapt.ai>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: browser-automation,commit-boundary,computer-use,gui-agents,mcp,verification
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: cryptography>=42.0.0
|
|
23
|
+
Provides-Extra: browser
|
|
24
|
+
Requires-Dist: playwright>=1.45.0; extra == 'browser'
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# openadapt-kernel
|
|
32
|
+
|
|
33
|
+
Minimal, self-contained runtime kernel (`< 3,200` LOC, zero `openadapt-flow` dependencies, zero per-app code) implementing commit-boundary verification, cross-rail read-back, reversible occlusion probing, online ACI calibration, macro staging, stepwise live-DOM healing, and shadow-to-autopilot execution:
|
|
34
|
+
|
|
35
|
+
1. **Default-Deny Obligation, Capability, and Saga Ledger (`ledger.py`):** Episodes start `UNVERIFIED` and emit `VERIFIED` only when every obligation has an independent post-commit read-back proof and zero dirty form buffers remain. Step-limit timeouts, crashes, and unverified exits deterministically return `ESCALATED`. Carries both cross-screen `<MANDATORY_CONSTRAINTS>` and `<VERIFIED_CAPABILITIES>` (user consent and SSA opaque-ID provenance), with durable Saga checkpointing across multi-system workflows.
|
|
36
|
+
2. **Wire and DOM-Effect Commit Interceptor (`interceptor.py`):** Detects commits from actual network mutations (`POST`, `PUT`, `PATCH`, `DELETE`) or non-empty dirty form submissions instead of button-label regexes. Excludes search/filter inputs from dirty buffers and escapes escalation payloads safely.
|
|
37
|
+
3. **Full-DOM Macro Staging and Stepwise Live-DOM Healer (`macro.py`):** Extracts all interactive controls across the full scrollable page (`observe_schema`), fills an entire form in one pre-commit batch with SSA provenance enforcement (`stage_form`), and heals drifted UI plans step-by-step against the live mounted DOM (handling modals and dialogs that only exist after earlier clicks).
|
|
38
|
+
4. **Cross-Rail Read-Back Oracles (`oracles.py`):** Independent read-only SQLite queries (`mode=ro`), pure-stdlib PDF content-stream extraction (filtering `3 Tr` / `7 Tr` invisible text), and multi-tab / fresh-reload DOM verification.
|
|
39
|
+
5. **Reversible Pre-Click Probe & Online ACI Calibration (`probe.py`, `aci.py`):** Hit-tests commit controls via `elementsFromPoint` plus an 80ms hover/focus probe to block transparent-overlay click-jacking (`probe_before_click`), and calibrates anomaly thresholds across shifting UI themes via `SessionStartNormalizer` and Gibbs-Candes `OnlineACICalibrator`.
|
|
40
|
+
6. **Shadow-to-Autopilot, 4-Mutant Offline Qualification, Micro-Handoff, Live Runner, and MCP Server (`copilot.py`, `extension_bridge.py`, `runner.py`, `mcp_server.py`, `cli.py`):** Induces zero-PII `PortalPack` specs from live Chrome Co-Pilot `extension_evidence.jsonl` recordings, qualifies verifiers offline against four counterfactual mutants (zero staging DB), runs `Draft-to-Commit` or `Verified Autopilot` across main and child popup windows via Playwright or `--cdp-url`, signs `openadapt.kernel.receipt/v1` Ed25519 receipts, and serves tools over stdio JSON-RPC 2.0 MCP.
|
|
41
|
+
|
|
42
|
+
## CLI Quickstart
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
openadapt-kernel shadow-sync --dir ./recordings --pack-id portal-v1 --out pack.json
|
|
46
|
+
openadapt-kernel qualify --pack pack.json --evidence ./recordings/run_1/extension_evidence.jsonl
|
|
47
|
+
openadapt-kernel keygen --priv priv.pem --pub pub.pem
|
|
48
|
+
openadapt-kernel run --pack pack.json --dossier dossier.json --mode draft --cdp-url http://127.0.0.1:9222
|
|
49
|
+
openadapt-kernel run --pack pack.json --dossier dossier.json --mode autopilot --url https://portal.example --commit-selector '[data-testid="submit-btn"]' --priv priv.pem --receipt-out receipt.json
|
|
50
|
+
openadapt-kernel verify-receipt --receipt receipt.json --pub pub.pem
|
|
51
|
+
openadapt-kernel serve-mcp
|
|
52
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# openadapt-kernel
|
|
2
|
+
|
|
3
|
+
Minimal, self-contained runtime kernel (`< 3,200` LOC, zero `openadapt-flow` dependencies, zero per-app code) implementing commit-boundary verification, cross-rail read-back, reversible occlusion probing, online ACI calibration, macro staging, stepwise live-DOM healing, and shadow-to-autopilot execution:
|
|
4
|
+
|
|
5
|
+
1. **Default-Deny Obligation, Capability, and Saga Ledger (`ledger.py`):** Episodes start `UNVERIFIED` and emit `VERIFIED` only when every obligation has an independent post-commit read-back proof and zero dirty form buffers remain. Step-limit timeouts, crashes, and unverified exits deterministically return `ESCALATED`. Carries both cross-screen `<MANDATORY_CONSTRAINTS>` and `<VERIFIED_CAPABILITIES>` (user consent and SSA opaque-ID provenance), with durable Saga checkpointing across multi-system workflows.
|
|
6
|
+
2. **Wire and DOM-Effect Commit Interceptor (`interceptor.py`):** Detects commits from actual network mutations (`POST`, `PUT`, `PATCH`, `DELETE`) or non-empty dirty form submissions instead of button-label regexes. Excludes search/filter inputs from dirty buffers and escapes escalation payloads safely.
|
|
7
|
+
3. **Full-DOM Macro Staging and Stepwise Live-DOM Healer (`macro.py`):** Extracts all interactive controls across the full scrollable page (`observe_schema`), fills an entire form in one pre-commit batch with SSA provenance enforcement (`stage_form`), and heals drifted UI plans step-by-step against the live mounted DOM (handling modals and dialogs that only exist after earlier clicks).
|
|
8
|
+
4. **Cross-Rail Read-Back Oracles (`oracles.py`):** Independent read-only SQLite queries (`mode=ro`), pure-stdlib PDF content-stream extraction (filtering `3 Tr` / `7 Tr` invisible text), and multi-tab / fresh-reload DOM verification.
|
|
9
|
+
5. **Reversible Pre-Click Probe & Online ACI Calibration (`probe.py`, `aci.py`):** Hit-tests commit controls via `elementsFromPoint` plus an 80ms hover/focus probe to block transparent-overlay click-jacking (`probe_before_click`), and calibrates anomaly thresholds across shifting UI themes via `SessionStartNormalizer` and Gibbs-Candes `OnlineACICalibrator`.
|
|
10
|
+
6. **Shadow-to-Autopilot, 4-Mutant Offline Qualification, Micro-Handoff, Live Runner, and MCP Server (`copilot.py`, `extension_bridge.py`, `runner.py`, `mcp_server.py`, `cli.py`):** Induces zero-PII `PortalPack` specs from live Chrome Co-Pilot `extension_evidence.jsonl` recordings, qualifies verifiers offline against four counterfactual mutants (zero staging DB), runs `Draft-to-Commit` or `Verified Autopilot` across main and child popup windows via Playwright or `--cdp-url`, signs `openadapt.kernel.receipt/v1` Ed25519 receipts, and serves tools over stdio JSON-RPC 2.0 MCP.
|
|
11
|
+
|
|
12
|
+
## CLI Quickstart
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
openadapt-kernel shadow-sync --dir ./recordings --pack-id portal-v1 --out pack.json
|
|
16
|
+
openadapt-kernel qualify --pack pack.json --evidence ./recordings/run_1/extension_evidence.jsonl
|
|
17
|
+
openadapt-kernel keygen --priv priv.pem --pub pub.pem
|
|
18
|
+
openadapt-kernel run --pack pack.json --dossier dossier.json --mode draft --cdp-url http://127.0.0.1:9222
|
|
19
|
+
openadapt-kernel run --pack pack.json --dossier dossier.json --mode autopilot --url https://portal.example --commit-selector '[data-testid="submit-btn"]' --priv priv.pem --receipt-out receipt.json
|
|
20
|
+
openadapt-kernel verify-receipt --receipt receipt.json --pub pub.pem
|
|
21
|
+
openadapt-kernel serve-mcp
|
|
22
|
+
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "openadapt-kernel"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Minimal commit-boundary verification, macro-action staging, stepwise live-DOM healing, and shadow-to-autopilot kernel for GUI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "OpenAdapt", email = "admin@openadapt.ai" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"computer-use",
|
|
17
|
+
"gui-agents",
|
|
18
|
+
"verification",
|
|
19
|
+
"commit-boundary",
|
|
20
|
+
"browser-automation",
|
|
21
|
+
"mcp",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
]
|
|
32
|
+
dependencies = [
|
|
33
|
+
"cryptography>=42.0.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
browser = ["playwright>=1.45.0"]
|
|
38
|
+
dev = ["pytest>=8", "ruff>=0.4", "mypy>=1.10"]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
openadapt-kernel = "openadapt_kernel.cli:main"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/OpenAdaptAI/OpenAdapt/tree/main/packages/kernel"
|
|
45
|
+
Repository = "https://github.com/OpenAdaptAI/OpenAdapt/tree/main/packages/kernel"
|
|
46
|
+
Documentation = "https://github.com/OpenAdaptAI/OpenAdapt/blob/main/packages/kernel/README.md"
|
|
47
|
+
Changelog = "https://github.com/OpenAdaptAI/OpenAdapt/blob/main/packages/kernel/CHANGELOG.md"
|
|
48
|
+
Issues = "https://github.com/OpenAdaptAI/OpenAdapt/issues"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build]
|
|
51
|
+
dev-mode-dirs = ["src"]
|
|
52
|
+
|
|
53
|
+
[tool.hatch.build.targets.wheel]
|
|
54
|
+
ignore-vcs = true
|
|
55
|
+
exclude = ["**/__pycache__/**", "**/*.pyc"]
|
|
56
|
+
packages = ["src/openadapt_kernel"]
|
|
57
|
+
core-metadata-version = "2.4"
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.sdist]
|
|
60
|
+
ignore-vcs = true
|
|
61
|
+
include = [
|
|
62
|
+
"/src/openadapt_kernel/**/*.py",
|
|
63
|
+
"/tests/*.py",
|
|
64
|
+
"/README.md",
|
|
65
|
+
"/CHANGELOG.md",
|
|
66
|
+
"/LICENSE",
|
|
67
|
+
"/pyproject.toml",
|
|
68
|
+
"/uv.lock",
|
|
69
|
+
]
|
|
70
|
+
core-metadata-version = "2.4"
|
|
71
|
+
|
|
72
|
+
[tool.pytest.ini_options]
|
|
73
|
+
testpaths = ["tests"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff]
|
|
76
|
+
target-version = "py311"
|
|
77
|
+
line-length = 100
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint]
|
|
80
|
+
select = ["E4", "E7", "E9", "F", "I"]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""openadapt-kernel: minimal commit-boundary verification and shadow-to-autopilot runtime."""
|
|
2
|
+
|
|
3
|
+
from openadapt_kernel.aci import (
|
|
4
|
+
OnlineACICalibrator,
|
|
5
|
+
SessionStartNormalizer,
|
|
6
|
+
)
|
|
7
|
+
from openadapt_kernel.copilot import (
|
|
8
|
+
MicroHandoffRequest,
|
|
9
|
+
MicroHandoffSession,
|
|
10
|
+
MutantQualificationReport,
|
|
11
|
+
PortalPack,
|
|
12
|
+
ShadowObserver,
|
|
13
|
+
ShadowTrace,
|
|
14
|
+
generate_ephemeral_ed25519_keypair,
|
|
15
|
+
mint_receipt,
|
|
16
|
+
qualify_verifier_offline,
|
|
17
|
+
verify_receipt,
|
|
18
|
+
)
|
|
19
|
+
from openadapt_kernel.extension_bridge import (
|
|
20
|
+
ExtensionSessionSummary,
|
|
21
|
+
induce_pack_from_extension_recordings,
|
|
22
|
+
parse_extension_evidence_jsonl,
|
|
23
|
+
replay_evidence_into_interceptor,
|
|
24
|
+
)
|
|
25
|
+
from openadapt_kernel.fsm import (
|
|
26
|
+
FSMState,
|
|
27
|
+
FSMTransition,
|
|
28
|
+
PortalFSM,
|
|
29
|
+
SafetyProof,
|
|
30
|
+
SafetyViolation,
|
|
31
|
+
verify_fsm_safety,
|
|
32
|
+
)
|
|
33
|
+
from openadapt_kernel.interceptor import (
|
|
34
|
+
CommitClassification,
|
|
35
|
+
CommitInterceptor,
|
|
36
|
+
NetworkEvent,
|
|
37
|
+
is_search_or_filter_field,
|
|
38
|
+
sanitize_action_string,
|
|
39
|
+
)
|
|
40
|
+
from openadapt_kernel.ledger import (
|
|
41
|
+
CapabilityToken,
|
|
42
|
+
FinalizationDecision,
|
|
43
|
+
Obligation,
|
|
44
|
+
ObligationLedger,
|
|
45
|
+
ProvenanceViolation,
|
|
46
|
+
ReadBackProof,
|
|
47
|
+
)
|
|
48
|
+
from openadapt_kernel.macro import (
|
|
49
|
+
ControlSchema,
|
|
50
|
+
HealResult,
|
|
51
|
+
PlanStep,
|
|
52
|
+
StageResult,
|
|
53
|
+
StepwiseHealer,
|
|
54
|
+
observe_schema,
|
|
55
|
+
stage_form,
|
|
56
|
+
)
|
|
57
|
+
from openadapt_kernel.mcp_server import (
|
|
58
|
+
dispatch_tool_call,
|
|
59
|
+
handle_jsonrpc_message,
|
|
60
|
+
serve_stdio,
|
|
61
|
+
)
|
|
62
|
+
from openadapt_kernel.oracles import (
|
|
63
|
+
OracleVerdict,
|
|
64
|
+
extract_pdf_visible_text,
|
|
65
|
+
token_boundary_check,
|
|
66
|
+
verify_cross_tab_dom,
|
|
67
|
+
verify_pdf_readback,
|
|
68
|
+
verify_sqlite_ro,
|
|
69
|
+
)
|
|
70
|
+
from openadapt_kernel.probe import (
|
|
71
|
+
ProbeResult,
|
|
72
|
+
probe_before_click,
|
|
73
|
+
)
|
|
74
|
+
from openadapt_kernel.registry import (
|
|
75
|
+
SignedPackEnvelope,
|
|
76
|
+
publish_signed_pack,
|
|
77
|
+
pull_verified_pack,
|
|
78
|
+
render_audit_card_html,
|
|
79
|
+
scan_pack_for_pii,
|
|
80
|
+
)
|
|
81
|
+
from openadapt_kernel.runner import (
|
|
82
|
+
RunResult,
|
|
83
|
+
format_run_result_json,
|
|
84
|
+
run_portal_pack,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
__all__ = [
|
|
88
|
+
"CapabilityToken",
|
|
89
|
+
"CommitClassification",
|
|
90
|
+
"CommitInterceptor",
|
|
91
|
+
"ControlSchema",
|
|
92
|
+
"ExtensionSessionSummary",
|
|
93
|
+
"FSMState",
|
|
94
|
+
"FSMTransition",
|
|
95
|
+
"FinalizationDecision",
|
|
96
|
+
"HealResult",
|
|
97
|
+
"MicroHandoffRequest",
|
|
98
|
+
"MicroHandoffSession",
|
|
99
|
+
"MutantQualificationReport",
|
|
100
|
+
"NetworkEvent",
|
|
101
|
+
"Obligation",
|
|
102
|
+
"ObligationLedger",
|
|
103
|
+
"OnlineACICalibrator",
|
|
104
|
+
"OracleVerdict",
|
|
105
|
+
"PlanStep",
|
|
106
|
+
"PortalFSM",
|
|
107
|
+
"PortalPack",
|
|
108
|
+
"ProbeResult",
|
|
109
|
+
"ProvenanceViolation",
|
|
110
|
+
"ReadBackProof",
|
|
111
|
+
"RunResult",
|
|
112
|
+
"SafetyProof",
|
|
113
|
+
"SafetyViolation",
|
|
114
|
+
"SessionStartNormalizer",
|
|
115
|
+
"ShadowObserver",
|
|
116
|
+
"ShadowTrace",
|
|
117
|
+
"SignedPackEnvelope",
|
|
118
|
+
"StageResult",
|
|
119
|
+
"StepwiseHealer",
|
|
120
|
+
"dispatch_tool_call",
|
|
121
|
+
"extract_pdf_visible_text",
|
|
122
|
+
"format_run_result_json",
|
|
123
|
+
"generate_ephemeral_ed25519_keypair",
|
|
124
|
+
"handle_jsonrpc_message",
|
|
125
|
+
"induce_pack_from_extension_recordings",
|
|
126
|
+
"is_search_or_filter_field",
|
|
127
|
+
"mint_receipt",
|
|
128
|
+
"observe_schema",
|
|
129
|
+
"parse_extension_evidence_jsonl",
|
|
130
|
+
"probe_before_click",
|
|
131
|
+
"publish_signed_pack",
|
|
132
|
+
"pull_verified_pack",
|
|
133
|
+
"qualify_verifier_offline",
|
|
134
|
+
"render_audit_card_html",
|
|
135
|
+
"replay_evidence_into_interceptor",
|
|
136
|
+
"run_portal_pack",
|
|
137
|
+
"sanitize_action_string",
|
|
138
|
+
"scan_pack_for_pii",
|
|
139
|
+
"serve_stdio",
|
|
140
|
+
"stage_form",
|
|
141
|
+
"token_boundary_check",
|
|
142
|
+
"verify_cross_tab_dom",
|
|
143
|
+
"verify_fsm_safety",
|
|
144
|
+
"verify_pdf_readback",
|
|
145
|
+
"verify_receipt",
|
|
146
|
+
"verify_sqlite_ro",
|
|
147
|
+
]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Zero-label session-start normalization and Online Adaptive Conformal Inference (ACI).
|
|
2
|
+
|
|
3
|
+
Implements:
|
|
4
|
+
- SessionStartNormalizer: estimates (mu, sigma) from K benign read-only
|
|
5
|
+
navigation frames to normalize commit anomaly scores under unseen UI themes.
|
|
6
|
+
- OnlineACICalibrator: Gibbs & Candes (NeurIPS 2021) online quantile update
|
|
7
|
+
alpha_{t+1} = alpha_t + gamma * (target_alpha - err_t), triggered strictly
|
|
8
|
+
when independent post-commit read-back resolves ground-truth Y_t.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import math
|
|
14
|
+
from dataclasses import dataclass, field
|
|
15
|
+
from typing import List
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class SessionStartNormalizer:
|
|
20
|
+
min_frames: int = 3
|
|
21
|
+
scores: List[float] = field(default_factory=list)
|
|
22
|
+
|
|
23
|
+
def observe_benign_nav(self, score: float) -> None:
|
|
24
|
+
self.scores.append(float(score))
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def ready(self) -> bool:
|
|
28
|
+
return len(self.scores) >= self.min_frames
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def mean(self) -> float:
|
|
32
|
+
if not self.scores:
|
|
33
|
+
return 0.0
|
|
34
|
+
return sum(self.scores) / len(self.scores)
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def std(self) -> float:
|
|
38
|
+
if len(self.scores) < 2:
|
|
39
|
+
return 1.0
|
|
40
|
+
mu = self.mean
|
|
41
|
+
var = sum((x - mu) ** 2 for x in self.scores) / len(self.scores)
|
|
42
|
+
return max(math.sqrt(var), 1e-4)
|
|
43
|
+
|
|
44
|
+
def z_score(self, commit_score: float) -> float:
|
|
45
|
+
if not self.ready:
|
|
46
|
+
return float(commit_score)
|
|
47
|
+
return (float(commit_score) - self.mean) / self.std
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class OnlineACICalibrator:
|
|
52
|
+
target_alpha: float = 0.02
|
|
53
|
+
gamma: float = 0.05
|
|
54
|
+
alpha_t: float = 0.02
|
|
55
|
+
history_scores: List[float] = field(default_factory=list)
|
|
56
|
+
errors: List[int] = field(default_factory=list)
|
|
57
|
+
|
|
58
|
+
def threshold(self) -> float:
|
|
59
|
+
if not self.history_scores:
|
|
60
|
+
return 2.0
|
|
61
|
+
sorted_s = sorted(self.history_scores)
|
|
62
|
+
q = min(max(1.0 - self.alpha_t, 0.0), 1.0)
|
|
63
|
+
idx = min(int(math.ceil(q * len(sorted_s))) - 1, len(sorted_s) - 1)
|
|
64
|
+
idx = max(idx, 0)
|
|
65
|
+
return sorted_s[idx]
|
|
66
|
+
|
|
67
|
+
def should_flag(self, score: float) -> bool:
|
|
68
|
+
return float(score) > self.threshold()
|
|
69
|
+
|
|
70
|
+
def update_from_readback(self, score: float, realized_error: bool) -> float:
|
|
71
|
+
"""Update alpha_t once independent read-back resolves whether a false alarm occurred."""
|
|
72
|
+
err_t = 1 if realized_error else 0
|
|
73
|
+
self.history_scores.append(float(score))
|
|
74
|
+
self.errors.append(err_t)
|
|
75
|
+
self.alpha_t = min(max(self.alpha_t + self.gamma * (self.target_alpha - err_t), 0.0), 1.0)
|
|
76
|
+
return self.alpha_t
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def empirical_error_rate(self) -> float:
|
|
80
|
+
if not self.errors:
|
|
81
|
+
return 0.0
|
|
82
|
+
return sum(self.errors) / len(self.errors)
|