Skip to content

feat(asinfo): add allocation_status and load asndata.asn_allocation - #50

Merged
digizeph merged 3 commits into
mainfrom
feat/asn-allocation-status
Oct 23, 2026
Merged

digizeph merged 3 commits into
mainfrom
feat/asn-allocation-status

Conversation

@digizeph

Copy link
Copy Markdown
Member

An AsInfo row could not say whether an ASN is allocated at all: delegated was None both for private-use space and for numbers no RIR ever allocated, and reserved records were dropped along with everything that was not allocated/assigned.

This adds allocation_status to every record (allocated, assigned, reserved, private, unallocated). The positive values come from the delegated record's status; private and the special-purpose part of reserved come from IANA's special-purpose AS table, which no RIR file restates and which is now public so loaders store the same ranges instead of a second copy. Records written before the field existed deserialize as unallocated.

It also fixes the parser swallowing each file's version record (2|ripencc|..., ARIN's 2.3|arin|...): seven fields wide, it passed the shape check and was stored as a record whose registry was the format version, which is how five of them ended up in asndata.delegated.

pg_inserter gains an allocations task that loads asndata.asn_allocation, one row per allocation range (the five delegated files plus the nine IANA ranges) with a GiST index on int8range(start_asn, end_asn). Ranges rather than per-ASN rows because the RFC 6996 private blocks cover about 95 million ASNs.

Measured against the 2026-10-23 files: 104,397 ranges (71,282 allocated, 31,928 assigned, 1,185 reserved, 2 private).

The first line of a delegated-stats file (2|ripencc|... or ARIN's 2.3|arin|...)
is a version record: every field is a file-level fact. It is seven fields wide,
so it passed the shape check and was parsed as a record whose registry was the
format version, which is how five of them ended up in asndata.delegated.
An AsInfo row could not answer whether an ASN is allocated at all: delegated was
None both for private-use space and for numbers no RIR ever allocated, and
reserved records were dropped along with the rest.

AllocationStatus states the verdict on every record. The positive values come
from the delegated record's status; Private and the special-purpose part of
Reserved come from IANA's special-purpose AS table, which no RIR file restates
and which is now public so loaders store the same ranges instead of a copy.
Records written before the field existed deserialize as unallocated.
One row per allocation range from the five delegated files plus the nine
IANA special-purpose ranges, with a GiST index on int8range(start_asn,
end_asn). Ranges rather than per-ASN rows: the RFC 6996 private blocks cover
about 95 million ASNs.

Measured on the 2026-10-23 files: 104,397 ranges, of which 71,282 allocated,
31,928 assigned, 1,185 reserved and 2 private.
@digizeph
digizeph merged commit 4f05967 into main Oct 23, 2026
1 check passed
@digizeph
digizeph deleted the feat/asn-allocation-status branch October 23, 2026 18:28
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.

1 participant