Skip to content

Library format: valid-YAML entries, project Libraries found by convention #41

Closed

Description

@lukemaj

What: A Library is one flat folder of valid-YAML Markdown entries that can serve by exact key, Cue, or both, including long items.
Why: The former subfolder layout and both loaders' header and 1,800-byte storage restrictions blocked waiting Cue items in #19.
So what: Both reviewed PRs are merged and this format work is complete; the #19 owner extends the existing writer next, while activation rides the next build.

Parent

#3 (serving).

Outcome

  • Each project Library and the Great Library is flat: one folder and one Markdown file per item, with no keys/, cue/, pages/, or tools/ split.
  • A valid YAML header states exact-key serving, Cue serving, or both. The body is the knowledge. Malformed entries are reported by contextmd-serve check with their file and reason.
  • Short items are served whole. Long bodies may live in the same folder and are served as a Read <this file> in full pointer; 1,800 UTF-8 bytes remains a serving constraint rather than a storage rejection.
  • The current session's project Library is discovered at <project>/library/ by convention, without one serving.json line per project. Unrelated project Libraries do not load.
  • docs/, GLOSSARY.md, and ADRs stay in place. Entries can point to those records.
  • ContextMD and Chromeria agree on raw header validation, entry identity/version, matcher membership, body handling, source ordering, and discovery. Existing matcher normalization remains delegated; the known Unicode-digit difference is owned by fix(serve): error signatures agree on Unicode decimal digits #69.

Contribution to the Objective

One Library format gives captured knowledge a serving owner, so later sessions can receive it before they relearn it. It removes the format blockers for waiting Cue items in #19.

Elon record

Acceptance criteria

  • A flat Library loads valid exact-key, Cue-only, and both entries without cross-loader rejection; strict new-entry validation reports unknown fields, wrong types, malformed YAML and invalid matcher combinations with file and reason.
  • Valid YAML quoted/plain strings and flow string lists preserve their parsed meaning, including paired JSON surrogate escapes; existing stores retain an explicit temporary legacy reader/writer contract and visible legacy diagnostics.
  • A body over 1,800 UTF-8 bytes loads and serves a full-read pointer to itself; its complete knowledge stays in the file. Short knowledge stays whole when the harness can carry it; optional Cue display metadata shrinks first, and a complete self-pointer handles tighter deny/output limits. Authored record targets remain distinct from delivery pointers, and entry-pointer lifts require a full read after that version's first deny.
  • A session in a project, including its subdirectories and worktrees, loads that project's flat library/ without registration; another project's session cannot see it. Missing conventional Libraries are normal, while explicitly configured bad stores remain errors.
  • Shared contract fixtures prove both implementations accept/reject and return the same raw parsed entries and store/discovery cases, with independent expected outcomes; ASCII normalized error keys agree and the fix(serve): error signatures agree on Unicode decimal digits #69 Unicode difference is explicitly asserted per language.
  • Existing store checks are recorded using the candidate loader without changing live hooks, configs, processes, or databases.
  • Each PR has a review comment and successful review/independent-sol and review/independent-grok on its exact head, and green required checks before merge.

Design review

  • User decisions: flat layout and self-pointer decision, reiterated in the two loader gaps.
  • Opus produced design v1, both independent roasts returned REVISE (Sol gpt-6.1-sol/max: 9 findings; Grok grok-4.7/xhigh: 7), and Opus revised to v2. The adjudicated review record records the accepted corrections and rejected flow-list deletion. All ordinary format choices are resolved. Independent design round 2 returned REVISE (Sol: 3 blockers; Grok: 1 clarification). All were accepted and Opus completed v3, including the upgrade-era inline-row correction. The final exact-head PR reviews checked design closure and code together; both models APPROVE with every prior finding closed.

Implementation decisions

  • Strict YAML 1.2 subset: quoted/plain scalar strings, booleans where declared, and one-line flow string lists. Block lists, nested collections, anchors, tags, multiline scalars and trailing comments are outside this format and are reported, never misread. Header fields are id, command, path, error, must-know-before, name, applies, and target; field presence derives matcher membership, with both name and applies required for Cue.
  • check --entry FILE... is strict admission for new entries in every Library. Store check keeps the existing exact_keys/cue JSON and errors surface, adds visible legacy diagnostics, and exits zero only when there are no errors. Registered stores temporarily support repeated key fields and the whole unquoted remainder containing : ; project Libraries are strict, and historical card parsing retains legacy support permanently.
  • While a registered store has any old running reader, its writers keep today's form, one matcher's fields and short body. New-format shared writes wait for every intended reader to upgrade. A later contract step converts legacy entries and retires runtime tolerance; this is not deployment authority.
  • Discover the nearest checkout root from the joined thread directory, recognizing .git files for worktrees; use the authoritative directory for a non-Git project. Never discover from hook cwd. Read one flat folder, deduplicate source realpaths, order project first, and keep ids unique per matcher; reject an incoming both-entry wholly on any collision.
  • Cache parsed bytes per mode, rebuild active sources per moment, and resolve file/record targets freshly. Include source realpath in the cache stamp. Reject whitespace-only command/error keys using shared predicates, and scan syntax before field validation. Preserve raw-byte versions. Keep authored record targets separate from self-read delivery paths and distinguish entry-pointer lifts from ordinary record-pointer lifts. An incoming entry deny rebinds an unlifted row's kind and target, including older inline rows, without resetting first deny/cap/epoch; lifted rows and incoming record pointers stay unchanged.

