Skip to content

[Constitution] Alignment principle + CI guardrails (addresses b87992f drift)#20

Merged
dtzp555-max merged 3 commits intomainfrom
feat/alignment-constitution
Apr 20, 2026
Merged

[Constitution] Alignment principle + CI guardrails (addresses b87992f drift)#20
dtzp555-max merged 3 commits intomainfrom
feat/alignment-constitution

Conversation

@dtzp555-max
Copy link
Copy Markdown
Owner

Background

On 2026-04-11, commit b87992f ("fix: use dedicated /api/oauth/usage endpoint for reliable plan data") was merged. The commit message asserted that /api/oauth/usage was "the dedicated usage endpoint that Claude Code CLI uses." This was false — the string does not appear in cli.js at any shipped Claude Code version. The endpoint was fabricated by an LLM-assisted authoring pass that generalized from adjacent OAuth paths without grepping cli.js. A follow-up (cb6c2a8) compounded the error by caching the fabricated responses. The dashboard /usage progress bar was broken for nine days.

This PR is PR A of the remediation. It is governance-only: it establishes the constitution that makes the drift structurally impossible to repeat. It does not modify any runtime code.

Files in this PR (4)

  1. ALIGNMENT.md — OCP project constitution.

    • Core principle: OCP is a proxy layer for Claude Code, not an extension layer.
    • Five binding Rules: (1) grep cli.js first, (2) no invention, (3) match the implementation, (4) unalignable features are deleted, (5) commits cite cli.js line numbers.
    • Golden reference paths per machine + annual audit pin slots.
    • Historical Lesson section: the 2026-04-11 drift, recorded in full.
    • Unalignable Policy: deletion, not deprecation.
    • Annual Alignment Audit fixed to 11 April each year (the drift anniversary).
  2. CLAUDE.md — project-level session instructions.

    • Flags ALIGNMENT.md as required reading before any code.
    • Three hard requirements for every server.mjs PR: cli.js citation, CI blacklist pass, independent reviewer (Iron Rule 10).
    • References CC 开发铁律 v1.3 Rules 10, 11, 12.
  3. .github/PULL_REQUEST_TEMPLATE.md — mandatory alignment-evidence section.

    • Three author checkboxes (cli.js citation, scope justification, commit-message citations).
    • Reviewer checklist requires opening cli.js at cited lines before approval.
    • Blank section = automatic request-changes.
  4. .github/workflows/alignment.yml — CI guardrails.

    • Hard fail: grep server.mjs for blacklisted tokens (api/oauth/usage, api/usage). Scan is restricted to server.mjs; ALIGNMENT.md and CLAUDE.md are allowed to quote the tokens as historical references.
    • Soft check: scan PR commit messages for "Claude Code uses X" / "cli.js uses X" assertions lacking a cli.js:NNNN or cli.js vE4 <fn> citation; emits warnings for reviewer enforcement.

Historical Lesson (summary)

Field Value
Drift commit b87992f (2026-04-11)
Fabricated token /api/oauth/usage (not in cli.js)
Compounding commit cb6c2a8 (cached the 4xx away)
Impact window 9 days, /usage bar broken
Root cause LLM hallucination accepted without grep cli.js; no CI blacklist; no constitution
Remediation PR A (this PR) + subsequent code-layer PR(s)

Merge preconditions

  • Reviewed by an independent opus reviewer (not the drafter). Iron Rule 10.
  • Reviewer confirms the historical record in ALIGNMENT.md matches the git log for b87992f and cb6c2a8.
  • Reviewer confirms the CI blacklist scope is correct (scans only server.mjs; does not false-positive on documentation).
  • This PR is kept draft until all of the above are satisfied; then converted to ready for merge.

Out of scope (explicitly)

  • No changes to server.mjs.
  • No changes to package.json version (constitutions do not bump versions).
  • Deletion of the fabricated /api/oauth/usage code path in server.mjs is deferred to a follow-up PR (PR B), which will land under the rules this PR establishes.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@dtzp555-max dtzp555-max marked this pull request as ready for review April 20, 2026 03:11
