Offline clock calibration and conservative timestamp pairing for two data sources
git clone https://github.com/chenqi-arch/moonsyncaudit.git
cd moonsyncaudit
moon version --all
node --version
moon run --target js cmd/main -- audit examples/inspection/device.tsv examples/inspection/reference.tsv examples/inspection/anchors.tsv --tolerance-ms 5 --checkpoints examples/inspection/checkpoints.tsv --strictstatus=PASS device=3 reference=3 pairs=3 issues=0 checkpoints=PASS strict=true| 退出码 | 含义 |
|---|---|
| 0 | 配对完整,且已提供的独立校验点均在容差内。严格模式还要求所有校准区间都有独立观测。 |
| 1 | 有缺项、候选冲突、覆盖区间外的记录或校验点问题。有校验点缺失的区间也会阻止严格模式通过。报告中保留已找到的配对供复核。 |
| 2 | 参数、表格、校准锚点或文件读取无效。错误输出使用输入类别、错误码和行号。 |
& {
$rows = moon run --target js cmd/main -- audit examples/inspection/device.tsv examples/inspection/reference.tsv examples/inspection/anchors.tsv --tolerance-ms 5 --checkpoints examples/inspection/checkpoints.tsv --strict --format pairs-tsv
$auditExit = $LASTEXITCODE
if ($auditExit -ne 0) {
throw "MoonSyncAudit 退出码 $auditExit,本批次未生成合表索引。"
}
$index = Join-Path (Get-Location).Path ("pairs-" + [Guid]::NewGuid().ToString("N") + ".tsv")
$temporary = $index + ".tmp"
try {
[IO.File]::WriteAllLines($temporary, [string[]]$rows, [Text.UTF8Encoding]::new($false))
[IO.File]::Move($temporary, $index)
} finally {
if ([IO.File]::Exists($temporary)) {
[IO.File]::Delete($temporary)
}
}
$index
}device_line reference_line delta_ms
2 2 1
3 3 0
4 4 0moon add chenqi-arch/moonsyncaudit@0.1.1moon fmt --check
moon check --target wasm --deny-warn
moon build --target wasm --deny-warn
moon test --target wasm --deny-warn
moon check --target js --deny-warn
moon build --target js --deny-warn
moon test --target js --deny-warn
moon run --target wasm cmd/library-example
node scripts/verify-cli.mjs
moon package --list --frozenpub struct AuditReport {
// private fields
}pub struct ClockModel {
// private fields
}fn ClockModel::check_points(self : ClockModel, points : ArrayView[ClockPoint], tolerance_ms~ : Int64) -> Array[CheckpointResult] raise InputErrorpub(all) enum IssueKind {
OutsideCalibration
NoCandidate
CandidateConflict
}pub(all) struct MatchedRows {
device_line : Int
reference_line : Int
delta_ms : Int64
}pub struct Pairing {
// private fields
}pub(all) struct RowIssue {
side : SourceSide
line : Int
kind : IssueKind
candidates : Int?
peer_candidates : Int?
}pub(all) struct SegmentCheck {
start_anchor_line : Int
end_anchor_line : Int
checkpoint_count : Int
max_abs_residual_ms : Int64?
}pub(all) enum SourceSide {
Device
Reference
}pub(all) struct TimestampPair {
device_index : Int
reference_index : Int
delta_ms : Int64
}fn audit(clock : ClockModel, device : ArrayView[Record], reference : ArrayView[Record], tolerance_ms~ : Int64, checkpoints? : ArrayView[ClockPoint], checkpoint_tolerance_ms? : Int64, strict? : Bool) -> AuditReport raise InputErrorfn pair_timestamps(device_times : ArrayView[Int64], reference_times : ArrayView[Int64], tolerance_ms~ : Int64) -> Pairing raise InputErrorInstall
Download zipOffline clock calibration and conservative timestamp pairing for two data sources