Documentation
¶
Overview ¶
Package reportjson is Pluto's canonical, versioned JSON codec for a Scorecard plus an optional profile.Result. It embeds each table's raw eval.Report as the bytes produced by eval's own reportjson.Encode — already redacted and canonical — so this codec adds no additional lossiness of its own beyond what eval's codec already imposes. Decode is the untrusted deserialization boundary: unknown fields and an unknown version are rejected fail-closed, and the input is size-bounded before it is parsed.
Index ¶
Constants ¶
const MaxReportBytes = 64 << 20 // 64 MiB
MaxReportBytes bounds a document at the untrusted decode boundary, mirroring eval/reportjson.MaxReportBytes.
const Version = "pluto-report/v1"
Version is the sole wire version this codec implements. It is read FIRST from every document; an unknown or missing version is rejected before the payload is trusted (fail-closed).
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode serializes card and the optional profile result to the canonical pluto-report/v1 wire form. It validates card.Manifest first, so a structurally invalid manifest is rejected before any encoding work happens, then computes the dimension scores and status rollup (each of which itself fails on an empty Scorecard), then embeds each non-skipped table's raw report as the bytes eval's own reportjson.Encode produces. result may be nil; the wire form then omits the profile entry entirely. Encode is deterministic: the same card and result always produce identical bytes.
Types ¶
type Decoded ¶
type Decoded struct {
Version string
Manifest qual.Manifest
Fingerprint string
Dimensions []qual.DimensionScore
StatusRollup qual.StatusRollup
Tables []DecodedTable
Profile *profile.Result
}
Decoded is the strict reconstruction of one encoded document.
func Decode ¶
Decode reads a pluto-report/v1 document. It is the untrusted boundary: enforced in order, the size bound, valid UTF-8, exactly one JSON value (no trailing data), strict envelope decoding (no unknown fields), a known version, strict payload decoding (no unknown fields), and finally domain reconstruction — the manifest is re-validated, and each non-skipped table's embedded report is decoded via eval's OWN reportjson.Decode, which yields the redacted projection (zero Observation, empty Finding.Message).
type DecodedTable ¶
type DecodedTable struct {
Pack, Table, Dimension eval.Name
Skipped bool
Missing []qual.Capability
Report eval.Report
}
DecodedTable is one table entry's reconstruction. Report is the zero eval.Report when Skipped is true; otherwise it is the REDACTED projection eval's own reportjson.Decode returns (zero Observation, empty Finding messages) — see eval/reportjson's package doc.
type EncodeError ¶
type EncodeError struct {
Cause error
}
EncodeError reports that a scorecard could not be serialized. Cause is exposed via Unwrap.
func (*EncodeError) Error ¶
func (e *EncodeError) Error() string
func (*EncodeError) Unwrap ¶
func (e *EncodeError) Unwrap() error
type InvalidReportError ¶
type InvalidReportError struct {
Cause error
}
InvalidReportError reports that a decoded document was well-formed JSON but a reconstructed part failed domain validation. Cause is exposed via Unwrap so callers can classify it further (for example as an *qual.ValidationError).
func (*InvalidReportError) Error ¶
func (e *InvalidReportError) Error() string
func (*InvalidReportError) Unwrap ¶
func (e *InvalidReportError) Unwrap() error
type MalformedReportError ¶
type MalformedReportError struct {
Reason string
}
MalformedReportError reports that the bytes were not exactly one well-formed pluto-report/v1 document. Reason is drawn only from the fixed vocabulary above, so no untrusted content leaks.
func (*MalformedReportError) Error ¶
func (e *MalformedReportError) Error() string
type ReportTooLargeError ¶
ReportTooLargeError reports that a document exceeded MaxReportBytes. Only safe integers are carried; no content is embedded.
func (*ReportTooLargeError) Error ¶
func (e *ReportTooLargeError) Error() string
type UnknownVersionError ¶
type UnknownVersionError struct {
Version string
}
UnknownVersionError reports that a document's version discriminator was missing or names a wire version this codec does not implement. The version token may originate from untrusted input, so it is bounded and withheld when hostile; Version is either a short, valid token or "" when redacted.
func (*UnknownVersionError) Error ¶
func (e *UnknownVersionError) Error() string