Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
14b87ce
Align Python provider contracts
GTrunSec Jul 20, 2026
ec3bb47
Sync canonical schema profile
GTrunSec Jul 21, 2026
e6351a0
chore: align Python provider contracts
GTrunSec Jul 22, 2026
b9a7b6d
style: apply repository formatting
GTrunSec Jul 22, 2026
1bdda0c
fix: align provider package schema inclusions
GTrunSec Jul 24, 2026
cdebde8
fix: align exact-selector provider contract
GTrunSec Jul 26, 2026
18c2eb0
chore: sync shared structural index schema
GTrunSec Jul 26, 2026
5c1147b
feat: align project scope schemas
GTrunSec Jul 30, 2026
b9042fe
feat: align ASP provider projection contracts
GTrunSec Aug 9, 2026
03fbe0e
fix: preserve lexical header field order
GTrunSec Aug 9, 2026
ebd8abc
feat: adopt resident Python HTTP provider
GTrunSec Aug 25, 2026
65d4bbf
feat: align ASP provider contracts
GTrunSec Aug 28, 2026
f4d28a8
feat: rename project to asp-python
GTrunSec Sep 1, 2026
5200214
ci: use API-owned Python policy gates
GTrunSec Sep 1, 2026
8b7703d
Merge remote-tracking branch 'origin/main' into agent/asp-contract-al…
GTrunSec Sep 1, 2026
f5090cb
fix: close native exact runtime review gaps
GTrunSec Sep 1, 2026
adad838
refactor: align provider with client-owned search
GTrunSec Sep 8, 2026
456d672
schema: sync playbook performance receipt
GTrunSec Sep 8, 2026
745c1bb
refactor: align ASP Python public boundary
GTrunSec Sep 9, 2026
805f6ca
fix(query): bind the current ASP V1 contract
GTrunSec Sep 12, 2026
c3afb2a
refactor(query): adopt enhanced V1 syntax contracts
GTrunSec Sep 13, 2026
7785b3d
Merge commit '805f6ca4b247157399cd2a78b7e924d479ae5980' into agent/as…
GTrunSec Sep 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
Expand Down Expand Up @@ -48,12 +49,6 @@ jobs:
- name: Test
run: uv run --group test pytest tests -q

- name: Self harness
run: uv run --group test asp-python .

- name: Agent snapshot
run: uv run --group test asp-python --agent-snapshot .

- name: Build package
run: uv build

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- os: macos-latest
target: aarch64-apple-darwin
env:
BINARY: py-harness
BINARY: asp-python
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag || github.ref_name }}
TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
set -euo pipefail
rm -rf build dist package py_harness_entry.py
cat > py_harness_entry.py <<'PY'
from python_lang_project_harness import run_cli_from_env
from asp_python import run_cli_from_env

raise SystemExit(run_cli_from_env())
PY
Expand All @@ -82,7 +82,7 @@ jobs:
--name "$BINARY" \
--paths src \
--collect-submodules python_lang_parser \
--collect-submodules python_lang_project_harness \
--collect-submodules asp_python \
py_harness_entry.py
mkdir -p package
cp -R "dist/${BINARY}/." package/
Expand Down
94 changes: 42 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
# python-lang-project-harness
# asp-python

`python-lang-project-harness` is a standalone Python project harness library for
`asp-python` is a standalone Python policy and semantic tooling library for
modern Python packages. It ships two library boundaries in one repo:

- `python_lang_parser`: Python-native AST, compiler, tokenize, symbol-table,
module-shape, public-surface, and symbol-role facts.
- `python_lang_project_harness`: project discovery, deterministic rule
- `asp_python`: project discovery, deterministic rule
packs, compact rendered diagnostics, and pytest-friendly assertions.

