Skip to content

Phase 0 — the protocol as typed code#2

Merged
darko-mijic merged 29 commits into
mainfrom
feature/mvp-init
Jun 10, 2026
Merged

Phase 0 — the protocol as typed code#2
darko-mijic merged 29 commits into
mainfrom
feature/mvp-init

Conversation

@darko-mijic

@darko-mijic darko-mijic commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What is this?

This PR is the first buildable foundation of the Libar Software Delivery Protocol — an attempt to treat the whole software-delivery lifecycle (intent, specs, design decisions, constraints, code bindings, verification) as typed code in the repo, derive one graph from it, and generate every other artifact off that graph.

The starting observation: delivery knowledge today is scattered across tickets, wikis, PRDs, and tribal memory — none of it machine-checkable, all of it free to drift from the code. Meanwhile, the consumers of that knowledge are no longer just humans: coding agents, CI, and CLIs all need to read delivery intent. A typed graph of related specs is the shape an LLM already reasons in — so the bet is to make delivery intent authorable as code, checkable like code, and queryable as a graph.

Three ideas anchor the design:

  • One authored primitive. Everything you'd recognize as a Use Case, NFR, Decision Record, Epic, or Story is a single Spec type, positioned by three descriptors — kind (what category of truth) × altitude (epic → feature → story) × readiness (idea → scoped → defined → ready) — and enriched in place, never migrated to a different artifact type. The familiar nouns survive as named coordinates, not as a class hierarchy.
  • Honesty over gating. The system checks conformance (is this well-formed?) and honesty (is this not pretending? — e.g. you can't state defined with a blocking open question, and you can't hand-author an implemented badge), but it never gates workflow and never judges content quality. We claim "deterministically validated," never "provably correct."
  • Authored vs derived, never blurred. Humans assert intent (relations, readiness, decisions) and bindings (anchors pointing code at a Spec ID); machines derive facts (implemented, has-verifier). Every edge carries its epistemic status (declared / anchored / inferred), and the taxonomy is never collapsed.

What's in this PR

The ratified concept basedocs/concept/: a lean ubiquitous-language glossary (the terminology contract), eight principle-led design docs (0007, from vision and founding principles through the core model, the graph, validation, consumers, and the roadmap), and DECISIONS.md — a why-log of every hard-to-reverse choice (MD-1…MD-16), each with the alternatives that were rejected and why. The JTBD stories in jtbd-stories/ are the functional spec.

Phase 0: the protocol as typed codesrc/: the Spec primitive and its descriptors, typed relations, binding-only anchors, the Pack grouping, branded IDs, the graph schema, and the validators. Highlights:

  • Floor-bearing sections are closed-typed, so hand-authoring a delivery fact inside a section fails to typecheck — and a runtime check catches what the type system structurally can't.
  • The readiness floor is a kind-conditional evidence table that is itself the single source of truth: clause ids are derived from the table via typeof, the evaluator is one generic loop, and promoted child specs count as evidence only when they actually carry it (an empty stub is not a promotion).
  • Validation runs on a pre-graph stand-in that is honestly fenced as such — there is one validation path, and it migrates onto the extracted graph in Slice 1/3.

A worked exampleexamples/checkout-v1: nine specs plus a pack for an Order Management slice, written tracer-bullet-first so the DSL was forced to be usable before it was finished, with real implementation and test anchors.

Tests and tooling — 57 tests across 10 files, including compile-time pins (@ts-expect-error fixtures proving the type-level guarantees) and active should-fail fixtures for the honesty checks. CI runs the full gate: a fail-closed temporal guard (durable artifacts must state invariants and cite decisions, never narrate history — git is the event log) → typecheck (src + examples) → lint → format → tests → build.

How it was reviewed

