Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
design_ledger.hpp
Go to the documentation of this file.
1#pragma once
2
3// pulp::design — project design ledger.
4//
5// A DesignLedger is the small, CLI-maintained record of what a design/import
6// project has produced and where it stands: each emitted artifact as a named,
7// versioned asset with its source provenance, viewport, bound design system(s),
8// and a review status. It is the resumability + audit substrate for multi-day,
9// multi-agent design sessions — the answer to "which of these five ui.js
10// revisions did the human approve" lives in the ledger, not in chat.
11//
12// Discipline (borrowed intentionally): only the CLI writes the ledger; skills
13// and agents READ it (on resume, load the bound system's binding prompt without
14// re-asking; never silently regenerate an approved version). Keeping writes on
15// one path is what keeps the record trustworthy.
16//
17// This module is pure: parsing, serialization, and the in-memory operations
18// carry no file IO. The CLI supplies the bytes and, for reconciliation, a
19// predicate that answers whether an asset's file still exists on disk — so the
20// core stays unit-testable and the "ledger vs reality" policy lives in one place.
21//
22// The serialized form is deterministic: assets are sorted by (name, version)
23// and emitted in a fixed key order, so the ledger diffs cleanly in review.
24
25#include <functional>
26#include <optional>
27#include <string>
28#include <string_view>
29#include <vector>
30
31namespace pulp::design {
32
35inline constexpr std::string_view kDesignLedgerVersion = "2026.07-design-ledger-v1";
36
41
44const char* review_status_name(ReviewStatus status);
45
47std::optional<ReviewStatus> review_status_from_name(std::string_view name);
48
52 std::string name;
53 std::string version;
54 std::string path;
55 std::string inherit_from;
56 std::string source;
57 std::string viewport;
58 std::vector<std::string> design_systems;
60};
61
64 std::string ledger_version;
65 std::vector<LedgerAsset> assets;
66};
67
71DesignLedger parse_ledger(const std::string& json);
72
75std::string ledger_to_json(const DesignLedger& ledger);
76
82
85std::vector<std::string> remove_asset(DesignLedger& ledger, const std::string& selector);
86
90std::vector<std::string> reconcile(DesignLedger& ledger,
91 const std::function<bool(const std::string& path)>& exists);
92
93} // namespace pulp::design
Definition design_adherence.hpp:32
std::vector< std::string > reconcile(DesignLedger &ledger, const std::function< bool(const std::string &path)> &exists)
Drop assets whose file no longer exists, per the caller-supplied predicate (the "ledger vs reality" r...
std::optional< ReviewStatus > review_status_from_name(std::string_view name)
Parse a status slug; std::nullopt if it is not one of the three.
std::vector< std::string > remove_asset(DesignLedger &ledger, const std::string &selector)
Remove a specific asset.
constexpr std::string_view kDesignLedgerVersion
On-disk format id stamped into DesignLedger::ledger_version; bump on a non-additive shape change.
Definition design_ledger.hpp:35
ReviewStatus
Where an asset stands in review.
Definition design_ledger.hpp:40
@ needs_review
Definition design_ledger.hpp:40
@ approved
Definition design_ledger.hpp:40
@ changes_requested
Definition design_ledger.hpp:40
const char * review_status_name(ReviewStatus status)
Canonical lowercase slug for a status ("needs-review" | "approved" | "changes-requested").
LedgerAsset & upsert_asset(DesignLedger &ledger, const LedgerAsset &incoming)
Record or update an asset.
std::string ledger_to_json(const DesignLedger &ledger)
Serialize a ledger to deterministic JSON (assets sorted, fixed key order, design_systems sorted).
DesignLedger parse_ledger(const std::string &json)
Parse a ledger from JSON.
The whole project ledger: a format id plus the recorded assets.
Definition design_ledger.hpp:63
std::string ledger_version
kDesignLedgerVersion when compiled here
Definition design_ledger.hpp:64
std::vector< LedgerAsset > assets
sorted by (name, version) for clean diffs
Definition design_ledger.hpp:65
One recorded artifact revision.
Definition design_ledger.hpp:51
std::string source
provenance ("fig", "figma-plugin", "claude", …)
Definition design_ledger.hpp:56
std::string path
emitted artifact path (e.g. "ui.js")
Definition design_ledger.hpp:54
std::string inherit_from
parent version this revision derives from ("" = root)
Definition design_ledger.hpp:55
ReviewStatus status
Definition design_ledger.hpp:59
std::string name
logical asset name (e.g. "main-panel")
Definition design_ledger.hpp:52
std::vector< std::string > design_systems
bound design system(s) ("ink-signal", …), sorted
Definition design_ledger.hpp:58
std::string viewport
design viewport ("340x280"), "" if unknown
Definition design_ledger.hpp:57
std::string version
monotonic per name ("v1", "v2", …); assigned by upsert if empty
Definition design_ledger.hpp:53