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
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ The repository enforces a clean root structure (maximum 9 files) with well-defin
3. **Core Engine**: Pure deterministic logic lives in [src/evaluator-core.ts](src/evaluator-core.ts) and [src/evidence/](src/evidence).
4. **Adapter & Security**: GitHub integration logic lives in [src/github/](src/github) and follows [docs/threat-model.md](docs/threat-model.md).
5. **Validation**: Run `npm run verify` before completing any change.
6. **Agent verification**: Follow [docs/agent-verification-map.md](docs/agent-verification-map.md) for surface ownership, verification ladders, PR invariants, bounded parallel work, and evidence labels.
7. **Agent evaluations**: Use [docs/agent-evaluation-protocol.md](docs/agent-evaluation-protocol.md) when measuring or scaling agent-assisted work; scores and agent summaries never replace parent verification.

## Current project status

Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,38 @@ The four related repositories and the shared evidence rules are recorded in
The shortest path to a user result is [one non-blocking first-use check](docs/first-use.md).
The workspace tracks this alongside the [continuous adoption loop](docs/adoption-loop.md).

## Try one real pull request in five minutes

Add this temporary workflow to a test repository, open or update one pull
request, and read the non-blocking PatchGate check. It does not change merge
eligibility.

```yaml
name: PatchGate shadow check

on:
pull_request_target:
types: [opened, synchronize, reopened]

permissions:
contents: read
pull-requests: read
checks: read

jobs:
patchgate:
runs-on: ubuntu-latest
steps:
- uses: daichunghy/patchgate@34d998bbd59fa09dd9081e24f22abe812f97fbab
with:
fail-on: never
create-check-run: true
```

Remove the workflow after the trial, or follow the [shadow installation
runbook](docs/pilots/g4-shadow-installation-runbook.md) before requesting any
broader use.

## Try it locally

The fastest first-run path is a direct GitHub install on Node 20+ — `npx`
Expand Down Expand Up @@ -243,10 +275,13 @@ The repository maintains a clean root directory structure (9 files max) with mod
- [Redacted support bundle](docs/support-bundle.md)
- [Project-wide review and next-build checkpoint](docs/reviews/2026-08-13-project-wide-review.md)
- [Current G4/G0 continuation audit](docs/reviews/2026-08-20-g4-g0-audit.md)
- [Agent verification foundation](docs/reviews/2026-08-27-agent-verification-foundation.md)
- [Implementation roadmap](docs/implementation-roadmap.md)
- [User requirements](docs/product/user-requirements.md)
- [User-needs and roadmap research](docs/research/2026-08-13-patchgate-user-needs-roadmap-review.md)
- [Detailed execution plan for agents](docs/agent-execution-plan.md)
- [Agent verification map](docs/agent-verification-map.md)
- [Agent evaluation protocol](docs/agent-evaluation-protocol.md)
- [Machine-readable agent work packages](docs/agent-work-packages.yml)
- [Prompt 1 implementation review](docs/reviews/2026-08-13-prompt-01-review.md)
- [Prompt 2 implementation report](docs/reviews/2026-08-13-prompt-02-implementation.md)
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ outputs:
description: 'SHA-256 canonical digest of the final evaluation receipt.'
summary-markdown:
description: 'Human-readable markdown summary of the evaluation findings.'
target-kind:
description: 'Evaluation target kind (head, merge, or merge_group).'
tested-sha:
description: 'Exact commit SHA evaluated and used as the Check Run head_sha.'
head-sha:
description: 'Exact pull-request head SHA recorded in the evaluation.'

runs:
using: 'node24'
Expand Down
2 changes: 1 addition & 1 deletion dist/action/index.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### First-use probe and live-smoke entrypoint — 2026-08-27
- Added a read-only first-use probe that distinguishes a valid trusted local
policy from a missing `patchgate.yml` without treating discovery guidance as
enforcement.
- Fixed direct live-smoke harness execution when the checkout path contains
spaces and added fail-closed no-token/no-authorization regression coverage.
- These changes remain local/unreleased; they do not establish live GitHub
integration, external pilot evidence, or production enforcement.

