Skip to content

Spec: make documentation drift control merge-enforced #117

Description

@marcusglee11

Objective

Make LifeOS documentation drift control merge-enforced instead of relying on operator discipline.

This is a spec / review issue only. Do not implement from this issue until the spec has been reviewed and converted into one or more build issues.

Background

Recent docs/wiki reconciliation made the documentation layer credible, but not yet robust. AA and OpenClaw independently agreed on the same core finding:

  • canonical docs must remain source of truth;
  • wiki/corpus surfaces are derived, not authority;
  • drift prevention needs machine-checkable metadata and merge gates;
  • sweeps should detect residual drift and open issues, not mutate authority state;
  • promotion into canon remains a human/AA governance decision.

Current weak points:

  • Manual bypass remains possible.
  • Wiki/corpus freshness checks are workflow knowledge, not necessarily merge blockers.
  • Reconciliation packet requirements are policy unless enforced.
  • Authority class labels are not consistently machine-checkable.
  • Local working-tree validation can lie; post-merge verification must run from clean origin/main.

Grill-me decision ledger

Decided

  • Goal: prevent canonical docs, generated corpora, and wiki surfaces from drifting after docs are updated.
  • Mechanism shape: small manifest/metadata + validator + merge gate + advisory sweep; no doc platform.
  • Authority model: canonical docs are source of truth; wiki/corpus are derived surfaces; proposal/deferred/discarded docs cannot be treated as canon.
  • Enforcement boundary: objective checks should fail closed in merge guard; subjective semantic review remains human/AA.
  • Sweep behavior: sweeps open evidence-backed reconciliation issues only; they do not auto-fix docs or promote authority.
  • Post-merge proof: verification receipts must run from clean origin/main, not the agent's dirty branch.

Rejected

  • Relying on policy text alone — too easy to bypass.
  • Pre-commit hooks as primary enforcement — bypassable and noisy.
  • Auto-promoting proposal docs into canonical docs — authority laundering risk.
  • Blocking merges on subjective quality/lint opinions — creates false blockers and workarounds.
  • Building a CMS/doc orchestration platform — wrong scale; Markdown + git + gates is enough.

Open for implementation design

  • Whether authority metadata lives as per-file YAML frontmatter, a central manifest, or both.
  • Exact file paths for validator/gate integration after repo inspection.
  • Whether noisy existing wiki/corpus lint should be advisory while freshness is mandatory.

Proposed spec

1. Authority registry / metadata contract

Create a machine-checkable authority contract for documentation surfaces.

Required authority classes:

  • canonical — source-of-truth docs.
  • derived — generated wiki/corpus/navigation surfaces.
  • proposal-only — design material that is not approved canon.
  • deferred — intentionally parked material.
  • discarded — explicitly non-operative historical material.

Minimum required fields for each tracked doc or doc group:

authority: canonical | derived | proposal-only | deferred | discarded
steward: <owner-or-role>
source_paths: []          # required for derived surfaces
derived_surfaces: []      # required/relevant for canonical docs
check_commands: []        # commands that prove freshness or classification
last_reviewed: YYYY-MM-DD # advisory, not a merge blocker unless policy later says so

Design choice to resolve during implementation:

  • Prefer a central manifest for cross-file relationships and generated surfaces.
  • Allow optional per-file frontmatter later if useful.
  • Do not require a bulk frontmatter migration before the validator/gate can exist.

Acceptance criteria:

  • All active architecture/doc surfaces are classified.
  • New architecture/doc files cannot be unclassified.
  • Derived surfaces name their canonical source path(s).
  • Canonical surfaces can declare expected derived outputs.
  • Proposal/deferred/discarded surfaces cannot be referenced as canonical by active docs without an explicit exception.

2. Reconciliation packet requirement for canonical-doc changes

Any PR that mutates canonical documentation must include a machine-detectable reconciliation packet or explicit machine-detectable exemption.

Minimum packet fields:

changed_canonical_paths: []
affected_derived_surfaces: []
regeneration_required: true | false
authority_class_changes: []
post_merge_verification_commands: []
not_affected_reason: <required if derived surfaces are declared unaffected>

Recommended packet location:

  • docs/10_meta/reconciliation_packets/<YYYY-MM-DD>-<slug>.md

Acceptance criteria:

  • Canonical-doc PR without packet fails merge gate.
  • Packet must name affected derived surfaces or justify why none are affected.
  • Authority class changes are visible and reviewable.
  • Packet is a review input, not a source of authority by itself.

3. Wiki/corpus freshness merge gate

Wire existing freshness checks into the merge path.

Required checks:

test ! -e .context/wiki/_refresh_needed
python3 scripts/wiki/refresh_wiki.py --dry-run
python3 -m doc_steward.cli wiki-lint .

Gate semantics:

  • Stale/missing generated outputs fail closed.
  • Dirty generated diffs after dry-run fail closed.
  • Known baseline quality/lint noise may be advisory if documented, but freshness cannot be advisory.
  • Derived surfaces must not be manually edited unless the PR records regeneration provenance.