The harness is library-first. Callers pass a project root or explicit paths,
ASP Python is library-first. Callers pass a project root or explicit paths,
then decide whether to assert, render compact text, or inspect the structured
report. Compact text is the default agent repair surface; JSON is available for
tooling through `render_python_lang_harness_json()`.
tooling through `render_asp_python_report_json()`.

`python_lang_parser` is the semantic foundation. Harness policy consumes parser
`python_lang_parser` is the semantic foundation. ASP Python policy consumes parser
reports and parser-owned `pyproject.toml` metadata instead of re-parsing Python
source or guessing package scope in the rule layer; tests-root layout stays in
the harness.
ASP Python.

## Quick Use

```python
from pathlib import Path

from python_lang_project_harness import (
from asp_python import (
__version__,
PythonOwnerResponsibility,
PythonVerificationProfileHint,
PythonVerificationTaskKind,
assert_python_project_harness_clean,
default_python_harness_config,
assert_asp_python_clean,
default_asp_python_config,
plan_python_project_verification_with_config,
render_python_lang_harness,
render_asp_python_report,
render_python_reasoning_tree,
render_python_verification_plan,
run_python_project_harness,
run_asp_python,
)


def test_python_project_harness_policy() -> None:
assert_python_project_harness_clean(Path("."))
def test_asp_python_policy() -> None:
assert_asp_python_clean(Path("."))


report = run_python_project_harness(Path("."))
report = run_asp_python(Path("."))
print(__version__)
print(render_python_lang_harness(report))
print(render_asp_python_report(report))
print(render_python_reasoning_tree(report))
```

The project runner scans the whole Python project root by default, excluding
tool/cache/build directories such as `.venv`, `__pycache__`, `build`, and
`dist`. Conventional source and test roots still classify project policy, but
they do not narrow parser coverage. The explicit path runner,
`run_python_lang_harness([...])`, is useful for focused parser and syntax
`run_asp_python_paths([...])`, is useful for focused parser and syntax
checks.
Use `PythonHarnessConfig` to change source-root classification, test-root
Use `AspPythonConfig` to change source-root classification, test-root
classification, extra external project paths, test inclusion, or blocking
severities without hardcoding project-specific policy into the library.
Project runners also read `[tool.python-lang-project-harness]` from
`pyproject.toml` when no explicit `PythonHarnessConfig` is passed, including
Project runners also read `[tool.asp-python]` from
`pyproject.toml` when no explicit `AspPythonConfig` is passed, including
`disabled_rule_ids` and `blocking_rule_ids` for stable rule-id policy.
Standard `[project]` metadata such as `name`, `requires-python`,
`import-names`, scripts, and pytest entry points is parsed by
`python_lang_parser` and appears in project policy and reasoning-tree facts.
When `include_tests=False`, test files are not parsed, but tests-root layout
policy still runs. Explained local exceptions can live in
`tests/python-project-harness-rules.toml`.
`tests/asp-python-rules.toml`.

For agent repair loops, `render_python_reasoning_tree(report)` emits a compact
package/module owner tree from parser-owned facts. It shows package branches,
Expand All @@ -75,42 +75,32 @@ shadows without forcing an LLM to consume the full JSON report first. In
project-scoped runs, tree paths are rendered relative to the project root to
avoid repeating long absolute prefixes.

`render_python_project_harness_agent_snapshot(".")` and the
`--agent-snapshot` CLI mode bundle compact policy findings, reasoning-tree
facts, verification-profile reminders, and active verification tasks into one
low-noise Agent repair surface. The snapshot uses capped module summaries,
branches, public owners, import edges, and branch-first profile candidates; it
does not print clean-run file counts or empty section summaries.
`render_asp_python_agent_snapshot(".")` bundles compact policy
findings, reasoning-tree facts, verification-profile reminders, and active
verification tasks into one low-noise library response. The snapshot uses
capped module summaries, branches, public owners, import edges, and
branch-first profile candidates.

