Repository navigation
feat(history): object change history (audit log) — CLI + MCP - #84
Merged
Merged
Conversation
nbox history <kind> <ref> shows the system-recorded create/update/delete timeline for an object (who, when, and which fields changed) from /api/core/object-changes/ (NetBox 4.x). Distinct from nbox journal (operator notes): this is the audit trail. Answers a top agent query — "what happened to this prefix/device/IP?" — that nbox could not answer before. Each row carries time/action/user/object/message/fields_changed/request_id. fields_changed lists the top-level fields whose values differ pre vs post (a sorted diff), not the full before/after JSON (which can be kilobytes per row). The full diff is a planned --diff follow-up. Mirrors nbox journal almost exactly — the ref→kind→content-type→id resolution is shared (resolve_content_type_id), just a different endpoint + richer payload: - ObjectChange model (action/user/time/object_repr/request_id/prechange_data/ postchange_data) in models/extras.rs - Endpoint::CoreObjectChanges + object_changes(content_type, object_id, max) query (mirrors journal_entries, against /api/core/object-changes/) - HistoryView + HistoryRow (domain/history_view.rs): from_models renders the fields-changed diff; to_plain renders the timeline - nbox history CLI command (mirrors nbox journal) + run_history handler - nbox_history MCP tool (mirrors nbox_journal) — tools 10 → 11 - EXPECTED_TOOLS bumped in mcp_serve_tests + mcp_serve_http_tests Tests: 4 history_view unit tests (render, empty, create-no-fields, user fallback) + 1 MCP functional test (history_returns_changes_for_device) + 1 MCP contract test (history_view_shape_is_pinned — pins the key set). 1116 all-features / 1021 no-default, clippy -D warnings, fmt. Verified live against 4.6.2: nbox history device <name> returns the audit timeline with fields_changed (e.g. "fields: asset_tag" on an update). Docs: AGENTS, README, FEATURES, MCP, SCRIPTING command/tool lists updated; "ten tools" → "eleven tools" across README/MCP/SCRIPTING; "10 read tools" → "11" in ROADMAP; CHANGELOG [Unreleased] Added; ROADMAP history item ☐→☑.
This was referenced Jun 25, 2026
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
nbox history <kind> <ref>shows the system-recorded create/update/delete timeline for an object (who, when, and which fields changed), from/api/core/object-changes/(NetBox 4.x). Distinct fromnbox journal(operator notes): this is the audit trail.Answers a top agent query — "what happened to this prefix/device/IP?" — that nbox could not answer before.
Shape
Each row carries:
time/action/user/object/message/fields_changed/request_id.fields_changedlists the top-level fields whose values differ pre vs post (a sorted diff), not the full before/after JSON (which can be kilobytes per row). The full diff is a planned--difffollow-up.Implementation (mirrors
nbox journal)The ref→kind→content-type→id resolution is shared (
resolve_content_type_id) — just a different endpoint + richer payload:models/extras.rsObjectChangemodel (action/user/time/object_repr/request_id/prechange/postchange)endpoints.rsEndpoint::CoreObjectChanges→/api/core/object-changes/query.rsobject_changes(content_type, object_id, max)— mirrorsjournal_entries, scoped bychanged_object_type+changed_object_id, ordered-timedomain/history_view.rsHistoryView+HistoryRow:from_modelsrenders the fields-changed diff;to_plainrenders the timelinecli.rsnbox history <kind> <ref> [--limit N]— mirrorsnbox journallib.rsrun_historyhandler (mirrorsrun_journal)mcp/mod.rsnbox_historyMCP tool (mirrorsnbox_journal) — tools 10 → 11Tests (6 new)
history_viewunit tests: render-with-fields-and-user, empty-explicit, create-no-fields (prechange null → no diff), user-fallback-to-nested-objecthistory_returns_changes_for_device— pinsfields_changed=["site_id", "status"]for an update (status changed, site_id added, name unchanged)history_view_shape_is_pinned— pins the key set (time/action/action_label/user/object/fields_changed/request_id;messageomitted when empty)EXPECTED_TOOLSbumped 10 → 11 in bothmcp_serve_testsandmcp_serve_http_tests.Verification
fmt,clippy --all-targets --all-features -- -D warnings,test --all-features(1116 pass, +6),test --no-default-features(1021 pass, +2) — all green.nbox history device <name>against the 4.6.2 box returns the audit timeline withfields_changed(e.g.fields: asset_tagon an update); JSON view carries the structured fields.changed_object_type=dcim.device&changed_object_id=573isolates one object exactly (the dotted form works;idalone is ambiguous across types).Docs
AGENTS.md,README.md,docs/FEATURES.md,docs/MCP.md,docs/SCRIPTING.md— command + tool lists updated; "ten tools" → "eleven tools"; "10 read tools" → "11" (ROADMAP).CHANGELOG.md[Unreleased]→### Added.ROADMAP.mdhistory item ☐ → ☑.Files
18 files, +549/−12. New:
src/domain/history_view.rs(+248 incl. tests).This is a new capability — the highest-impact next win after three structural-but-imperceptible perf fixes (cap normalize, browse revert, search per-endpoint cap). A user will notice it's there.