Acceptance criteria:

  • A canonical-doc change that leaves wiki/corpus stale blocks merge.
  • A derived-output-only regeneration PR can pass without a new semantic reconciliation packet if it points to the canonical change it refreshes.
  • Baseline lint noise is separated from new drift introduced by the PR.

4. Local CI / merge guard integration

Add a docs drift gate to the approved merge path.

Minimum gate names, subject to existing repo conventions:

  • doc_authority_registry
  • doc_reconciliation_packet
  • doc_derived_freshness
  • doc_post_merge_receipt or equivalent post-merge command set

Acceptance criteria:

  • The merge guard fails closed on:
    • missing authority classification;
    • canonical-doc mutation without packet/exemption;
    • stale wiki marker;
    • dirty generated diff after refresh dry-run;
    • manual edits to derived surfaces without provenance.
  • The gate can be run locally and in the intended CI/merge path.
  • Failure output names exact file paths and the smallest recovery action.

5. Clean-origin post-merge verification receipt

After merge, verification must run from fresh origin/main.

Receipt fields:

repo: marcusglee11/LifeOS
base_ref: origin/main
verified_commit: <sha>
commands:
  - <command>
results:
  - command: <command>
    status: pass | fail
    summary: <short result>
dirty_worktree_after_verification: true | false
follow_up_issues_created: []
completion_claim: conductor_verified | failed | follow_up_required

Acceptance criteria:

  • Receipt proves validation used clean current origin/main.
  • If verification fails, the receipt names whether the failure is new drift, baseline noise, or tooling failure.
  • Follow-up wiki-only or drift-fix issues are opened when needed.

6. Scheduled advisory drift sweep

Add or extend a recurring maintenance sweep to detect drift outside the merge path.

Sweep should detect:

  • docs missing authority classification;
  • stale wiki/corpus derived surfaces;
  • orphan derived pages;
  • proposal-only/deferred/discarded docs linked as canon;
  • canonical docs changed without recent reconciliation packet;
  • derived surfaces edited manually without regeneration provenance.

Sweep behavior:

  • Open evidence-backed reconciliation issues.
  • Do not mutate canonical docs.
  • Do not promote or demote authority classes.
  • Deduplicate existing drift issues.

Acceptance criteria:

  • Sweep output is low-noise and actionable.
  • Each created issue includes exact paths, observed evidence, and recommended recovery.
  • Sweep can be safely run repeatedly.

Human / AA review points

Human or AA review remains required for:

  • promoting proposal-only / deferred content to canonical;
  • changing authority class of a document;
  • resolving semantic drift where generated text is fresh but misleading;
  • architecture authority disputes;
  • changes affecting COO/EA/AA authority boundaries, CEO approval semantics, or canonical operational state.

Automation may detect and report these cases but must not decide them.

Non-goals

  • Do not build a CMS, dashboard, web editor, database-backed doc store, or broad knowledge-management platform.
  • Do not auto-promote docs into canonical status.
  • Do not make subjective wording/lint quality a hard merge blocker until baseline noise is resolved.
  • Do not require every proposal doc to maintain fresh wiki/corpus derived outputs.
  • Do not treat wiki/corpus as authority.
  • Do not use this issue to implement code directly.

Proposed work packages after spec approval

WP1 — Authority registry contract

Define manifest schema, authority classes, and validator behavior.

Acceptance:

  • Current docs can be classified.
  • Validator fails on unclassified active architecture docs.
  • Validator reports exact recovery steps.

WP2 — Reconciliation packet gate

Define packet schema and detection rules for canonical-doc PRs.

Acceptance:

  • Canonical-doc PR without packet/exemption fails.
  • Packet fields are machine-parseable.
  • Exemption path requires explicit reason.

WP3 — Wiki/corpus freshness gate

Wire existing wiki/corpus freshness commands into merge guard / local CI.

Acceptance:

  • Stale derived surfaces block merge.
  • Baseline lint noise is separated from freshness failure.
  • Failure output is path-specific.

WP4 — Clean-origin post-merge receipt

Define and implement receipt generation after merge verification.

Acceptance:

  • Receipt proves clean origin/main verification.
  • Failed verification creates or recommends follow-up issues.

WP5 — Advisory drift sweep issue creator

Extend maintenance sweeps to detect and file drift issues.

Acceptance:

  • Sweep opens evidence-backed issues only.
  • Sweep deduplicates existing issues.
  • Sweep never mutates authority state.

Review questions

  1. Is the manifest-first approach correct, or should per-file frontmatter be mandatory from the start?
  2. Are the proposed mandatory gates objective enough to fail closed without excessive false positives?
  3. Is the reconciliation packet schema sufficient for canonical-doc PR review?
  4. Should wiki-lint be hard fail now, or should only freshness/dirty-diff checks be hard fail until baseline noise is measured?
  5. Are any authority transitions still automatable by accident?

Definition of done for this spec issue

  • AA/OpenClaw or equivalent review confirms the spec is implementable and safe.
  • Any blockers are incorporated into a revised operative spec comment.
  • Separate build issues are created for approved work packages.
  • This issue remains the design/control issue, not the implementation issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestops

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions