Repository navigation
feat(server): log who called, with optional labels for known numbers - #96
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #96 +/- ##
==========================================
+ Coverage 69.47% 69.95% +0.48%
==========================================
Files 14 14
Lines 3240 3322 +82
==========================================
+ Hits 2251 2324 +73
- Misses 989 998 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Sep 27, 2026
An unexpected buzz on 2026-09-17 could not be attributed from the journal at all. The call was recorded, the caller was not: From arrives in the /twiml body and was parsed only for CallSid, so answering "who rang" meant going to the Twilio console. twiml-response now carries from and forwardedFrom. forwardedFrom is the number that diverted the call, which is the signature of a building line forwarding to us rather than someone dialling direct. KNOWN_CALLERS optionally maps E.164 numbers to labels, so the journal reads Intercom instead of a number, and anything else reads unknown. That is the useful half: on a number only the building management is supposed to have, telling the panel apart from a dialler that found an open PSTN number is the whole question. Logged after the signature check, never before. An unverified From is whatever the sender typed, and twiml-request fires before the body is even read. Descriptive only, and deliberately not a gate. An unknown caller still rings the doorbell: the building's dialler could change without warning, and a silently blocked visitor is far worse than a labelled unknown one. The label is also omitted entirely when nothing is configured, so an unconfigured deployment does not read unknown on every call as though that were a finding. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rq7wnggNTrhwGMADfJ5yvf
atdr
force-pushed
the
feat/identify-callers
branch
from
September 27, 2026 19:23
3a6460e to
9408842
Compare
Hardware testing showed EE sets ForwardedFrom to the dialled Twilio number on every inbound call, so it does not identify a diverting line as the comment claimed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atdr
force-pushed
the
feat/identify-callers
branch
from
September 27, 2026 19:24
9408842 to
bc419ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
twiml-responsenow carriesfromandforwardedFrom.KNOWN_CALLERSoptionally maps E.164 numbers to labels, so the log reads"caller":"Intercom"rather than a bare number, and anything unlabelled reads"caller":"unknown".Why
An unexpected buzz on 2026-09-17 could not be attributed from the journal.
Fromarrives in the/twimlPOST body and was parsed only forCallSid, so answering "who rang" meant opening the Twilio console. That is the second time in one evening we wanted this and did not have it.forwardedFromis logged as Twilio reports it. It was meant to tell a diverted call from a direct one, but hardware testing showed EE sets it to the dialled Twilio number on every call, so on this line it carries no information. The code comment now says so.Independent of the hangup stack
Branched off
main, not stacked on #88/#89/#95. It touches the TwiML handler and config rather than the hangup path, so it can merge in either order.Changes
src/core/config.jsKNOWN_CALLERSparses comma-separated<E.164>=<label>pairs into aMap. Validation refuses an entry with no separator, a number that is not E.164, an empty or over-64-character label, and a number listed twice — the last because otherwise one label silently wins and the other is never seen again.Split on the first
=only, so a label may itself contain one (Gate = side door).server.jsdescribeCaller()returns the label,'unknown'for a number with none, andnullwhenKNOWN_CALLERSis unset — so an unconfigured deployment omits the field rather than readingunknownon every call as though that were a finding.Logged on
twiml-response, after the Twilio signature check, never ontwiml-request.twiml-requestfires before the body is even read, and an unverifiedFromis whatever the sender typed.A repeated form field parses to an array (the signature covers the body, not its shape), so
firstFormValue()takes the first value rather than letting.trim()throw.Deliberately not a gate
You framed this as "primitive spam caller rejection", and I have built the identification half only. An unknown caller is labelled and still rings the doorbell.
Rejecting on this list would mean that the day the building management changes the panel's outbound number, or routes it through a different trunk, the doorbell silently stops working and nothing says why. A missed visitor at a door is a much worse failure than a labelled unknown call in a log. The data this adds is exactly what a later decision to filter would need, and by then there will be real traffic to judge it against — but that should be its own change, argued on its own terms.
The test file says this out loud, so a future change of policy has to delete the comment saying not to.
Test Plan
typecheck,lint,format:check,check,test— 150 tests, up from 134).tests/known-callers.test.cjs, 16 cases: parsing (pairs, padding, a label containing=), every validation failure, and labelling (known, unknown, unset, repeatedFrom, whitespace).=fails 2, dropping the duplicate check fails 2, labelling when unconfigured fails 2, and dropping the trim on the incoming number fails 2. Both source files confirmed byte-identical afterwards.KNOWN_CALLERSset (2026-09-27). The intercom's number came from Twilio's call log (8 calls April to September), not a live call. Two live calls logged"from":"<Twilio number>","caller":"Self test", which confirms the path end to end."caller":"Intercom".🤖 Generated with Claude Code
https://claude.ai/code/session_01Rq7wnggNTrhwGMADfJ5yvf