### Exact PR-head binding and tested-SHA visibility — 2026-08-27
- The Action now binds its live API snapshot to the workflow event's exact
`pull_request.head.sha`; a changed live head is rejected with
`GITHUB_TARGET_CHANGED` before evaluation.
- Check Run and step-summary output now shows full `testedSha`, `headSha`,
`baseSha`, target kind, and the head-binding state. Action outputs also expose
`target-kind`, `tested-sha`, and `head-sha` for downstream integrations.
- The consumer guide documents why the check name remains stable and why a
pull-request comment from a QA tool is not automatically verified evidence.

### evaluate --output alias with fail-closed conflicts — 2026-08-23
- `evaluate` accepts `--output` as an alias of `--report`, so the
file-writing flag is uniform across commands. Passing both with different
Expand Down
32 changes: 27 additions & 5 deletions docs/adoption-loop.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# User adoption loop — 2026-08-24
# User adoption loop — 2026-08-28

The goal for this workspace is not to produce four busy repositories. It is to
get real people to a first useful result, learn where the workflow fails, and
Expand All @@ -13,10 +13,10 @@ maintenance or discoverability signals, but they do not establish adoption.

| Project | First useful result | Current blocker | Next evidence |
| --- | --- | --- | --- |
| [PatchGate](https://github.com/daichunghy/patchgate) | A maintainer installs the Action in non-blocking shadow mode and receives a useful check | Unpublished CLI, token/permission boundary, and no outside shadow install | One consented shadow run in a repository outside `daichunghy/*` |
| [contribkit](https://github.com/daichunghy/contribkit) | An agent or human runs preflight on a real local change before opening a PR | Package/plugin discoverability and no outside consumer walkthrough | One outside repository completes `preflight` and reports the decision |
| [OpenSheet-AI](https://github.com/daichunghy/opensheet-ai) | A typed intent becomes a validated plan, dry-run receipt, and new `.xlsx` file | The boundary is deliberately local/greenfield; no real operator workflow is verified | One researcher or operator completes a real spreadsheet task |
| [quant-research](https://github.com/daichunghy/quant-research) | A declared instrument produces a codebook, recode output, coverage result, and analysis syntax | No real study workflow has been observed outside the maintainer workspace | One researcher uses an output in a real study and reports what was missing |
| [PatchGate](https://github.com/daichunghy/patchgate) | A maintainer adds the pinned shadow workflow, opens one PR, and receives a useful non-blocking check | PR #59 is public and CI-green, but it is not merged and no outside shadow consent exists | One consented shadow run in a repository outside `daichunghy/*` |
| [contribkit](https://github.com/daichunghy/contribkit) | An agent or human runs package-first `preflight` on a real local change before opening a PR | PR #33 is public and CI-green; npm alpha.7 still needs owner authentication/publication | One outside repository completes `preflight` and reports the decision |
| [OpenSheet-AI](https://github.com/daichunghy/opensheet-ai) | A typed intent previews to a receipt, then writes a new `.xlsx` file | PR #17 is public and CI-green; npm alpha.5 still needs owner authentication/publication | One researcher or operator completes a real spreadsheet task |
| [quant-research](https://github.com/daichunghy/quant-research) | A packaged workflow emits codebook, recode, coverage, measurement and syntax artifacts | PR #19 is public and CI-green; alpha.6 is prepared but npm publication is blocked by auth | One researcher uses an output in a real study and reports what was missing |

## Evidence to record

Expand All @@ -34,6 +34,28 @@ Every first-use report should record:
The evidence record must distinguish `worked`, `worked_with_workaround`, and
`did_not_reach_first_result`. Do not collapse a workaround into a success.

## Fast-conversion sequence

Use one measurable action per stage. Do not count a page view, star, download,
self-authored issue, or CI run as adoption.

1. **Activation, under five minutes:** the documented package or Action command
runs and produces the stated receipt, check, preview, workbook, or workflow
bundle. Record command, version, elapsed time, and first confusion.
2. **Useful result:** the person can answer the product question without opening
internal source files. The README CTA must point directly to this result.
3. **Feedback conversion:** offer one short issue form immediately after the
result. Ask what they expected, what blocked them, and whether they would
repeat the workflow. Never request private data or a positive quote.
4. **Pilot conversion:** request explicit consent, an exact target repository
and PR, least-privilege permissions, and a rollback path. For PatchGate,
keep the first run shadow-only and non-blocking.

The operating target is not a viral number. It is a shorter path from a public
entry point to a verifiable first result, followed by a consented outside
workflow. If activation is successful but feedback conversion is weak, improve
the result and the form before adding features.

## Working cadence

1. Check live GitHub and package signals before writing the weekly status.
Expand Down
120 changes: 120 additions & 0 deletions docs/agent-evaluation-protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# PatchGate Agent Evaluation Protocol

**Status:** local protocol for bounded agent work
**Purpose:** measure whether agent workflows produce safe, reviewable and
reversible PatchGate changes

This protocol evaluates the workflow, not the intelligence of a model. It is
not a claim that an agent can replace maintainer judgment, security review or
the constitutional human boundary.

## Evaluation unit

One evaluation is one bounded task in a fresh worktree with:

- a written objective and explicit file scope;
- a known acceptance command or test set;
- a time and token budget chosen before execution;
- no access to unrelated worktrees or private credentials;
- a final diff, test output and evidence-level classification.

Tasks should be atomic. A task that needs unrelated policy, adapter, Action
and release changes must be split into separate evaluations.

## Initial task corpus

Start with these tasks because they cover the main PatchGate boundaries:

| ID | Task family | Example acceptance | Human review |
| --- | --- | --- | --- |
| AG-01 | Schema/contract | invalid input is rejected and valid fixture replays | contract owner |
| AG-02 | Deterministic evaluator | status, reason IDs and digest remain stable | evaluator owner |
| AG-03 | Evidence binding | stale, foreign or duplicate evidence cannot satisfy a rule | security owner |
| AG-04 | CLI onboarding | first-use path gives actionable text and JSON output | UX/maintainer |
| AG-05 | GitHub adapter | snapshot is bounded, redacted and bound to the selected SHA | adapter owner |
| AG-06 | Action boundary | outputs and Check Run use exact tested/head SHA values | Action owner |
| AG-07 | Workflow safety | privileged workflow does not execute pull-request code | security owner |
| AG-08 | Fixture expansion | a real edge case gains a manifest entry and regression test | test owner |
| AG-09 | Documentation | supported behavior and limitation are stated without overclaiming | maintainer |
| AG-10 | Release surface | source, bundle, docs and release checks remain synchronized | release owner |

The corpus should grow from real review findings, rejected changes, user
walkthroughs and pilot edge cases. Do not manufacture task volume or public
activity to improve the score.

The machine-readable seed corpus is
[`fixtures/agent-evals/manifest.json`](../fixtures/agent-evals/manifest.json).
Its task IDs and acceptance commands are checked by `check:agent-contract`.

## Scoring rubric

Score each dimension from 0 to 2:

| Dimension | 0 | 1 | 2 |
| --- | --- | --- | --- |
| Functional correctness | fails acceptance | partial or needs rescue | passes targeted acceptance |
| Contract fidelity | violates authority/schema | preserves behavior with a gap | preserves authority, schema and status contract |
| Security | unsafe boundary or unknown impact | safe but incomplete evidence | threat case is tested and fail-closed |
| Scope discipline | unrelated or hard-to-revert changes | minor scope drift | atomic, explainable and reversible |
| Verification quality | claims without proof | runs some checks | provides reproducible checks and artifacts |
| Maintainability | adds ambiguity or duplication | usable but awkward | follows the shortest safe repository path |

Maximum score is 12. A task is eligible for the next wave only when:

- it scores at least 10/12;
- Functional correctness, Contract fidelity and Security are each 2;
- no P0/P1 issue remains unresolved;
- the parent maintainer independently verifies the result.

Scores are a workflow signal, not a release or adoption metric.

## Evaluation procedure

1. Select a task from the corpus and define its risk owner.
2. Create a fresh worktree from the intended base revision.
3. Give the agent only the task, repository guidance and allowed commands.
4. Observe whether it inspects the relevant source, schema and tests before
editing.
5. Run targeted checks without changing the task scope.
6. Inspect the diff for authority, security, scope and generated-artifact
issues.
7. Run `npm run verify` after the task is integrated into the parent tree.
8. Score the task and record failures as candidate fixtures or guardrails.

The local command `npm run agent-eval -- AG-01` runs the allowlisted acceptance
commands from the machine-readable manifest for one task. It does not inspect
or approve the diff; parent review remains mandatory.

For comparative model runs, use the same task, base revision, budget and
acceptance rubric. Do not treat a judge-agent score as a substitute for
deterministic tests or human review.

## Wave policy

| Wave | Scope | Quantity | Promotion condition |
| --- | --- | ---: | --- |
| A | docs, tests, fixtures and low-risk CLI | 5 tasks | all parent gates pass; no security regression |
| B | contract and evaluator behavior | 10 tasks | 90% first-pass targeted acceptance; all contract/security dimensions score 2 |
| C | GitHub adapter, Action and workflow boundaries | 10 tasks | serial human review; zero false green; full verify after each integration |
| D | external shadow/pilot feedback | as available | consented evidence and documented remediation |

The quantities are sampling waves, not a promise to create artificial PRs.
Increase concurrency only when review time, failure rate and rollback burden
are improving rather than merely when agent output is increasing.

## Required evidence record

```text
Evaluation ID:
Base revision:
Task and allowed paths:
Agent/model configuration:
Targeted commands and results:
Parent verification command and result:
Rubric score:
Failures converted to tests/guardrails:
Evidence level:
```

Keep local evaluation, native GitHub runtime, shadow installation, pilot,
release and adoption evidence in separate records.
19 changes: 19 additions & 0 deletions docs/agent-execution-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ merge-blocking từ các bằng chứng trên. `human_review_required` vẫn ch
thái cho biết human gate được khai báo nhưng chưa thỏa, không phải bằng chứng
con người đã review.

## Agent-scaling checkpoint — 2026-08-27

Phần local của quy trình agent đã được đưa vào repository contract:

- [agent verification map](agent-verification-map.md) quy định authority order,
path ownership, verification ladder, PR invariants và bounded parallel work;
- [agent evaluation protocol](agent-evaluation-protocol.md) quy định task
corpus, rubric, wave promotion và evidence record;
- `fixtures/agent-evals/manifest.json` chứa mười task `AG-01` đến `AG-10`;
- `npm run agent-eval -- <task-id>` chạy acceptance commands allowlisted;
- `check:agent-contract` nằm trong `npm run verify`.

Wave A baseline đã chạy trên current tree với `AG-01`, `AG-04`, `AG-08` và
`AG-09`. Kết quả này chỉ là local workflow evidence. Không được dùng nó để
claim agent authorship quality, external pull request, pilot, release hoặc
auto-merge. Các task `AG-02`, `AG-03`, `AG-05`, `AG-06`, `AG-07` và `AG-10`
phải tiếp tục qua parent verification do chạm evaluator, evidence, GitHub,
Action, security hoặc release boundary.

## 1. Kết luận điều hành

PatchGate nên tiếp tục theo định vị hiện tại: một **review-readiness gate có
Expand Down
Loading