strawberry/tests/fleet_inspect.cpp
trvon 0410eac61c
fleet-inspect: print manifest time range and window start min/max
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:16:32 -07:00

72 lines
2.7 KiB
C++

// strawberry-fleet-inspect: dev tool that prints record counts of an export bundle and how many
// window feature vectors carry fleet_bits (features[37..41] != 0). Not installed.
#include "strawberry/fleet_export.hpp"
#include <algorithm>
#include <iostream>
#include <string>
#include <string_view>
namespace strawberry {
namespace {
int run(int argc, char** argv) {
if (argc != 2 || argv[1][0] == '\0') {
std::cerr << "usage: strawberry-fleet-inspect <bundle_path>\n";
return 2;
}
fleet::ExportManifest manifest;
unsigned long long nwin = 0, nfeat = 0, nlabel = 0, nrar = 0, fleet_feat = 0;
int64_t win_min = 0, win_max = 0;
const bool ok = fleet::read_export_bundle(
argv[1], manifest,
[&](uint32_t type, std::string_view payload) {
switch (static_cast<store::RecordType>(type)) {
case store::RecordType::export_window: {
++nwin;
fleet::ExportWindow w;
if (fleet::decode_export_window(payload, w)) {
if (win_min == 0 || w.start_ns < win_min) win_min = w.start_ns;
win_max = std::max(win_max, w.start_ns);
}
break;
}
case store::RecordType::export_window_feature: {
++nfeat;
fleet::ExportWindowFeature f;
if (fleet::decode_export_window_feature(payload, f)) {
for (std::size_t k = 37; k <= 41; ++k) {
if (f.features[k] != 0.0f) {
++fleet_feat;
break;
}
}
}
break;
}
case store::RecordType::export_label:
++nlabel;
break;
case store::RecordType::export_rarity_delta:
++nrar;
break;
default:
break;
}
},
nullptr);
if (!ok) {
std::cerr << "unreadable\n";
return 1;
}
std::cout << "node_uid=" << manifest.node_uid << " windows=" << nwin << " features=" << nfeat
<< " labels=" << nlabel << " rarity=" << nrar << " fleet_feat=" << fleet_feat
<< " time_low=" << manifest.time_low_ns << " time_high=" << manifest.time_high_ns
<< " win_start_min=" << win_min << " win_start_max=" << win_max << "\n";
return 0;
}
} // namespace
} // namespace strawberry
int main(int argc, char** argv) { return strawberry::run(argc, argv); }