# Barcode Lab index

Every document and page of the Barcode Lab, and the StarCode documents and code it depends on, with a link to each. Start here. Every document in this folder links back to this page, and StarCode's own index links here.

Local folder: `workspace/music-dump-donotuse/barcode_prototypes` (gitignored, not in the repository). Live: https://barcode-lab.pages.dev.

Deploy: copy `index.html`, `js`, `assets`, `styles`, `cardspec` and `docs` to a scratch folder, set `window.__BUILD__` in the copied `index.html`, then from `workspace/starcode` (which has wrangler in its npx cache) run `npx --no-install wrangler pages deploy <folder> --project-name barcode-lab --branch main --commit-dirty=true`. Run `node ops/governance/linter-workspace.js workspace/music-dump-donotuse/barcode_prototypes` from the repository root first; it must report no findings outside `cardspec/vendor`.

## The two indexes

- This page: the lab. Live at https://barcode-lab.pages.dev/docs/INDEX.md.
- [StarCode index](../../../starcode/docs/INDEX.md), live at https://starcode-game.pages.dev/docs/INDEX. Every StarCode document, prototype and open decision.

## Documents in this folder

- [Code cards](CODE-CARDS.md) — The format: what a scan becomes, the boundary, the record, the words and the square, what exists today and where, and the merge plan for lifting the capture layer out of StarCode and the lab into one library. Read first.
- [Scanning lessons](SCANNING-LESSONS.md) — Fifty-six numbered lessons from building the scanner and the cards: decoder facts, frame budget, misreads, sampling the print, ink and background, colour consensus, rendering gotchas, interface, words, what a scan proves, testing, and drawing codes for a card.
- [Colour distinction](COLOUR-DISTINCTION.md) — One problem isolated: separating the print, the object, the surroundings and the light from a phone camera, and how any game can use the four answers.
- [Extraction roadmap](EXTRACTION-ROADMAP.md) — The step-by-step plan for lifting every barcode module out of StarCode and the lab into one library, written for someone with no context: vocabulary, rules, inventory, target layout, six phases, commands, gotchas, deploy recipes, definition of done.
- [Creature design](CREATURE-GDD.md) — The pet game that eats codes: the portion curve, the five kind dimensions, the plate and sickness, weight and neglect, the moment after Done.

## Pages you can open

- [Barcode Lab](https://barcode-lab.pages.dev) — Live camera and photo scanning with every reader field shown: Visual, Detail, Composition, Cards and Colours views, zoom, batch upload, delete, export.
- [Card styles](https://barcode-lab.pages.dev/styles/) — Five visual styles for a card (Tournament, Juicy, Menu, Arcade, Riso) on three sample scans. Pictures drawn from the sampled pattern; superseded in principle by the format, kept as the style study.
- [Capture cards](https://barcode-lab.pages.dev/cardspec/) — Cards drawn to the format with the QR square in nine module drawings, each decoded live by the lab's reader.
- [Beyond the square](https://barcode-lab.pages.dev/cardspec/more) — Aztec with hexagon modules, MaxiCode, and overlaid QR codes, decoded three ways.
- [Twin codes](https://barcode-lab.pages.dev/cardspec/twin) — Two QR codes authored to share one mark, with the search and the diagnostics. An experiment with no decided purpose.

## StarCode documents the lab depends on

- [Design decisions](../../../starcode/docs/DESIGN_DECISIONS.md), live at https://starcode-game.pages.dev/docs/DESIGN-DECISIONS — The ruling ledger. Section 6 is the intake boundary the capture layer adopts whole.
- [Game design document](../../../starcode/docs/GDD.md) — The seed pipeline and the intake boundary, and the game that consumes captures today.
- [Main handoff](../../../starcode/docs/HANDOFF.md) — How to work on StarCode: tests, deploy, the boundary test.
- [System words handoff](../../../starcode/docs/HANDOFF_SYSTEM_WORDS_CODE.md) — The six-word reversible code the card's words and square carry.
- [What a barcode can honestly prove](../../../starcode/docs/BARCODE-TAXONOMY.md) — The table behind the honesty rule.

## Code

StarCode, built and in use:

- `workspace/starcode/js/cosmicid.js` — canonical code, SHA-256, the cosmic ID with the "cosmos" prefix, the namespaced variant.
- `workspace/starcode/js/symbology.js` — the four families and the symbology name normaliser.
- `workspace/starcode/js/barcodescan.js` — the decoder over the vendored zxing-wasm.
- `workspace/starcode/js/system-words-code.js`, `system-words-list.js`, `system-words-open.js`, `words-entry.js` — the six-word code, its frozen 4096-word list, and entry by words.
- `workspace/starcode/tests/intakeboundary.test.js` — proves nothing from a scan reaches storage.

Barcode Lab, prototypes:

- `js/decode.js` — StarCode's decoder extended: every reader field, five preprocessing passes, text modes.
- `js/app.js` — the live loop, sightings, misread folding and correction, rescans, views.
- `js/sample.js`, `js/colour.js`, `js/consensus.js` — sampling the print through its corners, ink and background by quartile, the colour record with ring and frame votes, white balance, presence ranking, the hue histogram.
- `js/synth.js`, `js/cards.js`, `js/colourview.js`, `js/cardgrid.js` — the composition, the cards, the colours view.
- `js/zoom.js`, `js/batch.js`, `js/resample.js`, `js/exportjson.js`, `js/testpattern.js` — camera zoom, batch photos, re-sampling, export, a generated test code.
- `styles/js/` — the five card styles and their sample scans.
- `cardspec/js/card.js`, `page.js`, `more.js`, `twin.js` — the format card, the module drawings, the other symbols, the twin codes. `cardspec/vendor/` holds the QR encoder and bwip-js so nothing loads from a CDN.

## Design conclusions in force

- Only "new to this player" is cheat-proof; anything global is shown, never scored. Reasons in the creature document, section 2, and the lessons, section 10.
- The scanned content never crosses the boundary; the ID, family and class do. Code cards, section 2.
- Rarity is never a field. Code cards, section 5.
- Colour is a claim that improves with frames and devices, never proof. Colour distinction, section 5.
- Plain words: ink and background, the code as the camera sees it, object palette, surroundings palette. Lessons, section 9.
