Skip to main content

How AI Is Used in the CGP Project

AI agents do much of the work on Context-Generic Programming (CGP), a Rust library for writing several implementations of a trait and choosing which one each type uses. They write most of its documentation and most of its error toolchain, maintain much of its test suite, and help implement parts of the library. The author designs every CGP construct and interface, and writes the core library almost entirely by hand. To explain why their roles differ, this page goes through each part of the project, from the most agent-written to the least, describing who works on it, how that work is checked, and what those checks can miss.

Why the levels differ​

How much agents write depends partly on whether their work becomes part of your compiled program. Library code does, so you have to trust it. Documentation, tools, and tests stay outside that program: a tool runs on your project, and a test exercises the library.

It also matters whether the work can be checked against something that already exists. A claim about a macro can be checked against the macro's source and expansion snapshots, and a tool's output against its test fixtures. Design, however, decides what the library should do in the first place. There is no existing implementation to check that decision against, and passing tests cannot settle it.

Agents therefore do the most writing where the result stays out of your program and can be checked, and the least in the core library, whose design sets the behavior everything else must follow. These criteria decide who writes each part, but they do not make any part correct.

Documentation and reference pages​

AI agents write most of CGP's reference pages, explanations, guides, and error documentation using the CGP knowledge base. This public repository, also written by agents, records how CGP works and the rules agents must follow. The pages on this site adapt that record for people.

The source code is authoritative. Agents must check claims about accepted syntax, generated names, and macro expansions against the code, the tests, or the expansion snapshots, and when a document disagrees with the code, the document is corrected. A change to how CGP behaves must update its documentation in the same change.

Some of these checks are mechanical: expansion snapshots fail when a macro's output changes, and the code shown on a page is compiled in a test crate when the page is written or revised. Agreement between prose and code depends on agents following the rules and on review, both of which can miss a stale sentence. As a result, some documents still contain errors that no review has found yet, and the pages written from them share those errors.

The author directs this work by designing CGP, writing the rules agents follow, and choosing what gets documented. Those rules tell an agent to ask rather than guess when a choice has more than one reasonable answer. To make the agent's contribution visible, each commit it contributes to carries a Co-Authored-By trailer naming the model. That record shows who contributed, not that every statement is correct. How CGP's Documentation Is Written gives the full account of the process.

Human review varies by page. The author reads these pages in full before publication: the front page, the Concepts explanation pages, the reference index, this page, the page describing how the documentation is written, and every blog post. On each Comparisons page, which describes another community's tool beside CGP, the author reads in full the sections that judge that tool: what each approach costs, and where the other tool is the better choice. Every other page, including the individual construct reference pages and the rest of each comparison page, follows a writing guide and receives spot checks, without the author reading each one line by line.

Source checks and human review catch different mistakes. Checking an expansion against the source can reveal a technical error, while reading an explanation can reveal a misleading argument. Neither catches every error, and the project remains responsible for correcting the ones that get through.

Blog posts and tutorials​

The author drafts blog posts and tutorials, supplying their argument, their examples, and the judgment about what to teach. An agent then revises the prose and checks the code and claims against the knowledge base. This differs from reference pages, where an agent writes the first draft. Although the revision improves the prose and checks the code, it does not make the argument correct.

Older text on this site went through broader LLM refinement, as the post about this website describes. This section describes the current process for blog posts and tutorials.

Tooling and tests​

Agents write most of cargo-cgp, CGP's error toolchain, and maintain much of CGP's test suite. Neither becomes part of your compiled program: cargo-cgp runs on your project, and the tests exercise the library. Their results can also be checked against existing evidence: cargo-cgp's output against its test fixtures, and the tests against the library's behavior.

Agents also extend the tests across the many syntax forms the procedural macros accept. That work is broad and repetitive, and agents make coverage practical beyond what the author could maintain alone. Passing tests are evidence only for the cases they cover, though, and a wrong expectation or a missing case can still let a bug through.

cargo-cgp is an early release and can contain bugs. cargo cgp check leads with the root cause for the classes it recognizes, and the tool does not yet reshape every class.

The CGP library​

The author designs every CGP construct and interface, and writes the core library almost entirely by hand. This is the code your application imports and compiles, so the author takes direct responsibility for its design and implementation.

Agents help with correctness checks, code-quality review, and the implementation of the procedural macros, and the author directs and reviews that work. The cgp repository records that work with Co-Authored-By trailers, including for contributions to the macros. The author decides what CGP provides and how its interfaces fit together, while agents help implement and check some of those decisions. The library does contain AI contributions, and its checks cannot guarantee that every implementation is correct.

Contributions from others​

Contributions from outside the project follow a deliberately light policy, with a more detailed one to follow. For now, AI-assisted contributions must meet these requirements:

  • Use the knowledge base for contributions to any CGP repository, so the agent works from the current syntax and updates the documentation its change affects.
  • Include the prompts used to verify the issue or apply the fix in any AI-assisted pull request or issue. CGP maintainers may run similar prompts themselves rather than merge a pull request directly.

Contributing to CGP with an Agent gives the policy in full.

Finding a problem in the knowledge base is a useful contribution in its own right, because the checks can miss one. File it on the knowledge base's issue tracker.

Responsibility​

The project is responsible for everything published under CGP's name, including errors in agent-written work. As CGP's author, I would rather you told me about an error than worked around it. Report a problem in the knowledge base on its issue tracker, and any other error in GitHub Discussions or on the repository it concerns.

How pages are marked​

A new or substantially rewritten page carries a short note at the bottom, linking to the section of this page that describes how it was made. The front page is the one exception and carries no note. An older page gets a note only once its provenance has been established, so a page without one may still have been written with AI assistance.


An AI agent wrote and revised this page using the CGP knowledge base. See Documentation and reference pages.