privfield

package
v1.18.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

This file exists so future exported symbols in the package can accrete documentation here without crowding the Redact contract in privfield.go. The authoritative package-level godoc lives on privfield.go.

Package privfield provides serializer-layer field-level privacy redaction. It composes with internal/privctx (row-level tier stamping) but operates one level lower: on a single field within an already-admitted row.

Use Redact at each API surface's response-assembly site, passing the pre-existing <field>_visible companion string stored on the ent row. Every surface MUST call Redact for every field guarded by a _visible companion; there is no centralised enforcement — it's a per-serializer discipline locked by the 5-surface E2E test in Plan 64-03.

Design decisions locked in Phase 64 CONTEXT.md:

  • D-01 serializer-layer redaction (not ent Policy)
  • D-02 reusable package (this one)
  • D-03 fail-closed on unstamped ctx
  • D-04 omit key entirely when redacted (caller uses json omitempty)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redact

func Redact(ctx context.Context, visible, value string) (out string, omit bool)

Redact returns (value, false) if the caller's tier on ctx admits the field, or ("", true) if the serializer should omit the field entirely.

Admission rules:

  • visible == "Public" → always admit (any tier)
  • visible == "Users" && tier Users+ → admit
  • visible == "Users" && tier Public → redact (the gated case)
  • visible == "Private" → redact in all tiers (upstream parity)
  • any unrecognised visible value → redact (fail-closed)

Fail-closed semantics: privctx.TierFrom(ctx) already returns TierPublic for un-stamped contexts, so an un-plumbed ctx naturally lands in the most restrictive branch — no extra check needed here.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL