Skip to content

tagline: bump max length 260 -> 400, replace magic number with named constant#14

Open
vjt wants to merge 2 commits intoazzurra:masterfrom
vjt:feat/tagline-limit-400
Open

tagline: bump max length 260 -> 400, replace magic number with named constant#14
vjt wants to merge 2 commits intoazzurra:masterfrom
vjt:feat/tagline-limit-400

Conversation

@vjt
Copy link
Copy Markdown
Contributor

@vjt vjt commented Apr 21, 2026

Summary

  • Add TAGLINE_MAX_LEN in inc/tagline.h with an English block comment explaining why the value is not a free parameter (512-byte IRC line cap, send_globops() envelope math).
  • Replace the three literal 260 in src/tagline.c (ADD bound, DEL bound, error message) with TAGLINE_MAX_LEN; the user-facing error now formats the constant via %d instead of hardcoding the number in the English string, so the two will never drift.
  • Bump the cap from 260 to 350 bytes.

Rationale

Requested on #it-opers by @Hypnotize (2026-04-21): existing limit felt tight and he wanted an increase. The final shape — named constant in the header, block comment documenting the constraint, no raw magic number left — is his direct requirement ("magic number non ne voglio vedere, constant" / "metti un commento in inglese sopra la costante per spiegare che non puoi bumpare arbitrariamente oltre").

Safety / Byte budget

Final value revised from the initial 400 to 350 after review with @Essency, who correctly flagged that the outbound NOTICE wrap in bahamut's send_globops() includes both the services-side *** Global -- from <caller>: ... framing and the ircd-side :<server> NOTICE <dest> :*** Global -- ... envelope. Worst-case (HOSTMAX=63, NICKMAX=32 across caller/through/destnick, bold markers, full fixed tail) lands at ~230 bytes of overhead, leaving ~280 for the text. 350 is past the theoretical worst case for fully-loaded parameters but stays safely under 512 for every realistic Azzurra combination (server name ~16–21, oper nicks ~8–12) — see the block comment above TAGLINE_MAX_LEN for the full derivation and the explicit warning to re-derive both envelopes before bumping again.

Test plan

  • Local build clean with make -C src (no warnings introduced).
  • Ephemeral testnet smoke — bahamut master + services refs/pull/14/head, 3-server topology (hub + leaf-v4 + leaf-v6 + services):
    • TAGLINE ADD <349-byte string>Your tagline has been added successfully.
    • TAGLINE ADD <350-byte string>Your tagline has been added successfully.
    • TAGLINE ADD <351-byte string>The maximum length for a tagline is 350 characters. Your tagline has 351. (constant + actual length both via %d, no drift).
    • TAGLINE LIST after the run shows the 349 and 350 entries (the 351 was rejected before storage).
    • :hub.azzurra.chat NOTICE testoper :*** Global -- from OperServ: testoper added the following tagline: <350-byte text> GLOBOPS broadcast measured at 454 bytes on the wire, well under the 512 cap.

Smoke harness notes

Auth trick for the testnet: REGISTER → /OPER → IDENTIFY in that order. check_oper() at src/oper.c:603 only promotes past ULEVEL_HOP when user_is_ircop() is already true, so IDENTIFYing before /OPER leaves user->oper == NULL and every ULEVEL_MASTER dispatch returns Access denied. With testoper also configured as M: in services.conf, check_oper() auto-creates the Master oper entry (oper.c:586-591) on first identify — no pre-seeded oper db needed.

=== ADD len=349 (wire line 381) ===
:OperServ!service@azzurra.chat NOTICE testoper :Your tagline has been added successfully.

=== ADD len=350 (wire line 382) ===
:hub.azzurra.chat NOTICE testoper :*** Global -- from OperServ: testoper added the following tagline: A350-xxx...(350 bytes of text)
:OperServ!service@azzurra.chat NOTICE testoper :Your tagline has been added successfully.

=== ADD len=351 (wire line 383) ===
:OperServ!service@azzurra.chat NOTICE testoper :The maximum length for a tagline is 350 characters. Your tagline has 351.

vjt added 2 commits April 21, 2026 19:55
…constant

Introduce TAGLINE_MAX_LEN in inc/tagline.h and replace the three literal
260 occurrences in src/tagline.c (ADD bound check, DEL bound check, and
the error message sent to the caller) with references to it. The error
string now interpolates the constant via %d so it stays in sync if the
cap is ever adjusted again.

The new value is 400 bytes. The accompanying block comment in tagline.h
explains why this is not a free parameter: taglines are emitted via
send_globops() which produces a server-wide NOTICE bounded by the IRC
protocol's 512-byte line cap (RFC 1459 s.2.3.1). A realistic envelope --
server prefix + OperServ + the optional '(through <oper>)' variant +
fixed boilerplate -- consumes ~100-110 bytes, so 400 leaves headroom for
multibyte glyphs and long operator/server names without risking silent
truncation at the uplink.

Requested on #it-opers by Hypnotize (2026-04-21) as part of a general
tagline-capacity bump; the named-constant + explanatory comment are his
direct requirement.
Per Sonic's review on #it-opers: my previous comment underestimated the
outbound GLOBOPS envelope. The binding constraint is not the client→hub
PRIVMSG (short-form server-to-server prefix leaves ~480 bytes for the
tagline text), but the NOTICE that bahamut produces out of the GLOBOPS
broadcast to every +g operator.

bahamut's src/send.c:send_globops prefixes the pattern with
":<server> NOTICE <destnick> :*** Global -- " before forwarding to each
local +g client. Combined with services' own template
"\2<caller>\2 (through \2<oper>\2) added the following tagline: <text>"
the worst-case byte budget works out to ~230 + text against the 512-byte
line cap (RFC 1459 s.2.3.1), i.e. a theoretical hard ceiling of ~280
with all three nicks at NICKMAX=32 and a 63-byte server hostname.
Realistic Azzurra params (21-byte server name, 8-12 byte operator nicks)
leave much more room, but 400 sat uncomfortably close to the worst case.

350 preserves a bump from the previous 260 while keeping clear of
truncation in both realistic and near-worst-case combinations. The
block comment now spells out the full envelope math so the next person
bumping this value has a concrete formula rather than a hand-wave.

Addresses review feedback from @azzurra-nethack / Sonic on PR azzurra#14.
@vjt
Copy link
Copy Markdown
Contributor Author

vjt commented Apr 21, 2026

Per request di @Hypnotize su #it-opers: @Essency (Sonic) per code review.

Note: il valore finale nel PR è 350 (non 400). Il block comment in inc/tagline.h documenta il byte budget completo — inbound PRIVMSG via short-form server-to-server prefix + outbound GLOBOPS wrap di bahamut (src/send.c:send_globops:<server> NOTICE <dest> :*** Global -- ...). A 350 il wire sta comodamente sotto 512 con i params realistici Azzurra (server 21 byte, nick 10-12); truncation teorica solo con NICKMAX=32 × 3 + HOSTMAX=63 × 2 contemporanei, che su questa rete non si presenta.

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