Repository navigation
Conversation
The record log port now lives in internal/recordlog, as ADR-0091 decides: the Log port, its Reader and Stats, the Holding state whose zero value is unknown, the segment and manifest types, and the port's refusals. The package imports no file-system package. internal/segmentlog is the segments kind behind it: Open and Inspect take a recordlog.Config, refuse the zero kind, and read lines back through the directory handle the writer holds, failing the log on any mismatch. internal/trailfile names the kind in one place and reads export, cursors and reindex through the Reader; an unknown holding state is an error, never free. trail segments prints from Stats and says unknown where another process cannot see the writer's bounds. Conformance cases 10 to 13 join the port's suite, each with its negative control. Signed-off-by: Konrad Karauda <konrad@karauda.com>
…sees A segment others may write now fails a read-back in segmentlog and refuses a repeat in trailfile; both tests kill the mutant that swaps the checked open for a plain one. The import check drops a case that could only ever be an import cycle. Reader.Stats says which numbers are the writer's and unknown to a reader, never a measured zero. Signed-off-by: Konrad Karauda <konrad@karauda.com>
…ject An observation log is now a directory of segments under the record log port, bound to the tenant and project of the descriptor that made it and named by a random log id in a version 0.2 segments manifest. The single file observations.jsonl is still read and exported, never written: an import into its directory is refused, naming --log with a new directory. The byte bound refuses an append; guardana-gateway prune prunes an observation log as it prunes a trail. The observation export is version 0.2 for both forms: its header names pruned_before, a cursor's segment key folds in the log id, a cursor of a pruned segment is refused as expired and one of another log as another file. coverage and supervise refuse a log any of whose segments were pruned. The live segment is locked with segmentlog.Lock, so a second writer is refused with the directory's lock file gone. The findings log is not converted yet. Signed-off-by: Konrad Karauda <konrad@karauda.com>
…riter's refusal Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com> # Conflicts: # cmd/guardana-gateway/segments.go # internal/recordlog/port.go # internal/recordlog/segment.go # internal/segmentlog/errors.go # internal/segmentlog/port.go # internal/segmentlog/port_test.go # internal/segmentlog/view.go # internal/trailfile/log_holding_test.go
A log opened to prune holds the live file, so a reader that asks only the live file's lock finds the log held, and the record log refuses a live file its opener did not lock. Signed-off-by: Konrad Karauda <konrad@karauda.com>
supervise --findings writes a directory of segments through the record log port, bound to the supervised run's tenant and project, sealed at 64 MiB and refused past 1 GiB. A log of another project is refused, and so is a directory holding findings.jsonl, which is still read and exported but never written. The duplicate index covers the segments not pruned, and guardana-gateway prune prunes the log. react, notify and findings export read either form through one reader; react and notify state how many segments were pruned. notify reads its records and lines in one read and binds its state to the log id. findings export moves to 0.2: the header carries pruned_before, cursors over segments are keyed by segment and log id, and a cursor of a pruned segment is refused as expired. Signed-off-by: Konrad Karauda <konrad@karauda.com>
… keep the gates green A finding or report of another tenant or project is refused, each tested apart. The notify case moves to the unix test file it needs, scanLog returns only what its callers use, and three tests are split under the complexity bound. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Coverage and supervise read an observation log some of whose segments were pruned instead of refusing it: coverage names the source's log not whole and exits 1, supervise leaves the rules that rest on the source's reports not checked with the count as the reason. A removed descriptor whose log was pruned is refused, as what the pruned segments held is unknown. notify keeps the last sealed segment it read through in its state and exits 1 when a segment past it was pruned; react, which keeps no state, exits 1 whenever its log has pruned segments. The 0.2 manifest carries a required kind, observations or findings, set when the log is made and checked at every open and read, so a writer or reader of one kind refuses the other. Both exports stop before a record of another tenant or project than the log is bound to. A live segment opened shorter than read is read again, a tail whose live file changed size since the read is held, and segment files with no manifest are damage, never a directory with no log. A prune over a torn live segment names the step that mends it. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Keeps each function within the complexity bound; the kind test's config cases become their own test. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>
…otify mark ahead of its log A directory holding the single-file log and a live or sealed segment that no manifest names was read and exported as the single file alone. ReadDir and ExportDir of findings, ReadDir of observations, and an export of observations.jsonl by its path now refuse it as damage; the commands exit 2. notify accepted a mark above the log's last sealed segment, so a later prune of segments the state never read counted as read. After the log's identity is checked, such a state is refused as ahead of its log, naming a new, empty state directory and init as the step. Signed-off-by: Konrad Karauda <konrad@karauda.com>
A reader given neither a log id nor a kind read a 0.2 manifest of any kind, so trail export, trail and a scenario's trail read an observation or a findings log as a trail. Such a reader now refuses a log a log id or a kind names as ErrLogKind, unless it sets recordlog.Config.AnyKind, which a writer and a reader given a log id or a kind are refused. segmentlog.Prune and the gateway's prune and trail segments set it and take every kind. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Pages for ADR-0092: the observation log and the findings log are logs of segments of one tenant and project, pruned by an operator, exported as format 0.2, and a pruned log is read as not whole. The finding record, its log, notify and findings export move from supervision.md, which reached its word budget, to a new reference page, findings.md; links to the moved sections follow them. ADR-0092 is accepted and names the manifest's kind. Signed-off-by: Konrad Karauda <konrad@karauda.com>
…either kind findings.md, contracts.md and the CHANGELOG say what the last fixes changed: notify refuses a state ahead of its log, a single file beside segments no manifest names is damage, and trail and trail export refuse an observation or findings log as another kind of record. Signed-off-by: Konrad Karauda <konrad@karauda.com>
The egress access log page said the observation log is rotated by hand; a new log starts instead. Signed-off-by: Konrad Karauda <konrad@karauda.com>
observe export of a file named on its own judged its directory only when the file was called observations.jsonl, so a segment of a log was exported as a whole single-file log: pruned_before 0, the end reached at that segment's end, and no tenant or project binding. A file whose directory holds a log's manifest is now refused as a segment of that log, naming the directory to give instead, as trail export does; a file beside a segment no manifest names is damage, whatever its spelling. An export of a directory holding both a log of segments and the single file is now damage, as ReadDir and findings export find it. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Only a log of segments leaves a read-through mark, so a state marked over one and run over a single-file log was refused as a state ahead of its log, whose advice set up a new state over the wrong log. It is now refused as another log. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Observations.jsonl is another spelling of the single file only on a volume that folds case; on Linux the test skips, and the gate fails a skip the list does not name. Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>
…ngle file under a marked state is another log Signed-off-by: Konrad Karauda <konrad@karauda.com>
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed, and why
observe import --log <dir>andsupervise --findings <dir>use segmented logs like the evidence trail. Each log hassegments.json,live.jsonl, sealedsegment-NNNNNNNN.jsonlfiles andsegments.lock. Theguardana.control.segmentsmanifest is0.2and requireslog_idandkind(observationsorfindings).Segments seal past 64 MiB. Appends beyond 1 GiB of unpruned segments are refused without pruning. Prune explicitly with
guardana-gateway prune, as for trails.Import and supervise reject directories containing their legacy files (
observations.jsonlorfindings.jsonl), exit 2 and name the new directory option. The CLI only reads or exports legacy files. Each log is bound to its original tenant and project. A tenant or project mismatch exits 2. A mismatched record is damage. Missing log directories are created with mode0700after parent owner and sticky-bit checks.Both exports use format
0.2, withpruned_beforein the header and cursors bound to a segment and log ID. Exports reject pruned-segment cursors as expired and other logs' cursors as belonging to another file. An export stops before a record from another tenant or project, exits 2 and omits the trailer.log-read-through. It exits 1 if a later segment was pruned and rejects a mark past the log.Readers reject logs of the wrong kind, directories with segment files no manifest names, including beside a legacy file, and directories holding both forms.
observe exportjudges a file named by its path by its directory: a segment file is refused, naming the log's directory to export, astrail exportdoes. Notify refuses a single-file log under a state that marks a log of segments as another log.trailandtrail exportreject both kinds.trail segmentsandpruneaccept both.Invariant or record
This implements ADR-0092 and builds on ADR-0091, which moved the record log port to its consumers. The accepted ADR-0092 now specifies manifest
kind, incomplete-log and exit rules per reader, and export binding. Its backup and restore work follows in the next change.Readers report gaps after pruning and fail closed on damage.
How it was tested
live.jsonl, a findings reader read only the header and exported a whole, empty log. A trail export wrote a gap for a findings log and exited 1.observe export <log>/live.jsonlexported a segment as a whole single file, without the log's tenant and project binding, and exited 0.cmd/guardana-control(821) andcmd/guardana-gateway(920). Tests also passed ininternal/supervise(479),internal/docscheck(472),internal/coverage(362),internal/ingest/egresslog(218),internal/ingest/otelgenai(187),internal/trailfile(159) andinternal/gateway/e2e(132). Other passing packages wereinternal/observelog(123),internal/segmentlog(101),internal/findinglog(96),internal/notify(74),internal/lineexport(23),examples/refund-supervision(5) andinternal/recordlog(5). Round five's changed packages,internal/observelog,internal/notifyandcmd/guardana-control, passed again on macOS and on Linux.vettarget, vetting withtwoaccounts, macOS and Linux linting, formatting,check-sizes,check-brandanddocs-checkpassed.go.modor root in the test container cannot run there; they failed or were skipped, and the rest passed. Code inspection showedscenario run --trailrejects both kinds. No command-level test covered it. On the last head, the pre-push checks passed:vet, vetting withtwoaccounts, macOS and Linux linting, formatting,check-sizes,check-brand, thendocs-checkafter the last documentation change. The round-five Linux run predates its last two commits, a skip-list line and a message rewording. No race or localqualityrun. CI'squalityrun is the gate.Documentation
Moved the finding record, its log,
notifyandfindings exportfromdocs/reference/supervision.md(at its word budget) todocs/reference/findings.md. Updated links to the moved sections.Updated observations, coverage, supervision, reaction, CLI, versions (manifest and both exports), egress access log, contracts, status, glossary, privacy, the supervise-and-stop and egress-proxy guides, and the site. Updated links in ADR-0047, the upgrade-from-0.18 guide and the adapters page.
CHANGELOGlists upgrade steps underChanged. Use new, empty--logand--findingsdirectories per project. Use a new--statedirectory and runnotify --init. Move export readers to0.2. Of the 35 pagesdocs-impactflags, 18 changed. The other 17 were checked for the changed terms (the two logs, their exports,notify's state) and still hold.