Skip to content

fix(record): denied_policy claimed a check it never made - #57

Merged
jonioliveira merged 4 commits into
mainfrom
fix/denied-policy-naming
Sep 8, 2026
Merged

jonioliveira merged 4 commits into
mainfrom
fix/denied-policy-naming

Conversation

@jonioliveira

Copy link
Copy Markdown
Collaborator

What

Renames the outcome denied_policy to denied_by_harness_rule, and bumps the
record schema from 6 to 7.

Why

The value records the developer's own Claude Code permission rule refusing a
tool — reader.go reaches it from toolDenialKind: "permission-rule". The name
said policy, which in this product means the approved set, so a reader takes it
for a governance decision.

It is not one, and the gap is not theoretical. Wake was installed on a real
machine for the first time while investigating this:

  • 159 records carried denied_policy.
  • 100% of them were builtin_tool: Bash. None was a skill, subagent or MCP
    server — the categories governance is actually about.

Shipped to a client's sink, a dashboard row reading "policy denial" would look
like the governance layer working, and would be the developer's own permission
rule. A stored value whose name overstates the check it made is the defect
adr/0004 exists to prevent.

Why this is a schema bump

Same rule versions 4 and 5 used: no field is added, but a stored value changes
meaning, so a spool carrying the old one is refused on read and re-derived from
the harness's own history.

Nothing needs migrating by hand. The delivery watermark stamps the schema
version and starts over on a bump, so the wire is covered by the same mechanism.

Verification

  • make validate — clean.
  • Full suite: 23 packages ok, 0 failures. make lint — 0 issues.
  • Golden payload moves by four lines, all schema_version. No attribute key
    changes, so the frozen key set and the privacy allowlist over it are untouched.
  • Acceptance on real data: a rebuild re-derived all 31,288 records at
    version 7, with the 159 landing under the new name and delivery still off
    (delivered through: 0) — so no record under the old name ever left a machine.

Breaking

Anything grouping on the old string — a saved query, a dashboard panel — needs
updating. Called out under ## [Unreleased] → Changed.

Comment thread CHANGELOG.md Resolved
Comment thread internal/record/record.go Resolved
jonioliveira and others added 3 commits September 7, 2026 17:56
The value records the developer's own Claude Code permission rule refusing a
tool — reader.go reaches it from toolDenialKind "permission-rule". The name
said policy, which in this product means the approved set, so a reader takes
it for a governance decision. It is not one, and the gap is not theoretical:
of the 159 such records on the first machine Wake was installed on, every one
was a builtin Bash call. None was a skill, subagent or MCP server.

The outcome domain is part of the stored contract record.go refuses to pass an
unrecognised value through (ADR-0005, ADR-0007). Renaming it to
denied_by_harness_rule says what produced it.

Schema 6 -> 7 because the bump is the only thing that routes the old value to
the arm that can repair it. Validate checks the version before the outcome, so
without it a version-6 line carrying denied_policy matches SchemaVersion and
then fails validOutcome: Decode returns a plain "invalid outcome", never
ErrUnsupportedVersion. Store.Stale counts only the latter, so those 159 records
would be dropped by store.Entries, counted by no health.Scan.StaleRecords, and
never rebuilt. With the bump they are refused on read and re-derived from the
harness's own history. The delivery watermark stamps the version and starts
over on a bump, so nothing needs migrating on the wire — verified here by a
rebuild that re-derived all 31,288 records at version 7 with the 159 landing
under the new name.

This is not versions 4 and 5's rule: those cite ADR-0004 because both changed
how event_id is derived. A rename changes no id and adds no dimension.

The golden payload moves by four lines, all schema_version. No attribute key
changes, so the frozen key set and the privacy allowlist over it are untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The value changes on disk and on the wire, so anything grouping on the old
string needs updating. Filed under Changed rather than Fixed for that reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ADR-0004 is about id derivation: versions 4 and 5 cite it because both changed
how event_id is derived, and "a stored value whose name overstates the check"
is not a claim it makes. A rename changes no id and adds no dimension, so that
rule does not carry the bump.

What does carry it is mechanical and was missing. Validate checks the version
before the outcome, so without the bump a version-6 line holding denied_policy
matches SchemaVersion and then fails validOutcome: Decode returns a plain
"invalid outcome", never ErrUnsupportedVersion. Store.Stale counts only
ErrUnsupportedVersion, so those records would be dropped by store.Entries,
counted by no health.Scan.StaleRecords, and never rebuilt — the silent shrink
the paragraph below already warns about. The bump routes them through the
version arm instead.

The citation moves to ADR-0005/ADR-0007, which is how this file already cites
the rule that an unrecognised stored value is refused rather than passed
through.

The changelog said the store is re-derived "by the next scan", which overstates
what a hook-fired scan does. rebuildStaleSpool discards the version-6 spool
only at wholeHistory scope (internal/activation/boundary.go:181); Trigger runs
at consentedWindow and by design (ADR-0025) reports the count and leaves the
spool alone. A hooks-only install would therefore never rebuild, and the entry
told those users nothing needs migrating by hand, so they had no reason to run
the command that repairs it. It now names `wake ingest` and says what happens
if they skip it.

Comments and changelog prose only; no payload or key set is touched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jonioliveira
jonioliveira force-pushed the fix/denied-policy-naming branch from 8d00fea to d94fb86 Compare September 7, 2026 16:58
The rename lengthened one line to 97 characters where its neighbours sit near
75. No lint rule enforces a width here, so nothing failed; the words are
unchanged and only the line breaks move.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jonioliveira

Copy link
Copy Markdown
Collaborator Author

Both threads addressed — details in the replies on each. Summary of what landed:

cb8c4b8 reworded c0dae5c (rebase, force-with-lease; trees byte-identical at 84402c1)
d234e8f changelog commit, unchanged content
d94fb86 the two comment/changelog fixes
8281dee rewrap of one otlp.go line the rename left at 97 chars

Both reviews were right and both are applied. On the ADR citation I went with ADR-0005/ADR-0007 and stated the mechanism — version-checked-before-outcome, so without the bump those 159 records return "invalid outcome" rather than ErrUnsupportedVersion, which Store.Stale is the only thing counting. On the changelog I took the suggestion and added one sentence, because removing the false claim still left "nothing needs migrating by hand" reading as true of the store.

One thing neither review asked for, worth recording since only the compiler was checking it: git grep denied_policy on this head returns three hits, all deliberate prose naming the old value (CHANGELOG.md:14, record.go:36, record.go:46). git grep DeniedPolicy returns none. make validate proves every Go reference moved because a stale identifier would not compile — it proves nothing about a string literal in a dashboard template, a report label or an NDJSON fixture. There are none.

golden.json untouched: it holds no denied_policy (only denied_user, line 462), so the frozen key set and the privacy allowlist over it never came into this. All 11 checks green; make validate and make lint clean at 0 issues locally.

jonioliveira added a commit that referenced this pull request Sep 7, 2026
…fault

Synthetic fixtures choose their own key cardinality, and key cardinality is
what bounds a block — a generated spool with four skill names says nothing
about whether this is economical on real telemetry.

Measured on a real 21.9 MB spool of 32,032 records: 69 blocks totalling 218 KB,
1.00% of the spool. A view read 12 blocks plus 502 records instead of decoding
32,032. A repeated seal wrote and pruned nothing. Coverage complete.

The number that matters: 98 distinct (kind, name, outcome) keys across all
32,032 invocations. Real telemetry is far more repetitive than the fixtures, so
the design is more economical on real data than the synthetic numbers suggest.

Reads only what WAKE_TEST_SPOOL points at and writes only into t.TempDir(), and
skips when the variable is unset, so no fixture is committed and CI is not
gated. The doc comment says to point it at a copy.

Incidentally confirmed the schema refusal against real data: the live spool is
already at schema 7 from #57, and this build at 6 read a head of 0 rather than
misinterpreting 32,032 records — which is the behaviour ADR-0007 asks for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jonioliveira
jonioliveira merged commit ccb1d85 into main Sep 8, 2026
11 checks passed
@jonioliveira
jonioliveira deleted the fix/denied-policy-naming branch September 8, 2026 09:58
moraisjose added a commit that referenced this pull request Sep 9, 2026
Brings #57 (denied_policy -> denied_by_harness_rule) onto the epic.

Two conflicts, both from the same cause: #57 and DG-99 each bumped
SchemaVersion from 6 to 7 for an unrelated change.

- internal/record/record.go — resolved by giving the two changes two
  numbers. Version 7 stays the rename, which is what shipped on main;
  the mcp_server dimension becomes version 8. A version whose records
  two builds disagree about is the one thing the constant exists to
  prevent (ADR-0004, ADR-0007).
- internal/adapter/claudecode/reader.go — main renamed the constant,
  DG-100 changed outcomeFor's signature to return the unresolved half.
  Both kept.
- internal/adapter/claudecode/reader_test.go — auto-merge kept the epic's
  hunk, which still named the pre-rename constant. Renamed.
- internal/remote/testdata/golden.json — regenerated. The only difference
  is wake.schema_version 7 -> 8; the attribute key set is unchanged
  (ADR-0027, ADR-0030).
- CHANGELOG.md — the textual merge left two ### Changed headings under
  Unreleased and a schema claim of "6 to 7". Collapsed, corrected to
  6 to 8, and the mcp_server entry added.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants