Add Label B2 Oceanic Clearance Acknowledgement decoder plugin#413
Add Label B2 Oceanic Clearance Acknowledgement decoder plugin#413thepacket wants to merge 1 commit intoairframesio:masterfrom
Conversation
New plugin registered in official.ts and MessageDecoder.ts.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 20 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
kevinelliott
left a comment
There was a problem hiding this comment.
Summary
Adds Label_B2_OCRA for FANS Oceanic Clearance Acknowledgement (CLA) downlinks. Parses station envelope, time, date, oceanic FIR, clearance number, callsign, destination, route type (random / NAT track), waypoints, oceanic entry fix and entry time, cleared flight level, cleared Mach, and trailing CRC. Registered in both lib/MessageDecoder.ts and lib/plugins/official.ts. Build passes per the description.
Verdict
Needs changes before merge. The shape of the parser is correct and the field set is comprehensive, but there's a Mach decoding bug, two duplicate-row antipatterns, and the date-format choice deserves explicit justification.
Must Fix
- Mach decoding bug. Line 105-106:
This works for
const machM = routeClean.match(/\bM(\d{3})\b/); if (machM) machNumber = `0.${machM[1]}`.replace('0.0', '0.');M085(→0.085→ replace gives0.85) but breaks for any Mach where the second digit isn't zero — e.g.M082becomes0.082and the replace finds no match, leaving the wrong value. Mach numbers in oceanic clearances are typicallyM078–M092. The intended decoding is "drop the leading M and divide by 100" — implement that directly:if (machM) machNumber = (Number(machM[1]) / 100).toFixed(2);
- Duplicate Time row (project antipattern). Lines 130-133 call
ResultFormatter.timestamp(...)which already pushes a{type:'time', code:'TIMESTAMP'}item. Then lines 162-168 explicitly push another{type:'time', code:'TIME'}row with the same value. Pick one. Same issue is flagged in PR #412. - Duplicate Callsign row (project antipattern). Line 137 calls
ResultFormatter.flightNumber(decodeResult, callsign)(adds a "Flight Number" item) and lines 188-192 push a separate{code:'CALLSIGN', label:'Callsign'}row with the same string. For a callsign rather than a flight number, preferResultFormatter.callsign(...)(lib/utils/result_formatter.tsline 93) and drop the manual push. - No tests. Please add
Label_B2_OCRA.test.tswith at least the wire-format example, a NAT-track variant (sorouteTyperesolves toNAT Track <letter>), a missing-CRC body, and a body where the optionalVIAgroup is absent. Uselib/plugins/Label_15.test.tsas a template.
Should Fix
- Date format claim needs justification. Lines 21-23 declare YYMMDD and explicitly note "an earlier analyst report read this as DDMMYY; that interpretation is inconsistent with the real message date — corrected here." With only a single sample message, this is fragile. Please:
- cite the source (ARINC 622 / FANS-1/A spec section, an additional message sample, or a libacars reference) in the docstring,
- or accept both formats, validate the resulting date against a sanity window (year between e.g. 2000 and current year + 1), and pick whichever yields a valid date.
Without one of these, the next operator that emits DDMMYY will produce wrong ISO dates silently.
timevalidation only checks HH/MM but the value passed toconvertHHMMSSToTodistime + '00'. Fine becausetimeis\d{4}per the regex, but the comment "Time field" in the docstring should call out that seconds are forced to zero (not parsed from the wire).- Destination regex
[A-Z]{3,4}. Three-letter destinations risk colliding with route tokens. The wire format always uses 4-letter ICAO. Tighten to[A-Z]{4}, or document why the 3-letter form is needed. - Waypoint coordinate regex. Line 121:
/^\d{4}N\d{3}W$/and/^\d{4}N\d{3}E$/— these reject southern-hemisphere waypoints (5130S020W). AddSto the latitude-hemisphere alternation and document that lat is(N|S)and lon is(E|W). Consider a single regex^\d{4}[NS]\d{3,5}[EW]$(longitudes can also be 5 digits at high latitudes if the format includes minutes). channelraw key. The envelope splits station from channel on., e.g.PIKCLYA.OC1→ station=PIKCLYA, channel=OC1. "Channel" isn't really the right word —OC1is more like a service qualifier (Oceanic Clearance, instance 1). Suggestservice_qualifierorimi, matching the FANS 1/A vocabulary used in PR #411.route_typefor NAT track. "NAT Track A" is a friendly label, but downstream consumers will more easily key off a stable code likeNAT_Aor a structured{type:'nat', track:'A'}object. Same logic for'Random Route'→'random'raw, friendly value in formatted.
Nits
report_date: rename toclearance_dateto match the surrounding domain vocabulary.entry_timeraw isHH:MM— better to store as a numeric tod (DateTimeUtils.convertHHMMSSToTod(entryTime + '00')) for consistency withmessage_timestamp.cleared_flight_levelvalue is'F400'— most downstream consumers want a number (400). The formatted-display already strips theF.- The "Ground Station" formatted row uses the joined value
${station}.${channel}— but the raw fields store them separately. Worth surfacing the join only if you keep a separate parsed channel field.
Tests
Missing entirely. Beyond the four scenarios under Must Fix, please add: invalid HH (e.g. 2911), invalid date (260435), Mach values across the range (M078, M085, M092).
Notes
- Registration: confirmed in both
lib/MessageDecoder.ts(line 81) andlib/plugins/official.ts(line 67) at the PR HEAD. - FANS 1/A consistency: like PRs #409, #411, #412, this plugin introduces its own envelope-parse + CRC-strip + tail/callsign-extract logic. Please align raw-key naming with those three (
crchere matches PR #412, but PR #411 usescrcand PR #409 usescrc_hex— pick one).
Thanks @thepacket!
Adds a decoder for FANS Oceanic Clearance Acknowledgement (OCRA / CLA) downlinks.
Wire format
Surfaces ground station, UTC time, date (YYMMDD → ISO), oceanic FIR, clearance number, callsign, destination, route type (random/NAT track), waypoints, oceanic entry fix + entry time, cleared flight level, cleared Mach, trailing CRC.
npm run buildpasses.