provenance follow-ups: decode written_by on read; promote leaves empty dir on refusal; partial multi-page ingest #151

Open
opened 2026-10-01 21:07:17 +00:00 by mathias · 0 comments
Owner

Follow-ups from the pr-gatekeeper review of #147 (round 4, merged as a6da933). None of these lets a caller forge provenance; each is reproduced by execution.

  1. The read side doesn't decode the written_by scalar. search.extractProvenance trims "' instead of decoding YAML. A JWT subject 'local-cli' is stamped written_by: "'local-cli'", and brain_query reports written_by=local-cli (origin stays jwt). Principal "local-cli" shows as \"local-cli\, and a\nb keeps its escape. brain_get's frontmatter map returns the raw quoted text. Fix: decode the value with yaml.v3 (or the shared parser) in both readers, and test with 'local-cli'.
  2. A refused promote leaves an empty wing directory. api.PromoteNote calls MkdirAll before StampProvenance. Repro: a principal that fails verify (JWT subject bad\xff), then brain_promote into a new wing; the source survives but wiki/<wing>/ is left behind. Same brain#21 invariant that writeHallNote now honours.
  3. Partial multi-page ingest. pipeline.buildAndWrite stamps and writes page by page. If a later page can't be stamped (e.g. an existing page on disk with an unclosable ---x fence), earlier pages stay written, each correctly stamped, and the call returns an error. Decide whether to stamp everything first and write after.

Source: #147

Follow-ups from the pr-gatekeeper review of #147 (round 4, merged as a6da933). None of these lets a caller forge provenance; each is reproduced by execution. 1. **The read side doesn't decode the written_by scalar.** `search.extractProvenance` trims `"'` instead of decoding YAML. A JWT subject `'local-cli'` is stamped `written_by: "'local-cli'"`, and brain_query reports `written_by=local-cli` (origin stays `jwt`). Principal `"local-cli"` shows as `\"local-cli\`, and `a\nb` keeps its escape. brain_get's `frontmatter` map returns the raw quoted text. Fix: decode the value with yaml.v3 (or the shared parser) in both readers, and test with `'local-cli'`. 2. **A refused promote leaves an empty wing directory.** `api.PromoteNote` calls MkdirAll before `StampProvenance`. Repro: a principal that fails verify (JWT subject `bad\xff`), then brain_promote into a new wing; the source survives but `wiki/<wing>/` is left behind. Same brain#21 invariant that writeHallNote now honours. 3. **Partial multi-page ingest.** `pipeline.buildAndWrite` stamps and writes page by page. If a later page can't be stamped (e.g. an existing page on disk with an unclosable `---x` fence), earlier pages stay written, each correctly stamped, and the call returns an error. Decide whether to stamp everything first and write after. Source: https://git.d-ma.be/mathias/hyperguild/pulls/147
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mathias/hyperguild#151