Skip to content
Closed
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
15 changes: 10 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ Resolve scope questions from the changed code and the invariants first. Ask only
if a material security decision remains unclear; identify the decision rather
than stopping on general uncertainty. Ask before running a recommended security review.

Follow `docs/developer/AI_POLICY.md` for contributions and `SECURITY.md` for
private vulnerability reporting. Local edits, checks, and atomic commits are
allowed; do not automatically push, open pull requests, write replies, contact
maintainers, or claim authorship. A human publishes contributions. Never commit
to master or push to an open pull request branch without explicit user direction.
Before acting on a pull request, read `CONTRIBUTING.md` and
`docs/developer/AI_POLICY.md` from its current target branch. Follow that merged
contribution policy when the topic branch contains an older version. AI may
write PR descriptions and review replies under the tool-neutral policy.

Follow `SECURITY.md` for private vulnerability reporting. Local edits, checks,
and atomic commits are allowed. Publish only within the user's authorized scope;
permission to use AI does not itself authorize contacting others. Never claim
independent human authorship, commit to master, or push to an open pull request
branch without explicit user direction.

When asked to commit, keep commits focused and independently passing unless the
user explicitly requests a combined commit. Use an imperative subject of at
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Getting Started
New contributors are very welcome and needed.

If you use AI tools while contributing, please read and follow the [AI
policy](/doc/AI_POLICY.md).
policy](docs/developer/AI_POLICY.md).

In-depth reviewing and testing are the bottleneck of the project, and are the
most effective way anyone can start to contribute. It will teach you much more
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include LICENSE README.md SECURITY.md
recursive-include LICENSES *
recursive-include docs *.csv *.html *.json *.md
recursive-include docs *.html *.md
prune docs/planning
recursive-include requirements *.txt
recursive-include tests *.py *.json *.md
Expand Down
68 changes: 32 additions & 36 deletions docs/developer/AI_POLICY.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
# AI Policy

Using AI (i.e. LLMs) as tools for coding is welcome, provided that such use adheres to the following policy, adds value, and does not waste the community's time.

A high bar is held for all contributions to this project.

**AI should not be used to generate comments when communicating with maintainers and other contributors**.
Comments are expected to be written by humans.
Comments that are believed to be written by AI may be moderated.

If you are opening an issue, you should be able to describe the problem in your own words.

You should only open a pull request if you:

- know the language the code is written in
- could have written the code yourself
- understand the existing surrounding code and the effect of the suggested changes

You must also be able to explain the pull request changes in your own words.
This includes the pull request body and responses to questions.
**Do not copy responses from the AI when replying to questions from reviewers.**

This project requires a human author in the loop who understands the work produced by AI.
**Pull requests should not be opened or driven by autonomous agents**.
A human author must choose the work, understand the change, and be responsible for the contribution.
Do not include agents as authors or co-authors of your commits for these reasons.
Pull requests that appear in violation of this can be closed without notice.

If you wish to include context from an interaction with AI in your comments, it must be disclosed as such.
It must be accompanied by human commentary explaining the relevance and implications of the context.

Questions or proposed changes to this policy can be discussed in [bitcoin-core/meta].

This policy was adapted from [ripgrep's AI policy], which was adapted from [uv's AI policy].