The semantic-language console script exposes search, registry, and check
surfaces aligned with the Rust and TypeScript harnesses:
The provider console script exposes Query and registry surfaces. Public source
discovery is owned by the Runtime Search Playbook. Policy remains a dependency
API consumed by pytest/build ownership:

```shell
asp-python search workspace .
asp-python search prime .
asp-python search lexical PythonHarnessReport owner tests .
asp-python search lexical --query-set PythonHarnessReport --query-set PythonSemanticSearchOptions owner tests .
asp-python search public-external-types pytest .
asp-python search callsite PythonHarnessReport .
asp-python search deps pytest .
asp search playbook --language python --rg -n -e AspPythonReport . --tantivy 'title:AspPythonReport^2 OR body:AspPythonReport'
asp query playbook --language python --selector '<python-selector>' --projection source --workspace .
asp-python agent doctor --json .
asp-python agent guide .
asp-python check --full .
asp-python .
asp-python --json .
asp-python --agent-snapshot .
asp-python --source-dir lib --extra-path tools --no-tests .
python -m python_lang_project_harness .
python -c 'from asp_python import assert_asp_python_clean; assert_asp_python_clean(".")'
```

## Verification Planning

Verification is a library-first Agent contract. The harness does not execute
Verification is a library-first Agent contract. ASP Python does not execute
benchmark, security, stress, or chaos tools. It plans parser-backed obligations
that external skills can satisfy with receipts or complete waivers:

```python
config = default_python_harness_config().with_verification_profile_hint(
config = default_asp_python_config().with_verification_profile_hint(
PythonVerificationProfileHint(
"src/pkg/api.py",
(PythonOwnerResponsibility.PUBLIC_API,),
Expand All @@ -124,7 +114,7 @@ print(render_python_verification_plan(plan))

Profile hints, dependency signals, receipts, waivers, task-kind mappings, and
skill bindings are configurable through `PythonVerificationPolicy` or
`[tool.python-lang-project-harness.verification]`. Parser facts win over config
`[tool.asp-python.verification]`. Parser facts win over config
hints; mismatches become `responsibility_review` tasks instead of silent trust.
`build_python_verification_profile_index(...)` exposes `active_profile_hints()`
so Agents can turn parser-suggested owners into config-ready verification
Expand All @@ -139,29 +129,29 @@ responsibilities.

## Pytest Dev Dependency

Downstream projects can load the harness through their test/dev dependency
Downstream projects can load ASP Python through their test/dev dependency
group:

```toml
[dependency-groups]
test = [
"pytest>=8",
"python-lang-project-harness[pytest]>=0.1.0",
"asp-python[pytest]>=0.1.0",
]

[tool.pytest.ini_options]
addopts = ["--python-project-harness"]
addopts = ["--asp-python"]
```

The pytest plugin is exposed through the package `pytest11` entry point. It is
loaded by pytest when the dev dependency is installed, but it only runs the
harness when `--python-project-harness` is enabled. Projects that prefer an
ASP Python policy gate when `--asp-python` is enabled. Projects that prefer an
explicit test file can use the public helper:

```python
from python_lang_project_harness.pytest import python_project_harness_test
from asp_python.pytest import asp_python_test

