Zum Inhalt springen

Skills

assert-what-the-generator-found

Ein Generator, der abstürzt, sagt dir, dass er gescheitert ist; einer, der plausible Ausgabe liefert, sagt dir nichts. Prüfe, was er gefunden hat, nie dass er gelaufen ist.

Die Zusammenfassung oben ist eine Übersetzung. Die Karte selbst ist das englische Original — sie ist das, was der Agent liest und was der Hash unten bezeugt.

MusterHerkunft: cleanStatus: activev0.1.0 · Apache-2.0

Verliehen von der Person, die die Karte gelesen hat — nicht von der Datei über sich selbst behauptet. Eine Karte, die der Agent während eines Laufs mit nicht vertrauenswürdigen Inhalten destilliert, kommt kontaminiert zur Welt und wird bis zur Prüfung zurückgehalten, bevor sie jemals abgerufen wird.

Wann sie in den Sinn kommt

  • wrote a code generator
  • testing a schema dump
  • the output looks fine
  • extracting structure from a library

In Vermeiden und Prüfen steckt meist der Wert. Tun ist der Abschnitt, den alle schreiben.

Auslöser

You have written something that reads one representation and emits another: a schema dump, a reference extractor, a migration, a scraper, an index builder. Anything whose output nobody reads in full because there is too much of it.

It does not apply to a function returning one value you can eyeball. The risk here is specific to output that is large enough that "it looks right" is the only review it will ever get.

Tun

  1. Before writing the test, name the count. How many commands, rows, files, or fields should come out? Get that number from somewhere other than the generator — the source, the docs, a manual count.
  2. Assert the count, or a floor on it. assert len(groups) >= 10, not assert result.
  3. Assert the presence of specific, named items you know must exist. Three or four is enough, and pick ones from different shapes of input.
  4. If the generator classifies things, assert that each class is non-empty. A classifier that puts everything in one bucket is the failure this catches.

Vermeiden

assert build() — it passes when the generator returns an empty list, a partial list, or a list where every item is subtly the wrong kind.

Also avoid trusting isinstance when walking a third-party structure. Libraries vendor their dependencies: a TyperGroup is not an instance of the click.Group your file imported, because Typer ships its own copy of Click. Ask whether the object has the thing you need — a commands mapping, an items method — rather than what class it claims to be. Duck-typing survives a vendored dependency and a major version bump; a class check survives neither, and fails by misclassifying rather than by raising.

Prüfen

Break the generator on purpose and watch the test fail. Comment out the recursion into subcommands, or make the type check reject everything, and run the suite.

If the suite still passes, the test asserts that the generator ran, and you have written the test that this skill exists to prevent.

Risiko

Hard-coding an exact count makes the test a maintenance chore: every legitimately added command turns it red. Prefer a floor (>= 10) plus named items, and reserve exact counts for things that genuinely should not change without a decision.

There is also a limit. These assertions catch a generator that dropped a whole category. They do not catch one that gets a single field wrong on one item, and pretending otherwise is its own kind of false confidence.

Verwenden

Die Karte ist Daten. Klonen Sie das Repository und importieren Sie sie über den Pfad — was über das Netz kommt, gilt als kontaminiert und wird bis zur Freigabe zurückgehalten. Das ist das gewünschte Verhalten und der Grund, warum es hier keinen Einzeiler-Installer gibt.

git clone https://github.com/brcampidelli/chimera-agent.git
chimera skills-import chimera-agent/skills/assert-what-the-generator-found/SKILL.md

Integrität

SHA-256 der Datei in der veröffentlichten Fassung. Wer sie importiert, kann prüfen, dass das Empfangene dem entspricht, was diese Seite gezeigt hat.

c237a831782562ab7a2fc672af9a3a82ef12965dc45bcf58eddd924fab6e5f3e

Die Karte im Repository lesen