feat: selectable and searchable only-to-customer (OTC) field - #151
Conversation
- parse/search: the --only-to-customer filter (alias --otc) is now joined by
--fields only-to-customer display support in JSON, table, PSV, and markdown
formats; the JSON key is only_to_customer, matching native BgpElem serde.
- rib: persist the OTC attribute in StoredRibEntry and StoredRibUpdate plus the
ribs and updates SQLite tables, and expose it as a default output field.
- server: rename the SSE SearchStreamFilters field from otc to
only_to_customer for consistent snake_case wire naming.
- examples: add only_to_customer example demonstrating value ('*' presence and
'!*' absence) filters on real Route Views data.
- changelog: drop stale v0.19 parser version references under Unreleased.
There was a problem hiding this comment.
Pull request overview
Adds first-class only-to-customer filtering, display, and RIB persistence.
Changes:
- Renames OTC interfaces to
only-to-customer. - Adds OTC output formatting and RIB storage.
- Adds documentation and a runnable Route Views example.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/server/search.rs |
Renames the SSE filter field. |
src/lens/parse/mod.rs |
Renames and maps the OTC parser filter. |
src/database/session/rib_store.rs |
Persists OTC values in RIB tables. |
src/bin/commands/rib.rs |
Adds OTC to RIB output. |
src/bin/commands/elem_format.rs |
Adds OTC field formatting and tests. |
examples/README.md |
Documents OTC usage. |
examples/only_to_customer.rs |
Demonstrates OTC filtering. |
CHANGELOG.md |
Records the feature. |
Cargo.toml |
Registers the new example. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // --- bgpkit-parser extended element filters --- | ||
| #[serde(default)] | ||
| pub otc: Option<String>, | ||
| pub only_to_customer: Option<String>, |
| origin_asns TEXT, | ||
| only_to_customer INTEGER |
| # Select the attribute as an output column (JSON key: only_to_customer) | ||
| monocle parse <mrt-file> --fields timestamp,prefix,only-to-customer |
| origin_asns: elem | ||
| .origin_asns | ||
| .map(|asns| asns.into_iter().map(|asn| asn.to_u32()).collect::<Vec<_>>()), | ||
| only_to_customer: elem.only_to_customer.map(|asn| asn.to_u32()), |
- remote search: forward --only-to-customer to the server via the RemoteSearchFilters wire DTO (search_remote.rs and the run_remote_search_wrapper conversion in search.rs), with a wire-JSON test. - rib sqlite: auto-migrate databases created before the only_to_customer column existed by adding it via PRAGMA table_info + ALTER TABLE ADD COLUMN when opening without reset; regression test covers both ribs and updates tables. - rib store tests: use a non-NULL OTC value and assert it survives BgpElem conversion and both SQLite inserts instead of only counting rows. - docs: align README available-fields list with only-to-customer and clarify the JSON/PSV key; CHANGELOG updated.
|
Addressed all 4 review points in commit
|
Summary
monocle parse,monocle search, andmonocle rib, on top of the existing--otcfilter from feat: add bgpkit-parser v0.19 extended filters, remove unused deps #148.otctoonly-to-customerconsistently (CLI flag,--fieldsvalue, server DTO), keeping--otcas a CLI alias.*presence /!*absence filtering works end to end.Motivation
Monocle could filter by OTC but could not select it for display (
--fields otcwas rejected, andmonocle rib's local store dropped the attribute entirely). One Route Views updates file alone carries 17k+ real OTC-tagged elements (peer AS37100 tagging AS12654 announcements), so this is useful for route-leak and RFC 9234 role analysis.Changes
src/bin/commands/elem_format.rs:only-to-customeradded toAVAILABLE_FIELDSwith value and JSON match arms; custom JSON projection emits theonly_to_customerkey to match native BgpElem serde.src/lens/parse/mod.rs:ParseFiltersfieldotc->only_to_customer; CLI flag--only-to-customer(visible alias--otc); the bgpkit-parser filter key staysotc.src/server/search.rs: SSESearchStreamFiltersfieldotc->only_to_customerfor consistent snake_case wire naming.src/database/session/rib_store.rs: persist OTC inStoredRibEntry/StoredRibUpdateand theribs/updatesSQLite tables.src/bin/commands/rib.rs:only-to-customerdefault field plus JSON / PSV / table / markdown arms.examples/only_to_customer.rs+examples/README.md: new example and CLI usage docs.CHANGELOG.md: entries for the above; drops stalev0.19 parserversion references under Unreleased (monocle is on parser 0.20.0).Test Plan
cargo fmt -- --checkcargo clippy --all-features -- -D warningscargo test --features cli(elem_format 7/7, extended filters 3/3, rib_store 2/2)--only-to-customer 6777-> 1098 hits,*-> 17264,!*-> 167764--fields timestamp,prefix,only-to-customerJSON emitsonly_to_customerkeycargo run --example only_to_customer --features libNotes for Reviewers
Filter::OnlyToCustomer,AttributeValue::OnlyToCustomer); no parser change needed.otcsurvives only as the internal bgpkit-parser filter key and the CLI alias; not as the primary user-facing name.clippy --all-targetsflagsitems_after_test_moduleinbin/commands/search.rsand a testunwrapindatabase/core/connection.rs; these are outside the documented CI gate (clippy --all-features -D warnings).