Non-goals

Blockers

  • None for implementation. Shared new-format admission remains separate from merge and waits for every intended running reader to support it; this task authorizes no deployment or restart.

Required proof

  • Focused Python loader/config/check tests and Chromeria loader/selection tests, shared corpus equality and expected outcomes, and malformed-entry CLI failure with file and reason.
  • Isolated discovery and full-read-pointer behavior through the public selection seam, plus candidate contextmd-serve check output for existing registered stores.
  • Final candidate SHAs, appropriate ContextMD version transition, exact-head independent Sol/Grok statuses and green checks linked from the PRs.
  • Verify both PRs merged into their intended main; then reassess Capture: apply waiting items as exact-key and Cue Library entries #19 against its live dependencies and state its first step.

Current handoff

Merged, closed and finalized. Exact heads, proof, review identities, delivered commits and cleanup are recorded in Final delivery below. No implementation work remains in this issue.

PR review disposition and recovery

  • Opus's v3 contract remains normative; this correction changes no format choice. Original exact candidates were ContextMD efc2ab1e1a0f2241b07fca7c99c38aece26bfb1e and Chromeria a36f84987a410a0e54a73be5f316a1e68e67b2e2.
  • The planner's 13:37 deployment restart cut Sol's first PR review before a complete verdict. Its partial probe findings were preserved; no approval was inferred. A fresh current-head recovery review completed after re-dispatch, and Grok recovered its same job.
  • Both complete PR reviews returned REVISE with the same 3 supported blockers. Findings published before old-head failure statuses: Sol ContextMD / Chromeria; Grok ContextMD / Chromeria.
  • All accepted: JS field capture excluded YAML non-break LS/PS; JSON string decoding excluded raw tabs permitted by v3; L2 omitted a leading flow-map indicator. Parent reproduced each, with 18 new independent expected cases (6 Python/16 TS fail before), then fixed both parser owners and corpus copies after both complete reviews ended.
  • Sol independently ran 66 Python tests and 230 TypeScript tests on the original exact heads and reviewed both complete diffs; Grok independently probed the three defects. Green old suites/CI did not prove those missing boundary inputs. The corrected exact candidates now pass the expanded proof above; fresh independent reviews and fresh CI are still required.
  • Recovery records: original Sol node:delegated-task:command%3Amcp%3Ad18bf949-1f59-4d3f-a27d-542755c5decb%3Adelegate-task%3Acontextmd41-exact-head-pr-sol-v1 cancelled; replacement node:delegated-task:command%3Amcp%3A600ba748-11bd-4c1d-a101-4278ebbfbde6%3Adelegate-task%3Acontextmd41-exact-head-pr-sol-v1-recovery-1337 completed; Grok node:delegated-task:command%3Amcp%3Ad18bf949-1f59-4d3f-a27d-542755c5decb%3Adelegate-task%3Acontextmd41-exact-head-pr-grok-v1 completed, latest terminal ordinal 2. No active old review remains.
  • Other owner records: ContextMD fix(serve): error signatures agree on Unicode decimal digits #69 for inherited normalization differences, AgentsMD #225 for the hook's data false positive. No owner code was changed here; fix(serve): error signatures agree on Unicode decimal digits #69's earlier FEFF evidence is superseded by the merged matcher bases, recorded in fix(serve): error signatures agree on Unicode decimal digits #69 (comment).

PR review round 2 disposition

Both reviews completed as STALE BASE with all prior code findings closed and no new supported code blocker. Findings preceded failure statuses on the pinned old heads a2b8e09bc0a8da4b3c71f76aeaf86faaaaaeb5da / c10ded6a6f41114065189b30ec2af6d50640d96b: Sol ContextMD / Chromeria; Grok ContextMD / Chromeria. Sol independently passed 66 Python tests, 248 TypeScript tests and 270 parser probes per language; Grok independently checked all 18 correction rows and 17 edges. Neither verdict transfers after rebase.

The parent accepted the stale-base disposition, waited for both tasks to finish, then rebased onto the externally merged matcher PRs. ContextMD preserved main's VERSION and CHANGELOG and used versionctl to prepare the single 0.6.3 -> 1.0.0 major transition. Only that changelog wording/version baseline changes in the range diff; Chromeria's Library patch is identical. New matcher code and tests are preserved, with no Library diff in keys.py or Matcher.ts. No format choice, runtime, hook, config, capture code or memory changed.

Final delivery

  • ContextMD PR #70 merged into main at 5dc096cac8c0fecf548aba2b8b1886a12d226118 on 2026-10-14 13:42:40 UTC. Reviewed head daf898314ca5852310f333a34a133d8fb60ddd2d, base d45f751a564afa87d058eb0982e41fcece3c0e7c, version 0.6.3 -> 1.0.0. The squash tree 0e302daa532db34de5b9727faf7ab007830c2378 equals the reviewed head's tree.
  • Chromeria PR #288 merged into main at ddf32f8ab8b3ec4fc2e486ec13af3957039fdbb4 on 2026-10-14 13:40:02 UTC. Reviewed head 6e9bed48046399d07ef1a63de6adee8243dd85ed, live target base 9b495751dc20e01077aae2a7c2481f403673645d. Its squash tree 39dbf6af510f026e59fd6a7393948e0c611e698c equals the reviewed, freshly tested integration tree. No version bump.
  • Final Sol APPROVE findings: ContextMD, Chromeria. Final Grok APPROVE findings: ContextMD, Chromeria. Before each merge, newest review/independent, review/independent-sol and review/independent-grok were success on that exact head, authored by the authenticated account lukemaj, after their linked findings comments.
  • Fresh complete Chromeria CI passed with current base 9b495751 and unchanged head 6e9bed4; generated merge 7f3bd6ad68f1899b1ca38a982d2af909795434b9 has those parents and the same tree as the delivered squash. The CI refresh record closes Sol's actual old-merge proof gap without changing source or review head. Earlier findings/statuses remain historical; no verdict was transferred to a different SHA.
  • Full local proof on the exact candidates: 171 Python tests OK with 19 conditional skips; file-only corpus twin test 14 passed; 268 focused TypeScript tests; nine-file lint and server-only typecheck exit 0; clean versionctl release-check. Independent Sol ran 85 Python tests, 268 TypeScript tests, and 270 parser probes per language; Grok checked all 109 corpus rows and 20 edges. Corpus copies: 109 entry, 7 source and 10 discovery cases, SHA-256 4176777d5d9e9f6b61ace92171c6d659bfd72e03f210a5644204da217902377d.
  • Both actual loaders matched every baseline field/version on all 16 entries in each immutable machine snapshot, each 7 exact, 9 Cue, 13 legacy, zero errors. Actual bestia candidate check also exited 0. These are captured-byte compatibility and candidate checks, not a fleet activation claim.
  • Limits retained: Sol's additional local integration runs had existing wall-clock assertion failures (267/268 and 264/268); no cause or Library regression was established. Those are documented in its full report, not called passing. Fresh complete integration CI passed. No live activation/admission, runtime restart, deploy, install, tag/release/publication, capture judge/extractor or agent-memory action was performed in this task. The next ordinary build owns activation.
  • Cleanup verified in the merge steps: both owned worktrees and local/remote task branches are gone; no processes had either worktree as their cwd. Other agents' workspaces and both canonical checkouts were left alone. Duplicate final-review source archives, fixture folders and caches were retired. Design/review/proof records and the private immutable compatibility inputs remain evidence for the reader transition, not agent memory.
  • Format delivery is complete and both owning issues are closed. ContextMD Capture: apply waiting items as exact-key and Cue Library entries #19's format blocker is cleared. Its first step is extending the existing shape/add-only apply writer for strict Cue headers and receipts; its existing reflection, trust, reader and shown-proof gates remain.

Activity

  1. lukemaj commented on Oct 13, 2026

    @lukemaj
    ContributorAuthor

    User decision 2026-10-13: a Library is one flat folder with one file per item. Each file's header says how it is served (exact key, Cue, or both); its body is the knowledge. Short items are served whole; long ones as a "Read this file in full" pointer to themselves. No keys/, cue/ or pages/ subfolders; grouping only if a library grows past about 100 items and agents struggle. Personal rules live in the user's Great Library, not a separate store.

  2. lukemaj commented on Oct 13, 2026

    @lukemaj
    ContributorAuthor

    User decision, 2026-10-13: the Library is flat. One folder, one file per item. Each file's header says how the item is served (exact key, Cue, or both), and its body is the knowledge. A short item is served whole; a long one is served as "Read this file in full". There are no keys/, cue/, pages/ or tools/ subfolders until about 100 items. The Great Library store is ~/dev/promachos/library/ itself (lukemaj/promachos#2).

    This changes the Outcome's layout bullet. It also adds two loader gaps this Issue should cover:

    • contextmd/serve/store.py and Chromeria Store.ts reject any header field other than id, command, path, error, must-know-before and target. So a Cue or "both" header in a served folder fails contextmd-serve check.
    • Both loaders reject a body over 1,800 UTF-8 bytes (MAX_ENTRY_BYTES). So a long item cannot yet live in the same folder and be served as "Read this file in full".
  3. lukemaj commented on Oct 14, 2026

    @lukemaj
    ContributorAuthor

    What: Opus produced the first Library format design; Sol and Grok are independently roasting it before implementation.
    Why: Current stores contain legacy headers as well as the two known loader gaps, so strict YAML alone would drop existing served knowledge during rollout.
    So what: The implementation child adjudicates both roasts, gets the design revised, records the final contract here, and then builds both twins.

    The proposed shape derives exact-key/Cue/both membership from header fields, serves long knowledge through full-read self-pointers, and discovers the current Library from the joined thread's project/worktree root rather than the hook's mutable cwd. The design and roasts are kept outside the repositories; the final agreed interface and dispositions will be published here before code changes.

    Verified baseline: 25 focused Python store/config/card tests and 22 Chromeria selection tests pass. Candidate parsing reproduces both gaps: mixed headers fail on name/applies; a 1,801-byte body fails at 1,800; a YAML command flow list is wrongly treated as one command.

    A read-only YAML 1.2 oracle over bestia's existing files confirms 4 repeated-key exact entries and 9 Cue entries with unquoted : are invalid YAML; 3 other entries are valid. No files, configuration or runtimes in those owners changed. The first design's YAML subset and compatibility scope are proposals, not accepted decisions, and the review explicitly includes the original flow-list requirement.

    Counterpart: toolboxmd/chromeria#268. Own worktrees remain clean at the original pinned bases; later unrelated merges will be reconciled before implementation. No deployment, restart or capture-judge/extractor work has occurred.

  4. lukemaj commented on Oct 14, 2026

    @lukemaj
    ContributorAuthor

    What: Independent Sol and Grok design roasts both returned REVISE, and their accepted findings are now with Opus for the second contract.
    Why: The first proposal left reachable gaps in flow-list support, whole serving, version-bound read lifts, target caching, repository-subdirectory discovery and mixed-reader compatibility.
    So what: The implementation child verifies the revised contract and publishes its final decisions here before building either twin; no new human format approval is needed.

    Sol reviewed on Codex gpt-6.1-sol at max effort; Grok reviewed on grok-4.7 at xhigh effort. Both read the v1 design and pinned base consumers, and wrote their reports outside the repositories. These are design verdicts, not exact-head code approval.

    Accepted corrections:

    • Retain flow string lists and decode valid paired JSON surrogate escapes.
    • Preserve a short knowledge body by shrinking optional Cue display metadata first; omitted bodies recover through a complete pointer to the entry itself. Grok's tight deny room needs a self-pointer when an inline rule cannot fit whole.
    • Allow long bodies with authored record targets; distinguish those targets from derived serving pointers.
    • Bind entry-pointer read lifts to the current entry version's first deny, preserving explicit-record pointer semantics.
    • Cache parsed bytes and parsing mode; resolve filesystem targets and active source views freshly.
    • Resolve the nearest checkout root from the joined thread directory, including registered subdirectories and worktree .git files, without using mutable hook cwd.
    • Make new-writer YAML validation strict and the temporary legacy-reader/writer contract explicit. Existing legacy-only store checks may pass with visible warnings; a new check passing does not certify old running readers.
    • Preserve separate legacy key values and exact Cue score documents. Remove claims that old readers merely under-serve new syntax: an old reader can accept a quoted target and misresolve it.
    • Certify identical raw YAML/Library behavior and disclose inherited error-normalization divergence separately at fix(serve): error signatures agree on Unicode decimal digits #69, without touching matcher work.

    Rejected: deleting requested flow-list support because some running readers are old. New-format shared writes need upgraded readers; the strict format still supports the requested syntax.

    Verified outside live runtimes: read-only snapshots on bestia, rocky and cavallo each show 7 exact entries and 9 Cue entries, zero nested Markdown, zero current loader errors, and byte-identical entry files across machines. Those snapshots supply the candidate comparison. No server, hook, configuration, database, capture judge or extractor changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions