Skip to content

Add Label A0 AFN (ATS Facilities Notification) decoder plugin#407

Open
thepacket wants to merge 1 commit intoairframesio:masterfrom
thepacket:plugin/label-a0
Open

Add Label A0 AFN (ATS Facilities Notification) decoder plugin#407
thepacket wants to merge 1 commit intoairframesio:masterfrom
thepacket:plugin/label-a0

Conversation

@thepacket
Copy link
Copy Markdown

Adds a decoder for FANS 1/A AFN (Context Management / CPDLC logon) downlinks carried under label A0.

Handles all three observed envelope variants:

/LPAFAYA.AFN/FMHIBE0105,.EC-NVR,,093150/FAK4,GCCC,LPAFAYAF015
/PIKCPYA.AFN/FMHVIR8Y,.G-VPRD,,095426/FCASNNCPXA,0E7A6
/SNNCPXA.AFN/FMHVIR8Y,.G-VPRD/FAK0,EISN/FARADS,2/FARATC,0B5E0

npm run build passes.

New plugin registered in official.ts and MessageDecoder.ts.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@thepacket has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 31 seconds before requesting another review.

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 31 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c0ae7ed0-97da-4242-8b89-ca4944a851df

📥 Commits

Reviewing files that changed from the base of the PR and between 10f9f69 and dd15df9.

📒 Files selected for processing (3)
  • lib/MessageDecoder.ts
  • lib/plugins/Label_A0_AFN.ts
  • lib/plugins/official.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@kevinelliott kevinelliott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds a Label_A0_AFN plugin for FANS 1/A AFN logon downlinks. Handles three observed envelope variants. Registered correctly.

Verdict

Changes requested — useful coverage, but the implementation diverges from project conventions in several places, doesn't use ResultFormatter, has unstable raw keys, and ships without tests.

Must Fix

  • No tests. Please add coverage for each of the three documented variants from the PR description, plus a malformed envelope and an empty-body case.
  • Plugin bypasses ResultFormatter almost entirely. Where helpers exist (tail, groundAddress, arrivalAirport, timestamp) they should be used so downstream consumers get the same raw.* keys and formatted.items shape as every other plugin. Currently you write decodeResult.raw.tail = … directly, push your own code:'TAIL' row, etc. — equivalent, but inconsistent.
  • raw.message_timestamp is set to a HH:MM:SSZ string. Per RawFields, message_timestamp is numeric (seconds since midnight or epoch). This will type-mismatch downstream consumers. Use ResultFormatter.timestamp(decodeResult, DateTimeUtils.convertHHMMSSToTod(timeTok)) and validate hh<24, mm<60, ss<60 first.

Should Fix

  • Sequence-detection heuristic is brittle. aircraft.match(/^([A-Z0-9]+?)(\d{4})$/) strips trailing 4 digits from any aircraft token of length ≥8 — so a tail like N12340105 would have 0105 peeled off as a "sequence". Variants 2 and 3 have no sequence — relying on length alone to disambiguate is risky. Drive this off the variant context (whether the post-envelope CSV block exists) instead.
  • Dead code / no-op. Line 76: const consumed = env[0].length + (seq ? -0 : 0);+ -0 is a no-op and the comment "env[0] already included seq digits" contradicts it. Delete the conditional, just use env[0].length. Also lines 78–80: const remainder = remainderRaw.startsWith(',') ? remainderRaw : remainderRaw; — the two branches are identical. Remove.
  • Non-standard raw keys. application, aircraft_address, message_sequence, reason_code, header_extra, capability_blocks, capability_code, atc_center_icao, ground_facility_full, ground_facility_address, ground_facility_version are bespoke. Consider namespacing under afn: { … } so these don't collide with future plugins, and document them in RawFields if they’re intended to be public.
  • raw.arrival_icao is set to the ATC centre ICAO (line 138). The ATC centre is not the flight’s arrival airport. Drop this — it pollutes the standard arrival_icao slot.
  • Ground-facility "version" parser (/^([A-Z0-9]+?)(F\d{2,4})$/) over-fits a single observed example (LPAFAYAF015). Without source documentation this should be exposed verbatim, not synthesised.
  • Capability-block multi-shape rendering is asymmetric: when there is one block you emit individual rows; when there are multiple you collapse to BLK1/BLK2 with ·-joined values. That makes consumers branch on count. Pick one shape (recommend always per-token rows with an index suffix).
  • HHMMSS validation. if (timeTok && /^\d{6}$/.test(timeTok)) accepts 999999. Validate ranges.

Nits

  • appl === 'AFN' ? 'AFN (ATS Facilities Notification)' : appl — given this plugin's qualifiers().labels = ['A0'] and the regex anchors AFN semantically, you can probably hard-fail on non-AFN applications.
  • decodeResult.raw.tail is set as an assignment, then later rendered via formatted.items.push({code:'TAIL'…}) rather than via ResultFormatter.tail(...).
  • The leading let { ground, appl, aircraft } = env.groups; mutates aircraft. Consider naming the original aircraftRaw for clarity.

Tests

Missing. See Must Fix.

Notes

  • Registration LGTM (MessageDecoder pluginClasses + official.ts re-export).
  • CodeRabbit rate-limited; that comment can be ignored.

Thanks @thepacket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants