Documentation
¶
Overview ¶
Package validate checks a block.manifest.json against the vendored JSON Schema plus structural project checks (manifest at root, build coherence).
Index ¶
Constants ¶
const ( // FieldDocument is the Field of a finding about the manifest AS A WHOLE: // the manifest is absent or unparseable, or the schema reports a violation // at the document root (a missing top-level required property is located at // the object that lacks it, not at the key that is not there). // // It is the literal the previous JSON output already used for schema root // errors, kept so existing consumers keep grouping the same way. FieldDocument = "(root)" // FieldProject is the Field of a finding about PROJECT STATE OUTSIDE the // manifest — the committed lockfile, the source tree. These are real // findings with no manifest field to name: the lockfile check reports on a // file that is or is not committed, and the ready-ack advisory reports on // what the browser loads. // // 🔴 It is a SECOND sentinel rather than reusing FieldDocument on purpose. // Both would be "not a manifest field", but they are not the same kind of // finding and a consumer routes them differently: `(root)` says "your // manifest document is wrong", `(project)` says "your repository state is // wrong, and no manifest edit alone fixes it". Collapsing them would tell a // CI job to go looking in block.manifest.json for a missing lockfile. // // Some of these findings DO offer a manifest edit as one remedy — the // lockfile error suggests setting `buildCommand` to match the lockfile you // already have — but the finding is not ABOUT that field, and pinning it // there would mis-group every project that takes the other remedy. FieldProject = "(project)" )
Variables ¶
var SENSITIVE_BLOCK_SCOPES = map[string]struct{}{
"ai:write:budgeted": {},
"social:tip:self": {},
"buzz:read:self": {},
"collections:read:private": {},
"apps:storage:shared:write": {},
}
SENSITIVE_BLOCK_SCOPES mirrors the server's single-sourced sensitive set (civitai → src/shared/constants/block-scope.constants.ts SENSITIVE_BLOCK_SCOPES): the scopes that can spend/read the viewer's Buzz, read their PRIVATE data, or write data other users see. A declared scope in this set MUST carry a non-empty scopeJustifications entry or the server rejects the manifest at submit — so this Go mirror fails the same manifests LOCALLY. Keep it byte-in- step with the server set; the sensitiveScopeJustificationError message is mirrored verbatim so CLI and server agree.
Functions ¶
Types ¶
type Finding ¶ added in v0.1.91
type Finding struct {
// Field is the manifest location this finding is about, in DOTTED notation
// (see the notation contract below). It is NEVER empty: a finding with no
// single natural field carries one of the two documented sentinels.
Field string
// Message is the COMPLETE human-readable line — byte-for-byte what the text
// renderer prints. It is deliberately not a reason fragment to be composed
// with Field: the semantic messages name their field inside prose
// ("iframe.sandbox MUST NOT combine …"), so composing would stutter, and
// the schema messages already carry a "<field>: <reason>" shape.
Message string
}
Finding is a single validation error or warning.
type Result ¶
type Result struct {
// Errors are hard failures: the server will reject the manifest. Non-empty
// Errors means validation failed.
Errors []Finding
// Warnings are non-fatal money-path / footgun advisories the schema can't
// express as hard errors (e.g. a budgeted page with no per-gen budget).
// They do not fail validation unless --strict is requested.
Warnings []Finding
}
Result is the outcome of validating a project directory.
Both slices hold Findings — a field PLUS a message — rather than bare strings. See finding.go for why (issue #225): the field has to be carried from where a finding is produced, because it cannot be recovered from prose afterwards.
func Dir ¶
Dir validates the App project in dir: the manifest checks PLUS the project-state checks that depend on files the AUTHOR maintains (currently the lockfile ↔ buildCommand consistency check — see lockfile.go).
func ManifestOnly ¶ added in v0.1.84
ManifestOnly validates just the manifest of the project in dir, skipping the project-state checks.
`civitai app init` / `app create` use it to self-check the template they just wrote. That self-check exists to catch a bug in OUR templates; a scaffold legitimately has no lockfile yet (the author's first `npm install` writes it), so failing there would turn an author-state issue into "internal error: scaffolded manifest failed validation". `civitai app validate` on that same directory still reports it — which is correct, because the app is not submittable until the lockfile is committed.
func (Result) HasWarnings ¶
HasWarnings reports whether any non-fatal advisories were emitted.