Oracle Public Cloud User and others added 2 commits April 20, 2026 03:13
…ils (PR A)

Introduces the OCP project constitution to structurally prevent the kind
of scope drift that produced commit b87992f on 2026-04-11 (the fabricated
"/api/oauth/usage" endpoint, which does not appear in cli.js and broke
the dashboard usage bar for nine days).

This PR is governance-only. It does not modify server.mjs, package.json,
or any runtime code. It is intentionally shipped as one reviewable unit
per Iron Rule 11 (governance is one layer).

Files added:
  - ALIGNMENT.md
      Supreme scope document. Core principle: OCP is a proxy layer for
      Claude Code, not an extension layer. Five binding Rules: grep
      cli.js first; no invention; match the implementation; unalignable
      features are deleted; commits cite cli.js line numbers. Includes
      the 2026-04-11 drift postmortem, the Unalignable Policy, and an
      Annual Alignment Audit fixed to 11 April each year.

  - CLAUDE.md
      Project session instructions. Flags ALIGNMENT.md as required
      reading before any code. Codifies three hard requirements for
      server.mjs changes: cli.js citation, CI blacklist pass, and an
      independent reviewer per Iron Rule 10. References CC 开发铁律
      Rules 10, 11, and 12.

  - .github/PULL_REQUEST_TEMPLATE.md
      Mandatory "Claude Code Alignment Evidence" section. Three author
      checkboxes (cli.js citation, scope justification if cli.js does
      not perform the op, commit-message citations). Reviewer checklist
      requires opening cli.js at the cited lines before approval. A PR
      with this section blank receives request-changes.

  - .github/workflows/alignment.yml
      Hard-fail blacklist on server.mjs for tokens "api/oauth/usage"
      and "api/usage" (scan restricted to server.mjs; ALIGNMENT.md and
      CLAUDE.md may quote them as historical references). Soft check
      over all PR commit messages for "Claude Code uses X" / "cli.js
      uses X" assertions lacking a cli.js:NNNN or cli.js vE4 <fn>
      citation.

Historical reference: b87992f ("fix: use dedicated /api/oauth/usage
endpoint for reliable plan data") asserted the endpoint was used by
Claude Code CLI. The string does not occur in cli.js. Root cause was
LLM hallucination accepted without grep verification. See ALIGNMENT.md
-> Historical Lesson for the full record.

Merge precondition: this PR must be approved by an independent reviewer
(Iron Rule 10). The drafter of this commit may not self-approve.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…6 a9950ef6)

First annual alignment audit pin. Records the cli.js version and content
hash that the current ALIGNMENT.md codified implementations mirror.

- Claude Code version: 2.1.89
- cli.js SHA-256: a9950ef6407fdc750bddb673852485500387e524a99d42385cb81e7d17128e01
- Audit date: 2026-04-20
- Auditor: Tao Deng

Next audit: 2027-04-11 (drift anniversary).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dtzp555-max dtzp555-max force-pushed the feat/alignment-constitution branch from 01518a9 to 80014b9 Compare April 20, 2026 03:13
…fore grep

Two false positives discovered during PR #20 bootstrap CI:
1. /api/usage is a legitimate OCP dashboard route (per-key quota, added
   in v3.8, server.mjs:1472). The bare token "api/usage" was too broad.
2. The ANCHOR warning comment in server.mjs (added by PR #21) references
   /api/oauth/usage as a DO-NOT-USE example, triggering the scanner.

Fix: require full host "api.anthropic.com/api/oauth/usage" to ensure
only real outbound fetch calls trip the guard, and strip line comments
with sed before grep so historical ANCHOR warnings pass.

Amendment procedure (ALIGNMENT.md) still governs future blacklist
changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dtzp555-max dtzp555-max merged commit 2853088 into main Apr 20, 2026
2 checks passed
@dtzp555-max dtzp555-max deleted the feat/alignment-constitution branch April 20, 2026 03:15
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