Repository navigation
Description
Umbrella: #14222
Summary
Collect a bounded native-log incident window. Deliver one usable operation, not a framework-only foundation.
Boundary
Proposed activation caller: bydbctl rca collect --source=native-log. Command names are proposed, not existing APIs.
Reporter collection runs with read-only source access; offline steps use local files only.
No source storage/wire-format changes are requested. The incident format is separately versioned.
Requirements
R1. Reuse the ordinary stream query API for _monitoring_log/log; require UTC start/end, selected nodes, levels, output path, byte budget and deadline. Do not enable logging or modify a cluster.
R2. Persist a private local workspace with schema version, collection interval, source status, hashes and tool build information. Decode searchable tags and binary JSON data.fields without dropping unknown fields; preserve source log_id.
R3. Query one bounded time/node/level selection and filter module/message locally. No adaptive time subdivision or automatic pagination. Mark coverage partial or unknown when scan limits prevent proving completeness, including timestamp ties.
R4. Bound per-query rows, cumulative bytes and elapsed time; no automatic retries in this first slice; record missing schema, unreachable nodes, truncation separately from an empty successful query. Verify retrieved rows rather than trusting producer written counters.
Acceptance criteria
- A hand-authored three-row fixture includes two rows with the same timestamp, a nested secret in data.fields, and a module predicate whose server-side limit would hide a match. For an unsaturated fixture assert exact IDs and decoded fields; for a saturated fixture require an explicit partial/unknown status, never complete.
- Invoke the real CLI against the native-log E2E deployment, then with an absent schema and an unavailable endpoint. Assert no server writes/config changes, bounded termination, private files, and a truthful manifest.
- Interrupt a collection: no complete marker may be left. Existing stream query commands remain unchanged.
- Use hand-authored or independently captured fixtures with documented provenance; do not generate expected values using the code under test.
- Add focused behavioral tests before implementation and record the actual RED command/failure, then GREEN results.
- Keep existing CLI/API behavior compatible. Never overwrite unrelated user files; output conflicts must be refused.
Scope and readiness audit
- Boundary and behavior: the single operation above; independently observable output and refusal behavior.
- Production activation: the named CLI or skill entry point above, included in the same PR.
- Packages/callers: bydbctl/internal/cmd/root.go and stream.go; new internal RCA collector package; existing native-log E2E fixtures.
- Dependencies: None; first implementation candidate.
- Classification: initial leaf candidate, NOT automation-ready until contract/RED audit.
- RED evidence: not executed during this planning task; no claim of passing or failing implementation tests.
- End-to-end proof: the real command/skill scenarios above, not source-text assertions.
- Formats/lifecycle/fixtures: private workspace or public archive only; artifact-specific fixture family above.
- Focused tests: CLI leaves should add
TestRCA…coverage underbydbctl/internal/cmdand/or the introduced collector package;
rungo test ./bydbctl/internal/cmd -run TestRCA -count=1plus the new package tests. Skill leaves must add a replayable evaluation harness
with an exact command documented in the PR. Final test names/paths are fixed when the prerequisite seam merges. - Resource/concurrency checks: cancellation, bounded reads/output and cleanup on failure; use repository panic-aware goroutine wrappers if concurrency is introduced.
- Decision: one proposed PR. If the named behavior requires an unimplemented server API or another lifecycle change, stop and split that prerequisite.
Required-only scope audit
Bounded export is required; exhaustive historical recovery is not.
Removed/deferred: Adaptive window splitting, automatic pagination, additional drop-metric endpoint collection, configurable retry engines and automatic resume.
Out of scope
Query-trace storage, schema changes, native receiver bug fixes, redaction, public archives, Kubernetes installation.
Concrete verification and closure gate
These are required acceptance tests, not examples that may be skipped. Artifact filenames and unsupported format handling must follow the merged prerequisite contracts. Before queueing, fix the tested schema version, configured limits, observable statuses and independent expected values; record any necessary interface decision in this issue rather than leaving it to an agent mid-run.
Fixed acceptance scenario
Use three independently authored native-log rows with IDs L1/L2/L3 inside [10:00, 10:05) UTC and a fourth outside. L2/L3 share a timestamp; one contains a nested data.fields value. With adequate limits, assert exactly L1/L2/L3 and the expected decoded values. With a two-row scan cap, assert partial/unknown coverage, never complete. Exercise absent schema, an unreachable endpoint and cancellation; no completed manifest marker or cluster mutation is allowed.
Executable regression
Proposed named regression: TestRCANativeLogCollect in bydbctl/internal/cmd exercising the registered command through an existing CLI test seam.
After normal repository generation, use:
go test ./bydbctl/internal/cmd -run '^TestRCANativeLogCollect$' -count=1 -v
make test-ci PKG=./bydbctl/internal/cmdThe exact selector must execute at least one test, not return “no tests to run.” If repository conventions require a different test harness or location, update this section with the real command before queueing; do not claim this proposed test already exists. Also run the actual changed internal package suites.
For GraphLoom, apply only the regression tests/fixtures to the chosen base: they must compile and fail by a relevant assertion. Apply the implementation: the same test must pass. Tests that import a new production package missing from the base are not valid assertion-based RED proof; use an existing command seam. Exercise the real CLI with fixture endpoints/files. If the issue requires deployment E2E, record its separate command and result; fixture-server tests alone do not satisfy it.
Evidence required to close this issue
- Source/base revision, exact commands, fixture provenance and independently specified expected outcomes.
- Actual positive and negative/partial-case results; explain failures and rerun after fixes.
- Produced artifact/manifest/report samples with no real sensitive data, and the relevant size/coverage/privacy assertions.
- Applicable repository checks and integration/evaluation results; explicitly list checks not run. A required check not run leaves acceptance incomplete, not passed.
- For failures/cancellation, confirm no false completion marker and no unrelated user-file overwrite.
No verification execution is claimed by adding this section. Do not close the issue merely because code or documentation was submitted.
Activity
UchihaIthachi commentedon Nov 18, 2026
@hanahmily is #14223 open for a contributor, or is it meant for your queue once the contract is fixed?
If a contributor is fine, I'd like to take it. I checked the test seam first: bydbctl/internal/cmd already runs the real CLI from plain Go tests (analyze_native_test.go builds the root with RootCmdFlags and calls Execute), so
TestRCANativeLogCollectwith-run '^TestRCANativeLogCollect$'would really run there. I can also write down the open contract points here first (schema version, limits, statuses) before any code, if that helps.hanahmily commentedon Nov 18, 2026
@UchihaIthachi Thanks for checking the CLI test setup. The
RootCmdFlags/Executeapproach matches what we intended. Writing down the small contract here before implementation would help:log_id, source identity and decodeddata.fields; record collector build, hashes and coverage.To clarify private output: these are files saved locally within the reporter's approved environment, before sanitization—not a special private GitHub repository. For example:
These filenames are illustrative, not a fixed contract. The logs may contain sensitive query values, customer identifiers, internal addresses or accidentally logged credentials. Do not automatically upload this directory or feed its raw contents to a hosted AI model. Later issues select and sanitize evidence into a separate candidate directory; only the reviewed and approved archive is intended for public sharing.
This issue collects evidence faithfully; it does not make that evidence safe to publish. A sample manifest, sample log record and a small input/status table should be enough to review the contract. No new server API or general collection framework is needed.
UchihaIthachi commentedon Nov 20, 2026
Thanks @hanahmily. Short version first, details below.
schema_missingapart), then one query, no pagination/retry.collection(did the run finish) is kept separate fromcoverage(complete / empty / partial / unavailable / unknown). Exit 0 = complete or empty, 6 = partial, 3 = failed.partial, with an exclusivecovered_until, since rows often share a millisecond.Two questions:
~/.bydbctl.yamllike thedatacommands do, so nothing is written outside--output?I checked this against main (8efdf0ca) and with real queries on a local standalone.
surlymochan commentedon Nov 20, 2026
Scope/readiness spot-check on the seam named in this issue (read-only verification, no implementation claim):
bydbctl/internal/cmd/root.goandstream.goboth exist — but inapache/skywalking-banyandb, not in this repo. Inapache/skywalking,bydbctlappears only in e2e docker-compose references._monitoring_logstream referenced by R1 is likewise a BanyanDB-side concept (it shows up inskywalking-banyandbdocs/design for self-stored logs).So the implementation seam resolves cleanly, just across the repo boundary: if the PR for this leaf is meant to land in
skywalking-banyandb, the paths in the audit section are correct as written; if it is meant to land here, the stream-query reuse in R1 would need a cross-repo call or a move. Flagging only so the PR venue is explicit before the RED audit runs — the requirements themselves (bounded rows/bytes/time, partial-or-unknown coverage marking, no server writes) read as implementable against that seam either way.UchihaIthachi commentedon Nov 20, 2026
Here are the details I meant to include above (they didn't make it into that comment, sorry).
@surlymochan thanks, good point. Like the other BanyanDB issues tracked here, the code goes to apache/skywalking-banyandb, so the PR will be there and link back to this issue. The paths in the audit section are relative to that repo.
Inputs
--source native-log--start,--endZ), ms precision at most (the server returns 400 for sub-ms),start < end, window[start, end)--nodenode_id--levellevel, one of the zerolog names the sink stores--output0700; refused if anything already exists there--module,--message-contains--max-rowslimit; 900 is what the nativelog tests use because of the memory budget; above 100000 the server refuses it--max-bytesnative-logs.jsonl; the HTTP response read is capped at 2x this--deadlineConnection/auth: the existing
-a,-u/-pand TLS flags, through the same REST helper asbydbctl stream query, with the request tied to the deadline/cancel context. Like thedatacommands, it doesn't read or create~/.bydbctl.yaml.What it does
GETthe_monitoring_loggroup andlogstream schema. 404 there meansschema_missing. I added this step because querying a missing stream gives a 500 with "stream doesn't exist", not a NotFound. The stream'smod_revisiongoes into the manifest._monitoring_log/log: time order ascending (empty index rule,SORT_ASC),limit = --max-rows, projection = the 8 searchable tags +data.fields. Nodes/levels go in as(node_id = n AND level = l) OR ...pairs. No pagination, no splitting, no retry.log_idpresent. If not, coverage becomesunknown.Why OR pairs instead of IN ... AND IN ...
I first tried
node_id IN (...) AND level IN (...)and got a 500 ("timeRange and series are required"). Any multi-valueINcombined withANDon these two entity tags fails the same way. Looks likeParseEntitiesinpkg/query/logical/parser.gocollapses anANDinto one series key and gives up when a position has two values, whileORkeeps the list. The OR form returns the right rows (I checked it filters node and level correctly), so this issue doesn't need a fix there. Happy to open a separate issue for it if that's useful.Results
collection= did the run finish.coverage= what the evidence actually proves. I also keepfetched_records(what the server returned) apart fromrecords(what was written after--module/--message-contains), so a filter can't make a capped scan lookempty.source_statuscollectioncoverage--max-rows, nothing capped, some writtenoksucceededcompleteoksucceededempty--max-rows(ties included) or--max-bytesoksucceededpartial+covered_untilschema_missingfailedunavailableunreachablefailedunavailabletimeoutfailedunknownResourceExhausted, response too big, bad rows, anything elseerrorfailedunknowncancelledunknown--outputexists1/2/3 mean the same as in
pkg/transfer/exitcode. 6 would be local to the rca command.covered_untilis exclusive: last fetched row's timestamp when the row cap is hit, or the first unwritten row's when the byte cap is hit. Rows at the same millisecond are common in the real data, so anything at that timestamp may be missing. Onlysucceeded+complete/emptyclaims the window is complete. Ctrl-C cleans up temp files; a kill -9 leaves nomanifest.json.manifest.json (example)
{ "schema_version": "rca.native-log.v1", "collector": {"build": "<version.Build()>"}, "source": {"addr": "http://banyand:17913", "group": "_monitoring_log", "stream": "log", "stream_mod_revision": "1795134849798106000"}, "request": {"start": "2026-11-18T10:00:00Z", "end": "2026-11-18T10:05:00Z", "nodes": ["data-0"], "levels": ["error", "warn"], "module": "", "message_contains": ""}, "limits": {"max_rows": 900, "max_bytes": 33554432, "deadline": "2m0s"}, "started_at": "2026-11-19T08:00:00Z", "finished_at": "2026-11-19T08:00:01Z", "source_status": "ok", "collection": "succeeded", "coverage": "partial", "covered_until": "2026-11-18T10:02:30Z", "fetched_records": 900, "records": 900, "nodes": {"data-0": {"records": 900}}, "files": [{"name": "native-logs.jsonl", "bytes": 412337, "sha256": "…"}], "errors": [] }addris saved without anyuser:pass@.native-logs.jsonl (one line)
{"log_id":"data-0-1731920000-42","timestamp":"2026-11-18T10:02:30Z","node_id":"data-0","node_type":"data","module":"STREAM","level":"error","grpc_address":"10.0.0.5:17912","http_address":"10.0.0.5:17913","message":"query failed","fields":{"group":"sw_trace","err":{"code":"Unavailable"}}}log_idcomes from the tag (the responseelementIdis a different, server-side id).fieldsis the decodeddata.fieldswith all keys kept; if it isn't valid JSON it's stored as base64 with"fields_raw": true. Whole lines only, files0600, written to temp names and renamed, manifest last.Tests
TestRCANativeLogCollectinbydbctl/internal/cmd, throughRootCmdFlags+Execute, against anhttptestserver with hand-written fixtures (provenance + fake secret noted intestdata/rca/README.md). Rows: L1 10:01:00, L2 and L3 both 10:02:30 (L3 has a nested secret indata.fields), L4 10:06:00 outside the window.Cases: exact records; empty window;
--max-rows 2→ partial,covered_until10:02:30, exit 6; a--modulematch sitting past the cap → fetched 2, written 0, partial; byte cap; non-JSON fields; missing schema;ResourceExhausted; unreachable; timeout; cancel mid-response; existing--output; bad flags (non-UTC, sub-ms, unknown level). Every case checks its exit code and manifest, so on main they all fail on assertions (rcais an unknown command) rather than not compiling.RED/GREEN:
go test ./bydbctl/internal/cmd -run '^TestRCANativeLogCollect$' -count=1 -v, thenmake test-ci PKG=./bydbctl/internal/cmd. Plus a deployment case next totest/integration/standalone/nativelog: real CLI against a node with native logging on (schema and revision unchanged afterwards), and one with it off (schema_missing, no group created).