Beyond the gate, the branch went through several adversarial review passes during development (recorded in reviews/ and folded into DECISIONS.md as MD-7 and MD-16), plus a final five-track internal review before this PR (implementation fidelity, tests/examples, docs conformance, tooling, plan coherence). The final review found no correctness bugs; its three findings (a comment citing a review event instead of the decision, the missing LICENSE file, the missing repository field) are fixed in the closing commits — along with a CI hermeticity bug the first real workflow run exposed (the typecheck was resolving the package's self-import through stale local build output).

What's next

Slice 1: the extractor — read the *.sdp.ts spec files statically (no execution), derive the first real graph, and feed the existing validators from it. The example in this PR becomes its first input. The slice roadmap is docs/concept/07; the live plan lives in plans/.


Reading guide for reviewers: start with docs/concept/ubiquitous-language.md (the vocabulary), then docs/concept/README.md0007 for the model, DECISIONS.md for any choice that looks arbitrary, and examples/checkout-v1 to see the DSL in use.

…ation

- H1: make the checkout-v1 scenario specs statically extractable (plain object
  literals; drop Object.fromEntries/thenKey/as-Record) so Slice 1's ts-morph
  extractor can reify them without executing.
- H6: simplify tsup — drop the banner + strip-plugin + post-build normalise hook;
  rely on esbuild preserving the CLI entry's source shebang. dist/index.js is now
  shebang-free; dist/cli/sdp.js carries exactly one.
- H7: prettier-ignore .tmp-scratch so format:check stops tripping on scratch.
- H8: add a should-pass/should-fail validator fixture suite (4 active fixtures +
  2 it.todo stubs gated on H2 and D1) as the regression net (05 §5).
- H9: lock the Spec-envelope and Pack type-level honesty defenses with
  @ts-expect-error fixtures; record the excess-property/inline-literal caveat (F7).
- npm run check green: typecheck x2, lint, format, 47 tests + 2 todo, build.
… adversarial review

Re-home the post-Session-1 review's three work-kinds so each gets the right rigor.

- plans/02: refocus to EXECUTION-only code hardening. Wave A marked done with
  verification; Wave B (H2/H3/H4/H5/H10) kept in full but decision-gated on plan 03.
  Adds a carried review backlog (F2 ref naming, F3 aggregate family, F4 modelRefs kind).
- plans/03 (new): the fresh-session grilling agenda — D1-D4, D6 in dependency order,
  the base-first method, what each unblocks. This is the 'item 1' landing zone.
- Absorb the post-split adversarial review (archived in gitignored .tmp-scratch) into
  tracked docs so the signal survives: add D7 (kind-aware defined floor; the kind-blind
  floor forces the example to pad — F1), D8 (.spec.ts test-glob collision), widen D2 to
  cover behavior.examples (F5), and §3a 'resolvable now' (R1/R2/H2-direction/D6).
- DECISIONS.md: record R1/R2/R3 as PROPOSED base refinements (code already conforms).
- docs/concept/07: fold in forward-looking acceptance criteria mapped across Slices 1-5.
…o 00-07; apply R1/R2

- ubiquitous-language.md is now the lean Evans glossary: terms, descriptor
  values, relations, a worked dialogue, flagged ambiguities, the term ledger.
  Terms and meanings unchanged - only their home. The header maps the old
  'base s-n' references for DECISIONS.md and plan history.
- Rehomed the only UL-unique exposition into the design docs: the discipline
  ~ kind/section mapping (06 s6), the UML alignment + constrainedBy/decidedBy
  granularity rationale (02 s6), spec-may-belong-to-many-packs (02 s4).
- Ratified + applied R1 (anchor = binding assertion only - glossary, 01, 04 s2)
  and R2 (source links OK, independent re-parse forbidden - 01 P2, 03 s4);
  DECISIONS.md R1/R2 flipped to ACCEPTED/applied.
- Re-aimed every pointer: AGENTS.md nav, concept README (glossary row),
  DECISIONS.md companion note + legacy D1-D6 table homes, live base-section
  refs in 03/06/07.
Implementation review, founding-ideation review, adversarial review + its
prompt, and the fold-session prompt - ~13h of review signal that previously
vanished on a clean clone (plans/04 s3 optional-archive step). README maps
each artifact to where its durable findings already landed.
…recorded, plans/03 slimmed to six

- docs/concept/04 s2 now shows the binding-only specTest signature the code
  already has (no executing run callback); DECISIONS R3 flipped to
  ACCEPTED/applied.
- DECISIONS.md gains the 2026-06-10 fold-session block: MD-8 (generic-anchor
  shape: one codeAnchor over impl/api/component; sibling builders rejected;
  execution Slice 2 / plan 02 H10) and MD-9 (open-questions canonical home =
  intent.openQuestions; execution stays plan 02 Wave B / H2).
- plans/03 slimmed to the six genuinely-open grill decisions (D1 D2 D3 D4 D7
  D8); the resolvable-now section collapsed to a folded-out pointer; base
  references re-aimed to the post-Fold-A homes (02 s1/s3, 05 s3, glossary).
- plans/02: header notes the 2026-06-10 folds; H2 direction decided (MD-9),
  H10 shape decided (MD-8); R-series marked ratified+applied; review pointer
  re-aimed to tracked reviews/; sequencing gains the done folds step.
- plans/04: status + s0/s3/s4 marked executed (Fold-A, Fold-B, archive);
  fold prompts marked executed; grill kickoff is the live prompt; s6
  resolvable-now ledger flipped to done with landing sites.
- AGENTS.md: DECISIONS row covers MD-1..MD-9 + R-series; reviews/ nav row.
…execution-ready

- DECISIONS.md: six grill resolutions ratified (content-only behavior sections,
  the typing law, kind-conditional evidence floor, table-as-truth, one validation
  path, .sdp.ts extension)
- Base reconciled inline: 02 (duality laws, typing law, no-status rule), 05
  (one-path rule; two-part floor + per-kind evidence table), 04/03/00/jtbd-01
  (.sdp.ts, content-only example), glossary (ledger updates)
- plans/03 = executed agenda-of-record with resolution table; plans/02 §4
  rewritten as four ordered Wave B steps (B1-B4); plans/04 marks the grill done
- Polish: .sisyphus untracked; package.json description + Apache-2.0
Consistency fixes:
- plans/02 H7: leftovers marked finalized (were done in the grill, still listed open)
- 02 $1/$3: model section aligned to the locked B1 shape (ModelSection, terms-only,
  richer concepts a named deferral) - was DomainModelSection/DomainConcept
- 04 $2: anchor snippet now points at the ratified MD-8 codeAnchor shape (Slice 2)
- AGENTS.md: status + 'where we are now' updated (Wave B next, then Slice 1)

Consolidation (no information lost - rationale lives in DECISIONS.md MD entries,
provenance in git history and reviews/):
- plans/01 -> executed stub keeping the two setup rationales (paths alias, examples/ home)
- plans/02 -> Wave A compressed to one-liners (handles + fixture inventory kept), header
  and sequencing de-dated; $4 Wave B contract untouched
- plans/03 -> agenda-of-record: resolution table + method + root tension ($2 kept as the
  MD-10/MD-11 citation target); per-decision detail folded into its MD entries
- plans/04 -> re-entry + frame + crippled-graph direction kept; executed fold/grill
  scaffolding and prompts stubbed; $6 decoder slimmed to the F-space map
…ded example, .sdp.ts (MD-9..MD-15)

B1: six floor-bearing sections closed-typed (MD-11 on MD-10); in-section
    honesty bypass fails typecheck, pinned as a compile-time fixture
B2: readiness-floor.ts is THE table (MD-12/MD-13): kind-blind clauses +
    per-kind evidence map, derived clause-id union, one generic evaluator;
    blocking open questions read intent.openQuestions (MD-9)
B3: example de-padded; promoted children are the floor evidence; GWT
    nested; no decision.status; fixtures re-authored + 4 new
B4: spec files renamed *.sdp.ts (MD-15)
F2/F3 backlog closed (ref() doc note; aggregate report carries no single
family). plans/02 retired to a done-record; plans/04, AGENTS, UL, 02, 07
status/wording reconciled. npm run check green.
…ed; runtime authoring-shape check; doc: targets named deferral

1. Floor (high): a promoted rule/example child counts only when it carries
   its kind's evidence; a constrainedBy edge counts only when it resolves
   to a constraint-kind spec with non-empty constraints[]. Empty stub
   children and wrong-kind edges no longer clear a parent's floor.
   Fixtures: invalid-defined-behavior-with-empty-promoted-child,
   invalid-scoped-behavior-with-non-constraint-constrained-by.
2. Honesty (medium): validateAuthoringShape is the Session-1 stand-in for
   05 §2 check 5 — delivery-fact keys smuggled into the envelope or any
   section (incl. via non-fresh objects past excess-property checking)
   now fail at runtime. Fixture:
   invalid-hand-authored-delivery-fact-in-section (runtime twin).
3. doc: targets (medium): explicit named deferral where the affordance is
   promised (02 §6, glossary, ids.ts/relations.ts notes); F2 stays closed
   as the doc-note it was scoped to be.
Recorded as DECISIONS MD-16; plans/02 + AGENTS updated. npm run check green.
…:'graph'; comments state invariants, not events
…05/07; AGENTS.md status -> one pointer at plans/; glossary header shrinks, base-§ map moves to DECISIONS.md
…-FOLD, D-table fold note, three-part test in working discipline, 'pre-graph' ratified in the glossary ledger
…poral tokens fail the gate; DECISIONS.md/plans/reviews exempt by genre
…ral type carries the value); plans/05 is now the sole 'what next' home
…laces !-negation; dedicated CI step (workflow never ran npm run check); all three exit paths verified
… genre exemptions; guard's own plan-ref comment removed; self-exemption is use-mention only
…e-mention (guard's own file is swept); plans/[0-9]+ un-caps the numbered-plan ban
…t most once; copied-regex smuggle and duplicated literal verified caught
…on (carried evidence, MD-16) not the review event; LICENSE (Apache-2.0) + package repository field land
… tsconfig paths — locally tsc resolved the self-import through exports -> stale dist/, which a fresh checkout (CI) never has; same idiom as tsconfig.examples.json and the vitest alias
@darko-mijic darko-mijic merged commit 58e2f89 into main Jun 10, 2026
2 checks passed
@darko-mijic darko-mijic deleted the feature/mvp-init branch June 10, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant