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
5 changes: 3 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Every toolchain the skill's evaluation fixtures need, so the evals run the same way
# on any machine and stay sandboxed in the container (see SECURITY.md).
# The JDK, Ruby, Python, and C toolchains, and the libraries Swift needs, for running agent
# sessions on projects in those languages, the same way on any machine and sandboxed in the
# container. Node and Rust come from devcontainer.json; Swift from post-create.sh.
# Base: the dev container project's Ubuntu image (non-root user "vscode").
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04

Expand Down
5 changes: 2 additions & 3 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env bash
# Runs once when the container is created. Installs what the Dockerfile does not:
# the Claude Code CLI (for running evals) and Swift (for swift-shop).
# the Claude Code CLI (for running agent sessions) and Swift.
set -euo pipefail
npm install -g @anthropic-ai/claude-code
if ! command -v swift > /dev/null; then
curl -fsSL https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz -o /tmp/swiftly.tar.gz
tar -xzf /tmp/swiftly.tar.gz -C /tmp
/tmp/swiftly init --quiet-shell-followup --assume-yes || echo "Swift not installed; swift-shop cannot run. See https://www.swift.org/install/linux/"
/tmp/swiftly init --quiet-shell-followup --assume-yes || echo "Swift not installed. See https://www.swift.org/install/linux/"
fi
echo "Toolchains: $(java -version 2>&1 | head -1); $(ruby -v); $(node -v); $(cargo --version); $(python3 --version)"
echo "Self-test the eval harness (no API cost): evals/selftest.sh"
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Bug or wrong advice
description: The skill made an agent do something wrong, unsafe, or slower, or the docs or eval scripts are broken.
description: The skill made an agent do something wrong, unsafe, or slower, or the docs are wrong.
labels: [bug]
body:
- type: markdown
Expand Down
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

45 changes: 26 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@ Versions follow [semantic versioning](https://semver.org): while the major versi
- **Before filing a speedup as a behavior change, the agent looks for a version that keeps the behavior:** redo costly work only when its input changed, hand out copies of cached values, take the fast path and fall back to the original where it cannot match (for example, resend a failed batch one item at a time), or read data that something outside the operation may change once per operation. A behavior change is listed only when no such version exists, with each way tried. When the developer declines a behavior change, the agent applies the version that keeps the behavior.
- **Changes to how code calls another system are now verifiable.** Batching, deduplicating, or caching calls to a database or service is checked against a fake that implements the collaborator's documented contract (limits, missing items, partial failure, error order), comparing everything callers observe and the requested items as a set. Only behavior the documentation does not settle stays unverified.
- **The agent states its mode first, then reads the file for that mode before looking at code** (`WORKFLOW.md` or `WRITING-NEW-CODE.md`), and `DIFFERENTIAL-TESTING.md` before writing differential tests.
- **The agent says when it runs on a small model.** If it knows its model and the model is a small, fast, or low-cost tier, it adds one line after the mode: the skill is tested with coding-tier models such as Claude Sonnet and Opus.
- **New behavior traps,** from changes coding-tier models made in testing: numeric identity in hash keys (`1` against `1.0`), new size limits an optimization introduces, and batched queries that must keep values as bound parameters. In write mode, a cache key must include the user, tenant, and permissions when they change the result.
- **The agent says when it runs on a small model.** If it knows its model and the model is a small, fast, or low-cost tier, it adds one line after the mode: the skill is built for coding-tier models such as Claude Sonnet and Opus.
- **New behavior traps:** numeric identity in hash keys (`1` against `1.0`), new size limits an optimization introduces, and batched queries that must keep values as bound parameters. In write mode, a cache key must include the user, tenant, and permissions when they change the result.
- **The A/A run of a differential test is required only when the behavior can vary between runs** (time, randomness, hash or iteration order, concurrency, external systems); deterministic code records "not needed".
- **The end-to-end share is its own field** in the apply results and part of each item's prediction.
- **One "Reproduce" section can cover every item** in `APPLY-RESULTS.md` when one harness tests them all.

### Fixed

- **Complexity and behavior claims checked across every skill file, and about 60 corrected.** The ones that could lead an agent to a slower or wrong choice:
- Dijkstra with a heap is slower than the array version on dense graphs.
- A deque does not make inserting in the middle O(1).
- One multi-source BFS gives only the distance to the nearest source.
- Components answer reachability only in undirected graphs.
- A rolling hash returns to O(n·m) when there are many matches.
- De Casteljau evaluation is O(d²), not O(d).
- A Fenwick tree cannot answer subtree minimum or maximum.
- Total unimodularity gives integer solutions only with integer data.
- Welford's method is no more accurate than the two-pass variance.
- Standard cardinality sketches fail after about k adaptive queries, not k².
- Rust's `HashMap` order varies per map, not only per process.
- glibc's `qsort` is stable in practice.
- Python's `median` does no exact arithmetic.
- Java's single-character `split` compiles no regex.
- C build files alone no longer select the C companion file for C++ projects.
- **Citations corrected:** the LCS hardness result (Abboud, Backurs, and Vassilevska Williams), the differential-privacy method for robust streaming (Hassidim et al.), and the author list of the SODA 2026 cardinality-sketch paper.

### Added

- **For contributors:** `docs/ARCHITECTURE.md` (what loads when, where each idea lives), `CONTRIBUTING.md`, issue and pull-request templates, `CODEOWNERS`, and a dev container with the JDK, Ruby, Node, Rust, Python, and Swift toolchains.
Expand All @@ -26,15 +46,8 @@ Versions follow [semantic versioning](https://semver.org): while the major versi

### Removed

- **The evaluation harness (`evals/`) and the examples (`examples/`),** to be rebuilt per `docs/EVAL-PLAN.md`. Both stay readable in the [repository history](https://github.com/protechnocrats/algorithmic-intelligence/tree/da47e4b), with every round's results.
- **The CI checks that depended on it** (token budgets, cross-references, rule evidence) and `docs/RULE-EVIDENCE.md`.

### Evaluation

Results on Claude Opus 5.5 from the rounds since 0.1.0 ([results in the history](https://github.com/protechnocrats/algorithmic-intelligence/tree/da47e4b/evals/results)), graded on every category including a judge reading each session's code and reports:
- Without the skill, Opus applied behavior changes on a general "apply all" in all 3 sessions where this could be scored. With it, Opus held every one for review, in 4 of 4 sessions.
- Bugs were reported to the developer in 4 of 4 sessions with the skill and 0 of 3 without.
- Sessions with the skill cost 1.7 to 3 times as much.
- **The evaluation harness (`evals/`), the examples (`examples/`), and all their results,** including the results quoted in the README and in the 0.1.0 notes below (the published v0.1.0 release page keeps its original notes). The skill will be benchmarked from scratch under `docs/EVAL-PLAN.md`, and only those results will be published.
- **The CI checks that depended on the harness** (token budgets, cross-references, rule evidence), `docs/RULE-EVIDENCE.md`, and the harness's `.gitignore`.

## [0.1.0] - 2026-11-01

Expand All @@ -52,14 +65,8 @@ The first release. Install it with `npx skills add https://github.com/protechnoc
- **Techniques:** core tables plus 16 domain files (graphs and trees; sequences, DP, search, and NP-hard problems; strings and text; math and numerics; machine learning; images and signals; geometry and CAD; games and simulation; spatial data; hardware and concurrency; data at scale; optimization and scheduling; hostile inputs; distributed systems; queues and latency; specialized data structures).
- **Reports:** `OPTIMIZATION-REPORT.md` written once in report mode and never rewritten, `APPLY-RESULTS.md` written once in apply mode, and `BUGS-FOUND.md`. Bugs are documented, never fixed on purpose. Behavior changes are listed for review and marked in the code once approved.

### Evaluation

- Test projects in Kotlin, TypeScript, Swift, C, Rust, Java, Ruby, and Python with planted cases and answer keys; held-out Python and Ruby projects; grading probes for the Python, TypeScript, Java, and Ruby projects; a headless runner with a spending cap and a stall watchdog; cost, token, and permission-refusal statistics; trigger tests; token budgets; and checks of Kotlin claims the official documentation does not settle.
- Results so far are in `evals/results/`. On the held-out Python project (round 3), report-flow cases passed at 1.00 with the skill against 0.50 without it on Opus 5.5, and 0.83 against 0.39 on Haiku 5.5. On the Java tuning project (rounds 4 to 6, Haiku 5.5, with the skill only) no session changed the code's behavior.

### Known limitations

- Only Claude Code has been evaluated; the skill is written to be agent-neutral.
- The Java and Ruby projects have no baseline runs yet, the Ruby held-out project has not been run, and the Swift project has not been run on a Swift toolchain.
- Smaller models do not always load the skill for new-code requests from its description alone; the README gives a one-line project instruction that fixes most of it.
- The skill is written to be agent-neutral, but has only been used with Claude Code.
- Smaller models do not always load the skill for new-code requests from its description alone; the README gives a one-line project instruction for this.
- Formal verification (proofs, model checking) is the least developed of the skill's roles.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Thank you for helping. This project is a skill: Markdown instructions that codin
## Changing the skill

- **Put each instruction where it belongs.** A mandatory rule goes in `skills/SKILL.md` and in the file that carries it out. Anything else lives in exactly one file, and others point to it.
- **Write for coding-tier models.** The skill is tested with Claude Sonnet and Opus. Every instruction must be followable without guessing: explicit, no shorthand, and an example where a rule is easy to misread.
- **Write for coding-tier models** such as Claude Sonnet and Opus. Every instruction must be followable without guessing: explicit, no shorthand, and an example where a rule is easy to misread.
- **Keep generic files language-neutral.** Name concepts ("an operation that copies a collection"), not one language's functions. Language-specific names belong in `skills/languages/`.
- **Keep references whole.** When you rename a file or a section, or renumber a rule, update every link, file name, quoted section name, and rule number that points at it. An agent that follows a reference to nothing skips that step.
- **Do not trim instructions to save tokens.** Every file is loaded only when a step names it. Remove repetition, never content.
Expand All @@ -35,7 +35,7 @@ Use [`skills/languages/GENERIC.md`](skills/languages/GENERIC.md) as the checklis

## Evaluation

The evaluation harness is being rebuilt. [docs/EVAL-PLAN.md](docs/EVAL-PLAN.md) describes what it will test (hostile inputs, security side effects of optimizations, unusual problems, and write mode, on Sonnet and Opus). Earlier rounds and their tooling are in the git history before the `evals/` folder was removed.
A new evaluation harness is being built from scratch. [docs/EVAL-PLAN.md](docs/EVAL-PLAN.md) describes what it will test (hostile inputs, security side effects of optimizations, unusual problems, and write mode, on Sonnet and Opus).

## Toolchains

Expand Down
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ Algorithmic Intelligence (`algorithmic-intelligence`) is a skill for AI coding a

Sometimes the best engineering decision is to leave the code alone, and the skill says so when it is.

**See it first:** [a real, unedited report](https://github.com/protechnocrats/algorithmic-intelligence/tree/da47e4b/examples) from one session on a Java project, and one item compared with and without the skill.

## Quick start

```bash
Expand Down Expand Up @@ -117,7 +115,7 @@ Agents load a skill by matching your request against the skill's description. Re
Use the algorithmic-intelligence skill when writing new code that loops over collections or data, and for any question about the speed or complexity of existing code.
```

Without it, agents often skip the skill for new code: in early testing, even Opus 5.5 did not load it for 1 of 3 write-mode requests. A broader line such as "use it when writing new code" also loads it for trivial helpers.
Without it, agents can skip the skill for new code. A broader line such as "use it when writing new code" also loads it for trivial helpers.

### Verify and update

Expand Down Expand Up @@ -242,18 +240,9 @@ Algorithmic reasoning is independent of the programming language, but costs and

Companion files cover the language and its standard library only. Frameworks and platforms (UI toolkits, ORMs, web frameworks, game engines) are deliberately not covered; the general rules (N+1 queries, main-thread blocking, I/O in loops) apply to them.

## Evidence

The skill was tested by running the same coding agent on small projects with planted problems, with and without the skill, and checking each session's final code against the original with trap inputs. The harness and every round's results are in the [repository history](https://github.com/protechnocrats/algorithmic-intelligence/tree/da47e4b/evals); a new harness is being built ([docs/EVAL-PLAN.md](docs/EVAL-PLAN.md)).

Results on Claude Opus 5.5 so far:

- **Hostile input** (held-out Python project): every run without the skill shipped a hash-based fix that becomes quadratic when an attacker chooses colliding IDs, and applied a concurrency change nobody approved. No run with the skill did either. Report-flow cases passed at 1.00 with the skill against 0.50 without.
- **Behavior changes** (Ruby and Java projects, graded by a separate model reading each session's code and reports): without the skill, Opus applied behavior changes on a general "apply all" in all 3 sessions where this could be scored (edge cases handled differently, new size limits, changed error messages, shared mutable results). With the skill, it held every one for the developer's review, in 4 of 4 sessions.
- **Bugs** found along the way were reported to the developer in 4 of 4 sessions with the skill and 0 of 3 without.
- **Cost:** sessions with the skill cost 1.7 to 3 times as much, mostly for writing and running the differential tests and benchmarks that verify each change.
## Evaluation

**Limits:** small samples, so treat these as early signals. All runs used Claude Code; other agents have not been evaluated. Claude Sonnet has not been tested yet.
The skill will be evaluated by running the same coding agent on projects with planted problems, with and without the skill, and checking each session's final code and reports. The benchmarks are being built ([docs/EVAL-PLAN.md](docs/EVAL-PLAN.md)); results will be published here when they exist.

## Files

Expand All @@ -280,7 +269,7 @@ The skill's knowledge base is modular and organized around its workflow. The age
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): what each part of the repository does, what the agent loads in each mode, and where each idea lives.
- [CONTRIBUTING.md](CONTRIBUTING.md): how changes reach `main`, and the rules for changing the skill.
- `.devcontainer/`: the JDK, Ruby, Node, Rust, Python, and Swift toolchains, and a sandbox for running agent sessions.
- [docs/EVAL-PLAN.md](docs/EVAL-PLAN.md): the plan for the next evaluations. Earlier rounds are in the [repository history](https://github.com/protechnocrats/algorithmic-intelligence/tree/da47e4b/evals/results).
- [docs/EVAL-PLAN.md](docs/EVAL-PLAN.md): the plan for the next evaluations.

## Releases and security

Expand Down
2 changes: 1 addition & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A map of the repository for contributors: what each part does, what loads when,

## The skill

`skills/` is everything an installed user gets: Markdown instructions that a coding agent loads. The skill has no code. Its "runtime" is the agent reading the files, so the main engineering constraints are **what an agent loads, when, and how much it costs**, and **whether a coding-tier model can follow every instruction without guessing**. The evaluation harness is being rebuilt ([EVAL-PLAN.md](EVAL-PLAN.md)).
`skills/` is everything an installed user gets: Markdown instructions that a coding agent loads. The skill has no code. Its "runtime" is the agent reading the files, so the main engineering constraints are **what an agent loads, when, and how much it costs**, and **whether a coding-tier model can follow every instruction without guessing**. A new evaluation harness is being built from scratch ([EVAL-PLAN.md](EVAL-PLAN.md)).

## What loads when

Expand Down
Loading
Loading