test_python_project_harness_policy = python_project_harness_test()
test_asp_python_policy = asp_python_test()
```

## Rule Packs
Expand Down Expand Up @@ -195,4 +185,4 @@ Detailed package material lives under [`docs/`](docs/index.md).

GitHub Actions runs the package contract on every pull request and on pushes to
the default branch: `uv sync --group test --locked`, ruff format/check, pytest,
self-harness, agent snapshot, wheel/sdist build, and diff hygiene.
ASP Python self-check, agent snapshot, wheel/sdist build, and diff hygiene.
39 changes: 20 additions & 19 deletions development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@
## Format, Test, Lint

```shell
direnv exec . uv run --group test ruff format --check src tests
direnv exec . uv run --group test ruff check src tests
direnv exec . uv run --group test pytest tests -q
direnv exec . uv run --group test python-project-harness .
direnv exec . uv run --group test python-project-harness --agent-snapshot .
direnv exec . uv build
direnv exec . git diff --check
.devenv/devenv-profile-exec uv run --project languages/asp-python --group test ruff format --check languages/asp-python/src languages/asp-python/tests
.devenv/devenv-profile-exec uv run --project languages/asp-python --group test ruff check languages/asp-python/src languages/asp-python/tests
.devenv/devenv-profile-exec uv run --project languages/asp-python --group test pytest languages/asp-python/tests -q
.devenv/devenv-profile-exec uv run --project languages/asp-python --group test asp-python languages/asp-python
.devenv/devenv-profile-exec uv run --project languages/asp-python --group test asp-python --agent-snapshot languages/asp-python
.devenv/devenv-profile-exec uv build languages/asp-python
.devenv/devenv-profile-exec git diff --check
```

Use `direnv exec .` so the devenv-managed Python and `uv` environment are used
consistently.
Use `.devenv/devenv-profile-exec` from the repository root so the captured
devenv-managed Python and `uv` environment are used consistently.

GitHub Actions runs the same validation surface without `direnv`: `uv sync
--group test --locked`, ruff format/check, pytest, self-harness, package build,
--group test --locked`, ruff format/check, pytest, ASP Python self-check, package build,
agent snapshot, and `git diff --check`.

## Library Boundary

This repo is a standalone Python library project. It ships:

- `python_lang_parser` for Python-native parser facts
- `python_lang_project_harness` for discovery, rule packs, rendering,
- `asp_python` for discovery, rule packs, rendering,
and pytest embedding

Keep these boundaries separate. Parser modules should not know about project
policy, pytest, or agent repair wording. Harness modules should consume parser
policy, pytest, or agent repair wording. ASP Python modules should consume parser
reports and emit deterministic findings.

## Self-Applied Policy

`tests/unit/test_self_hosting.py` mounts the project harness against this repo.
`tests/unit/test_self_hosting.py` mounts the ASP Python against this repo.
When adding tests, keep behavior coverage under `tests/unit` and avoid
scattered `tests/test_*.py` files at the test root.

Default assertions block on `Warning` and `Error`. `PY-AGENT-*` rules stay
`Info`: rendered by default as repair advice, but non-blocking unless a caller
opts into stricter severity selection.

The CLI is part of that same contract. Keep `python-project-harness` as a thin
The CLI is part of that same contract. Keep `asp-python` as a thin
adapter over the library runner and renderers.

## Renderer Contract

Compact text is the primary agent-facing repair surface. It should remain small:
rule id, location, optional source line, pointer label, and one `Required:`
contract line. Use `render_python_lang_harness_json()` for tooling that needs
contract line. Use `render_asp_python_report_json()` for tooling that needs
the full structured payload.

## Snapshot Workflow
Expand All @@ -57,10 +57,11 @@ Rendered output and policy diagnostics are locked under `tests/unit/snapshots`.
Normal tests compare snapshots only. Refresh them intentionally:

```shell
PYTHON_HARNESS_UPDATE_SNAPSHOTS=1 direnv exec . uv run --group test pytest \
tests/unit/harness/test_render_snapshots.py \
tests/unit/harness/test_agent_policy_snapshots.py \
tests/unit/harness/test_policy_snapshots.py -q
.devenv/devenv-profile-exec env ASP_PYTHON_UPDATE_SNAPSHOTS=1 \
uv run --project languages/asp-python --group test pytest \
languages/asp-python/tests/unit/asp_python/test_render_snapshots.py \
languages/asp-python/tests/unit/asp_python/test_agent_policy_snapshots.py \
languages/asp-python/tests/unit/asp_python/test_policy_snapshots.py -q
```

Review the resulting `.snap` diff before keeping it. Snapshot changes are
Expand Down
Loading
Loading