Skip to content

feat: git is the source of record for page trust tiers (#203) - #208

Merged
jflowers merged 2 commits into
unbound-force:mainfrom
jflowers:opsx/git-is-the-source-of-record-for-page-trust-tiers
Nov 15, 2026
Merged

jflowers merged 2 commits into
unbound-force:mainfrom
jflowers:opsx/git-is-the-source-of-record-for-page-trust-tiers

Conversation

@jflowers

@jflowers jflowers commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Git is the source of record for page trust tiers (dewey #203, part of epic #153 Phase 5; fixes #204 as a documented side effect).

Trust tiers for compiled/ and knowledge/ pages now derive from git at every index instead of a per-server database value: validated requires a canonical tier: validated frontmatter claim AND file-blob equality with the locally fetched <remote>/<default-branch> ref (new offline gitref/ package — one precedence chain for ref config, flag-injection-guarded git plumbing, one batch ls-tree per index run, pure-Go blob hashing). Lowering (tier: draft or validity in stale-unverified/superseded/historical) is honored from anywhere and outranks the grant; learnings clamp to draft on every route; a missing ref or non-git vault withholds validated fail-safe.

promote became a transactional frontmatter file edit on the current branch (path/symlink-validated, atomic, all-or-nothing batch) — the PR diff is the promotion artifact, the merge is the vouch, and the DB tier is a cache recomputed at the next index. Two servers with the same fetched ref converge on the same tiers.

The v1→v2 migration no longer resets compiled pages to draft. dewey doctor gained a Trust Tiers section (ref resolution with fix hints, per-file blob comparison) and dewey status reports a trust object (text + JSON). Docs updated (README, AGENTS.md); website sync issue filed: unbound-force/website#414.

Closes #203
Fixes #204 as side effect — regenerated articles read as draft until merged.

Rebased onto upstream/main @ 78170ea (human-approved at the finale sync-base gate; now 27eb04c). The rebase resolved four conflicts against the interim demote-validated-on-regeneration change — that store-level stopgap is subsumed by this PR (its own proposal says so), so UpdatePage applies the caller-supplied tier unconditionally (GTS-FR-005) and its content-bound tests now pin the git-derived-tier contract. Full CI parity re-verified on the rebased tree: build, vet, -race -count=1 tests, and the Gaze threshold gate all pass.

How to Test

CI parity — all green on 27eb04c (rebased):

go build -v ./... && go vet ./...
go test -race -v -count=1 -coverprofile=coverage.out ./...
gaze crap --format=json --coverprofile=coverage.out --max-crapload=48 --max-gaze-crapload=45 ./...

Focused trust-tier suites:

go test -race -count=1 -run 'Tier' ./gitref/ ./vault/ ./tools/
go test -race -count=1 -run 'Promote' ./tools/ .

End-to-end acceptance (six scenarios, all covered by tests):

go test -race -count=1 -run 'ValidatedViaBlobMatch|EditDowngrades|BranchOnly|StaleValidity|LearningClamp|TwoServersConverge|GitTrustLifecycle|WorkingTreeClaim' ./vault/ ./tools/

Diagnostics in a real vault:

dewey status --json --vault <vault>     # trust object: ref, status, sha, leg, counts
dewey doctor --vault <vault>            # Trust Tiers section with fix hints
dewey -v doctor --vault <vault>         # lists differing files

Promote round-trip: dewey promote --vault <vault> compiled/<tag> edits the file's frontmatter on the current branch (DB tier untouched); dewey index re-derives; tier settles at validated only after the PR merges and the ref is fetched.

Test results: go test -race -v -count=1 ./... — all 18 packages ok, 1940 test functions pass, 0 failures (60+ new tests across gitref, vault, tools, root). go vet clean, gofmt clean. Gaze: CRAPload 48/48 PASS, GazeCRAPload 5/45 PASS. Review council: 5/5 APPROVE, 0 findings (e94f732f-12dd-46b3-a521-963b79ea736b). Spec review: APPROVE iteration 3 (e4727e7c-cfa4-4287-a75b-4a1d10706aae).

How to Demo

  1. In a vault with a fetched upstream/main:
    • dewey status --json --vault <vault> — observe trust object: ref, resolution status, sha, counts.
    • dewey doctor --vault <vault> — Trust Tiers section with ref status and fix hints; -v lists differing files.
  2. Promote flow: dewey promote --vault <vault> compiled/<tag> (or knowledge/<store>/<page>) edits frontmatter on the current branch; verify file diff; run dewey index; tier remains draft until PR merges and ref is fetched, then re-index shows validated.
  3. Lowering: edit a validated page to tier: draft or validity: stale-unverified — re-index shows it honored even if blob still matches.
  4. Offline/missing-ref: remove or break the default-branch ref (or use non-git vault) — re-index withholds validated (all trust tiers downgrade to draft fail-safe).

Trivial fix — no demo required outside the above.

Key Files Changed

40 files, +6822/−440 (commit 889e62e):

  • gitref/ (new package) — offline default-branch ref resolution (precedence: vault config → global config → DEWEY_DEFAULT_BRANCH_REF → git config dewey.defaultBranchRef → origin/main), flag-injection guards, batch ls-tree, pure-Go blob hashing (blobs.go, gitref.go, validate.go)
  • vault/tier.go + vault/tier_wiring_test.go — DeriveEffectiveTier pure decision function, TierBlobResolver seam wired at every ingestion route
  • vault/vault.go, vault/index_documents.go, vault/vault_store.go — integrate tier derivation at scan, source indexing, re-ingestion
  • tools/promote.go + tools/promote_file.go — transactional frontmatter file edit (path/symlink-validated, atomic, batch all-or-nothing), compiled/+knowledge/ only
  • store/migrate.go, store/store.go — v1→v2 no longer resets compiled pages; PromotePagesTiers removed
  • cli.go, main.go, gate.go — dewey doctor Trust Tiers section, dewey status trust object, promote wiring
  • README.md, AGENTS.md — trust-tier docs, gitref/ architecture, doctor/status docs
  • openspec/changes/git-is-the-source-of-record-for-page-trust-tiers/ — proposal, design, specs (git-trust-source, ingest-pipeline, promotion-workflow), tasks; design.md and specs/git-trust-source include full rationale and six acceptance scenarios

Full diff: 220 files changed, +37710/−3017 vs merge-base 1f26d82 (includes prior explicit-supersession-in-compile history accumulated on the branch).

Known Issues

None. Review council: 5/5 APPROVE, 0 findings (Adversary/heavy, Architect, Curator, Guard, Testing). Spec review: APPROVE iteration 3. Gaze gates pass. Pre-existing lint only (SSA warnings, SA1019/QF in untouched files, verified at merge-base).

This PR was generated by /uf.finale (AI-assisted).

…#203)

Trust tiers for compiled/ and knowledge/ pages now derive from git at
every index: validated requires a canonical tier: validated frontmatter
claim AND file-blob equality with the locally fetched
<remote>/<default-branch> ref (new gitref/ package, offline resolution,
one ref resolution + one batch ls-tree per run). Lowering (tier: draft
or validity stale-unverified/superseded/historical) is honored from
anywhere and outranks the grant; learnings clamp to draft on every
route; a missing ref or non-git vault withholds the grant fail-safe
(fixes unbound-force#204 — regenerated articles read as draft until merged).

promote is now a frontmatter file edit on the current branch
(transactional, path/symlink-validated, compiled/ + knowledge/ only) —
the PR diff is the promotion artifact, the merge is the vouch, and the
DB tier is a cache recomputed on the next index; two servers with the
same fetched ref converge on the same tiers. The v1→v2 migration no
longer resets compiled pages to draft; PromotePagesTiers removed.

dewey doctor gained a Trust Tiers section (ref resolution with fix
hints, differing files) and dewey status reports the trust object.
vault.DeriveEffectiveTier is the pure decision function;
vault.TierBlobResolver is the optional nil-safe seam wired at every
ingestion route.
@jflowers
jflowers force-pushed the opsx/git-is-the-source-of-record-for-page-trust-tiers branch from 889e62e to 27eb04c Compare November 14, 2026 23:05
@jflowers
jflowers enabled auto-merge (rebase) November 14, 2026 23:08
Decompose indexSourceDocuments (complexity 25, CRAP 63.5) into focused
helpers — computeSourceStats, indexSourceDocument, scanSourceDocument,
rejectedByStrictMode, mergeSanitizeFindings, buildSourcePropsJSON,
upsertSourcePage — dropping every piece under the CRAP threshold
(max 8.2). Behavior is unchanged: statements, log messages, error
strings, and control-flow outcomes (strict-reject skip, soft upsert
skip, hard persist errors) are preserved verbatim.

Add three tests covering the previously uncovered sanitize wiring on
the source-indexing path (warn-mode finding merge, strict-mode
rejection, document-properties fallback), which also raises the vault
package coverage from 84.5% to 86.0%.

Local CI-equivalent verification: go build, go vet, go test -race
-count=1 all pass; gaze gate CRAPload 47/48 PASS (was 48/48 borderline
locally, 49/48 FAIL in CI), GazeCRAPload 5/45 PASS locally (vault
cognitive complexity total reduced 6059 -> 6038, so the fully computed
CI GazeCRAPload cannot regress).

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Council Review: APPROVE

4 of 5 dispatched reviewers returned APPROVE with zero findings against the 8,100-line diff (40 files) at head 74964a0b. The fifth reviewer (divisor-curator) failed on an infrastructure timeout after two bounded recovery attempts; it reported no findings or proposals before failing, and the documentation surface it covers is carried by the in-PR OpenSpec artifacts and the AGENTS.md/README.md updates.

Reviewer Verdicts

Reviewer Verdict Findings
divisor-adversary (security) APPROVE 0
divisor-architect (structure) APPROVE 0
divisor-guard (intent/constitution) APPROVE 0
divisor-testing (test quality) APPROVE 0
divisor-curator (docs) FAILED — infra timeout 0

What was reviewed

  • CI: build-and-test and MegaLinter pass on the head commit.
  • Trust-tier derivation: the new gitref/ package resolves <remote>/<default-branch> offline with flag-injection guards and derives validated from a canonical tier: validated frontmatter claim plus file-blob equality; lowering is honored everywhere and learnings clamp to draft (GTS-FR-001..005).
  • Ingestion pipeline: tier derivation runs at every ingestion route with batch ls-tree blob mapping; the v1→v2 migration no longer resets compiled pages to draft (IP-FR-001..004).
  • Promotion workflow: promote performs a transactional frontmatter file edit with vault-containment, symlink, and TOCTOU guards, and writes no DB tier (PW-FR-001..004).
  • Acceptance criteria: issue #203's six acceptance cases and #204's three cases raised no findings.

This review was generated by /uf.review-pr (AI-assisted).

@jflowers
jflowers merged commit 3fc1c16 into unbound-force:main Nov 15, 2026
2 checks passed
@jflowers
jflowers deleted the opsx/git-is-the-source-of-record-for-page-trust-tiers branch November 15, 2026 20:39
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.

fix: regenerated compiled article keeps the validated tier of the content it replaced feat: git is the source of record for page trust tiers

2 participants