[bitcoin-core/meta]: https://github.com/bitcoin-core/meta
[ripgrep's ai policy]: https://github.com/BurntSushi/ripgrep/blob/f0cec341ab95c25c691ad3d5754d4bd9eedde21f/AI_POLICY.md
[uv's ai policy]: https://github.com/astral-sh/.github/blob/c5187e200db51bfe11d56e13053d29bd3793fdd8/AI_POLICY.md
Use whatever tools help you, AI included. This project has no rules about
which tools you may use for what.

The expectations are the same for every contribution, however it was made:

- Do your best.
- If you open an issue, you should be able to describe the problem in your
own words.
- If you open a pull request, you must be able to explain the changes in your
own words when asked.
- A human author must choose the work, understand the change, and be
responsible for the contribution. Understanding means knowing what the
change does, why, and what it affects well enough to defend it in review,
not memorizing every implementation detail. If you can't defend it, don't
submit it.
- Do not include agents as authors or co-authors of your commits.
- Respect reviewers' time. Review is the bottleneck. Unverified or low-effort
issues, pull requests and comments may be closed without detailed review.

Saying which tools you used, and how, is welcome when it helps review. It is
not required.

Changes to share generation, recovery or checksums get a security review
however they were written.

Questions or proposed changes to this policy can be raised in an issue.

This policy follows Linus Torvalds' [reply to Laurent Pinchart] on 13 October
2026 and the Linux kernel's [tool-generated content guidelines].

[reply to Laurent Pinchart]: https://www.theregister.com/ai-and-ml/2026/10/14/linux-kernel-devs-drop-obligatory-confession-of-ai-tool-usage/5303140
[tool-generated content guidelines]: https://docs.kernel.org/process/generated-content.html
57 changes: 22 additions & 35 deletions docs/developer/alignment-benchmarks.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
# Alignment correction benchmark evidence

Measured 2026-09-10 with one shared **inclusive capture-mass ceiling `<=1`**.

Host: **AMD Ryzen 7 7735U with Radeon Graphics**, Python **3.13.12**, `Linux-7.0.10+deb14-amd64-x86_64-with-glibc2.42`.
Informational only: these timings help set correction limits on slower devices. They are not timing guarantees.

## Execution conditions and limits

The host rebooted repeatedly during this task. Accessible user journals did not establish the cause; kernel journals and persistent crash records required administrator access. Remaining cases resumed under first a 50%, then a 25% single-core CPU quota, 1 GiB memory limit, low priority and pauses between cases. The final run also waits for a CPU sensor reading at or below 75°C before each case, stopping if cooling takes over one minute. Capped rows are marked and excluded from promotion evidence. These precautions are not a diagnosed hardware fix. **No public timing guarantee is promoted from this interrupted, mixed-condition run.**
Measured 2026-09-10 with one shared **inclusive capture-mass ceiling `<=1`**.

Only complete JSON records were preserved across restarts. Cached syndrome tables persist within each process; restarted processes rebuild them. Timed calls retain the ten-second deadline. Cooldown pauses occur outside the timed call.
Host: **AMD Ryzen 7 7735U with Radeon Graphics**, Python **3.13.12**, `Linux-7.0.10+deb14-amd64-x86_64-with-glibc2.42`. Cached syndrome tables persist within each process. Timed calls retain the ten-second deadline.

## Public required-depth measurements

All 1156 cases requested `A<=2` and `G<=2`: 1152 completed, 1156 returned no candidates, 284 were capped, and 872 uncapped cases completed without candidates below eight seconds. Maximum elapsed time was **10.001 seconds**; maximum admitted mass was **0.992777219241**.
All 1156 cases requested `A<=2` and `G<=2`: 1152 completed and none returned candidates. Maximum elapsed time was **10.001 seconds**; maximum admitted mass was **0.992777219241**.

The exhaustive sweep stopped after 1120 of 1980 planned cases because the temperature gate made it impractically slow. The additional 36 representative cases cover every existing public profile length, known/unknown targets, and frozen/unfrozen five-character headers at offset zero with no explicit erasures. The partial matrix additionally exercises offsets -8/-4/-3/-2/-1/0/1/2/3/4/8 and erasures 0/1/2/4/8. The tool retains the full matrix for a stable host. Inputs use valid header syntax and deterministic random remaining symbols. Some offsets have no reachable required layer. No-candidate status is recorded rather than assumed.
The exhaustive sweep stopped after 1120 of 1980 planned cases because it was impractically slow on this host. The additional 36 representative cases cover every existing public profile length, known/unknown targets, and frozen/unfrozen five-character headers at offset zero with no explicit erasures. The partial matrix additionally exercises offsets -8/-4/-3/-2/-1/0/1/2/3/4/8 and erasures 0/1/2/4/8. Inputs use valid header syntax and deterministic random remaining symbols. Some offsets have no reachable required layer. No-candidate status is recorded rather than assumed.

| Profile | Displayed D | Full body B | Mutable M (frozen / unfrozen) | Completed | Capped | Maximum seconds |
|---|---:|---:|---:|---:|---:|---:|
| ms | 48 | 45 | 40 / 45 | 224/224 | 4 | 2.288 |
| ms | 54 | 51 | 46 / 51 | 224/224 | 4 | 2.768 |
| ms | 61 | 58 | 53 / 58 | 224/224 | 4 | 3.860 |
| ms | 67 | 64 | 59 / 64 | 224/224 | 12 | 4.616 |
| ms | 74 | 71 | 66 / 71 | 224/224 | 224 | 6.005 |
| ms | 127 | 124 | 119 / 124 | 20/24 | 24 | 10.001 |
| cl | 74 | 71 | 66 / 71 | 4/4 | 4 | 5.589 |
| bip39_12w | 56 | 46 | 41 / 46 | 4/4 | 4 | 2.158 |
| bip39_24w | 82 | 72 | 67 / 72 | 4/4 | 4 | 5.821 |
| Profile | Displayed D | Full body B | Mutable M (frozen / unfrozen) | Completed | Maximum seconds |
|---|---:|---:|---:|---:|---:|
| ms | 48 | 45 | 40 / 45 | 224/224 | 2.288 |
| ms | 54 | 51 | 46 / 51 | 224/224 | 2.768 |
| ms | 61 | 58 | 53 / 58 | 224/224 | 3.860 |
| ms | 67 | 64 | 59 / 64 | 224/224 | 4.616 |
| ms | 74 | 71 | 66 / 71 | 224/224 | 6.005 |
| ms | 127 | 124 | 119 / 124 | 20/24 | 10.001 |
| cl | 74 | 71 | 66 / 71 | 4/4 | 5.589 |
| bip39_12w | 56 | 46 | 41 / 46 | 4/4 | 2.158 |
| bip39_24w | 82 | 72 | 67 / 72 | 4/4 | 5.821 |

The implementation requires `A<=2` / `G<=2` before surfacing suggestions. Required-phase interruption suppresses suggestions. Character depths 3/4 remain best effort. Runtime under a CPU quota must not be extrapolated into an uncapped guarantee.
The implementation requires `A<=2` / `G<=2` before surfacing suggestions. Required-phase interruption suppresses suggestions. Character depths 3/4 remain best effort.

## Deeper public search

0/16 depth-3/4 probes completed within the deadline at displayed ms lengths 48 and 127, with both target-knowledge and header-freezing states. No deeper cutoff is promoted. Under the CPU quota, long-profile probes may expire in the required phase before deeper work begins.
0/16 depth-3/4 probes completed within the deadline at displayed ms lengths 48 and 127, with both target-knowledge and header-freezing states. No deeper cutoff is promoted. Long-profile probes may expire in the required phase before deeper work begins.

## Coordinates and synthetic kernels

`B = D - len(hrp + "1")`; checksum selection uses `X = len(bech32_hrp_expand(hrp)) + B`. Mutable length excludes the frozen header, while reverse indices and the syndrome retain full-body coordinates. The CSV records all eligible target body lengths and the selected checksum size. Public profile validation is unchanged.
`B = D - len(hrp + "1")`; checksum selection uses `X = len(bech32_hrp_expand(hrp)) + B`. Mutable length excludes the frozen header, while reverse indices and the syndrome retain full-body coordinates. Public profile validation is unchanged.

Synthetic kernels use **body lengths** 40/66/93/127/1015/1023 with explicit short/long period selection. They need not form valid public application strings and never promote public cutoffs. Character depths 2/3/4 sample 32 hypotheses per structural class. Group depth 2 completes the structural-generation and incremental-syndrome sphere; this is distinct from complete BCH decoding of that sphere.

Expand All @@ -55,16 +51,15 @@ Synthetic kernels use **body lengths** 40/66/93/127/1015/1023 with explicit shor
| 1023 | yes | 356,746 | 5.020 |
| 1023 | no | 648,466 | 8.897 |

The JSON records generation/syndrome throughput, BCH throughput for E=0/1/2/4/8 and S=0..4 wherever E+2S<=8, root scans of degrees 1..4, sampled full-result dedup cost, retained allocation counts and traced peaks. BCH microcases exercise successful locators; public timings primarily exercise failed hypotheses. Allocations cover sampled batches, not a retained complete sphere.
The `--kernel` output records generation/syndrome throughput, BCH throughput for E=0/1/2/4/8 and S=0..4 wherever E+2S<=8, root scans of degrees 1..4, sampled full-result dedup cost, retained allocation counts and traced peaks. BCH microcases exercise successful locators; public timings primarily exercise failed hypotheses. Allocations cover sampled batches, not a retained complete sphere.

Separate public tracemalloc runs had a maximum peak of 116,160 bytes. Tracing results are neither timing evidence nor process RSS.

## Implementation and artifacts

Incremental syndromes compose small piece-table segments from shifted prefixes. Full candidate bodies materialize only after BCH survival. Repeated two-erasure product-table construction was removed after profiling identified it as a dominant cost; changing erasure locations use direct field multiplication. Constant locators avoid unnecessary root scans. Search follows admitted capture-volume layers. No MITM is used.

- [Public and deeper per-case results](alignment-public-benchmarks.csv).
- [Kernel, memory and measured runtime source hashes](alignment-kernel-benchmarks.json).
The raw kernel JSON from these runs is in git history at commit `753cf61`. Reproduce with:

```sh
.venv/bin/python -m tools.alignment_benchmark --public --depths 2
Expand All @@ -73,12 +68,4 @@ Incremental syndromes compose small piece-table segments from shifted prefixes.
.venv/bin/python -m tools.alignment_benchmark --public --lengths 48 --depths 2 --deltas 0 --erasures 0 --memory
```

Commands emit JSON Lines with a host header. Capped portions of these recorded runs used systemd `CPUQuota=50%` or `CPUQuota=25%` as recorded, `MemoryMax=1G`, `CPUWeight=10`, and `nice -n 10`; each case was followed by an untimed pause equal to its elapsed time, capped at ten seconds. These settings are execution precautions, not correction policy. Full 13/15 consecutive-erasure completion at mass exactly 1 is additionally covered by API tests.

## Validation

After failure cleanup, normal and optimized full pytest runs each pass **714 tests**. Both runs used a 25% single-core CPU quota, 1 GiB memory limit, cooling pauses, and the 75°C temperature gate. The CLI tests now observe prefills at the editable-input boundary and expect the current diagnostic text. The approved package size budget is **4,500** nonblank/noncomment lines, retaining recursive counting; the formatted package measures **4,088**.

Ruff lint and formatting, mypy (19 source files), all 57 frozen PR #70 correction cases, all 768 wallet differential records, and staged whitespace checks pass. No public timing cutoff is promoted by this validation.

The kernel artifact preserves the measured source hashes in `source_sha256` and records the subsequently formatted files in `post_cleanup_source_sha256`. The failure cleanup changed test expectations, formatting, and the approved package size budget; it did not change runtime semantics.
Commands emit JSON Lines with a host header. Full 13/15 consecutive-erasure completion at mass exactly 1 is additionally covered by API tests.
Loading
Loading