Skip to content

Document log list date filters, ordering, and history window; fix Voice Logs MOS and include_deleted - #989

Open
Devon-White wants to merge 1 commit into
mainfrom
devon/rest/logs-filters
Open

Devon-White wants to merge 1 commit into
mainfrom
devon/rest/logs-filters

Conversation

@Devon-White

@Devon-White Devon-White commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #927
Closes #960

What changed

Log list filters (#960). The voice, message, fax, video, and conference log lists all use the same Rails contract for dates and paging, so they now share one TypeSpec model, LogListQuery (specs/signalwire-rest/_globally_shared/log-list-query.tsp), in place of five drifting copies. The parameter descriptions now state:

  • Accepted formats: YYYY-MM-DD, an ISO 8601 timestamp (with Z, an offset, or neither, which means UTC), or Unix time in seconds.
  • created_after is at or after the time and created_before is at or before it. A date means midnight UTC at the start of that day, so created_after=D includes day D and created_before=D leaves it out.
  • created_on covers one UTC day. A timestamp selects the whole UTC day that contains it.
  • page_size defaults to 50 with a maximum of 1000. The page_number and page_token descriptions are unified.

A shared logListBehavior alias adds the same paragraph to all five list operations: results are newest first, links.next carries the filters, and history is limited to one year (see below).

Voice Logs (#927).

  • MOS: "4.5 is the best score, and a call that received no audio packets also scores 4.5." The same sentence was also corrected in the two Compatibility API copies (call resource and status-callback webhook) and on the cXML voice overview page, because all of them describe the same stat.
  • include_deleted is removed from voice and message logs because both ignore it. Fax, video, and conference logs honour it, so they keep it on their own request models (spread over the shared model). Its default is now false on all three; conference logs had no default before.
  • One-year history window documented (shared paragraph above).

List payment history (#960).

  • page_size now says "default 50, maximum 1000". This applies to the shared SpacePaginationQuery, which members and member projects also use, and all of them use the same pagination contract.
  • New links example that points to /api/space/payment_history (with a carried created_after) instead of /api/space/members.
  • Newest-first order and the filter bounds are stated: created_after is inclusive and created_before is exclusive here, which differs from the log lists.

Source anchors (prime-rails origin/HEAD 4c7f31a2b6 unless noted)

Claim Anchor
Formats: Unix seconds via Float, else Time.zone.iso8601 (date-only → midnight) app/services/common/parse_datetime.rb, app/concepts/shared/contracts/validate_date_or_timestamp.rb
UTC: config.time_zone unset; APIController / API::REST::BaseController / API::Space::BaseController never use_zone config/application.rb:45, app/controllers/api_controller.rb
All five contracts identical for dates/paging app/concepts/api/rest/{voice,messaging,fax,video}/log/contracts/index.rb, .../logs/conference/contracts/index.rb
Log bounds: created_after gteq, created_before lteq, created_on beginning_of_day..end_of_day app/models/{voice_segment,message_segment,fax_segment,video_segment,conference_segment}.rb scopes
Newest first: every log list passes cursor_order_only: true → reorder(cursor: :desc); cursor is the auto-increment set on creation app/services/common/cursor_pagination.rb
links.next carries filters: sanitized_params includes allowed_query_params; links merge current_params app/concepts/shared/contracts/cursor_pagination.rb, app/serializers/api/rest/shared/pagination_meta.rb
page_size max 1000 (all users of the shared contract, payment history and members included) app/concepts/shared/contracts/cursor_pagination.rb
One-year window: created_after(HistoryLogs::DateRange.run) on every list; earlier filter values → exceeds_history_logs_limit app/services/history_logs/date_range.rb (1.year.ago.beginning_of_day), app/validators/timestamp_within_accessible_history_range_validator.rb, each operations/index.rb
include_deleted ignored by voice and messaging (scope.kept # unless contract.parsed_include_deleted); honoured by fax, video, conference app/concepts/api/rest/voice/log/operations/index.rb:21, .../messaging/log/operations/index.rb vs the other three
Payment history: order(created_at: :desc), date_gte (date..), date_lt (...date), path-helper links app/concepts/api/space/payment_history/operations/index.rb, app/models/balance_adjustment.rb:85-86, app/serializers/api/space/payment_history_serializer.rb
MOS: R = 100, recomputed only when recved > 0; mos = 1 + 0.035R + … → 4.5 at R=100 signalwire/stack master 2d6e498 src/switch_rtp.c do_mos (:1252-1292)

Notes for reviewers

  • Voice Logs reference: MOS 4.5 wording, RTT granularity, include_deleted, one-year history limit #927 claim 2 (RTT "in steps of 10") is not changed, because it is correct. FreeSWITCH writes rtp_audio_rtt_* in seconds with %0.2f (signalwire/stack src/switch_core_media.c add_stat_double, :2009, used at :2092-2095). mod_laml multiplies that by 1000 (mod_laml.c:4790-4802, mod_laml 57c1bb1), so the values come in 10 ms steps. The issue's source only covers the ×1000 step, not the formatting before it.
  • REST API, Logs: date filter format, bounds, timezone and list order are not stated on the list pages #960 row 4 disagrees with the source for the log lists. Testing found that created_before=T excluded a log created at exactly T. The scopes use lteq, so the docs follow the source and say "at or before". A likely cause: Rails serializes created_at with millisecond precision by default, while the stored value keeps sub-millisecond digits. A created_at copied from a response is therefore usually a little earlier than the stored value, which lteq then excludes. That explanation is inferred and not tested. Payment history really is exclusive (...date), and its docs say so.
  • Why include_deleted was in the spec: it came with the 2026-01-09 migration from the old docs repo (e9f5fa3f0a), and the 2026-02-10 Voice API audit (d72f3b2543) added its = false default. No comment explains it. The Rails contracts still list include_deleted in allowed_query_params and validate it as a boolean, which is probably where it came from. Only the voice and messaging operations comment out its use. The visible prime-rails history starts at a squashed commit (2157da1adf), so it doesn't show when that was commented out.
  • MOS/RTT were read on signalwire/stack master. I didn't confirm the deployed image's stack pin, but do_mos and add_stat_double are long-standing upstream FreeSWITCH code.
  • Unix-time input is documented because ParseDatetime tries Float() first. A side effect: an 8-digit basic-format date such as 20261101 is read as epoch seconds and fails the history check. The basic format isn't documented, so this text doesn't promise it.
  • The payment-history links example is a property-level @example on a $ref property, the same allOf + examples pattern used about 500 times in this OpenAPI file. Please confirm the rendered response example on the preview.
  • Out of scope, not touched: the video PaginationLinks examples (/api/video/rooms?page=2) and the fax/message 422 examples that link to /docs/rest/overview/error-codes/.
  • yarn build:specs and yarn fern-md-check pass. yarn fern-check fails only on "Missing redirects check skipped: could not reach FDR (403)", which is environmental.

Preview pages: /docs/apis/rest/voice-logs/list-voice-logs, /docs/apis/rest/message-logs/list-message-logs, /docs/apis/rest/fax-logs/list-fax-logs, /docs/apis/rest/video-logs/list-logs, /docs/apis/rest/conference-logs/list-conferences, List payment history, and /docs/compatibility-api/cxml/reference/voice (MOS line).

- Share one LogListQuery model (date filters + paging) across the voice,
  message, fax, video, and conference log lists, with format, bound,
  and UTC semantics from the shared Rails contract and scopes.
- State newest-first order, filter-carrying links, and the one-year
  history window on each list.
- Remove include_deleted from voice and message logs, which ignore it.
- MOS: a leg that received no audio packets also scores 4.5.
- Payment history: newest-first order, filter bounds, page_size max,
  and a links example for /api/space/payment_history.
@Devon-White Devon-White self-assigned this Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@Manny-r31

Copy link
Copy Markdown
Collaborator

Close to ready. I checked the date filters, ordering, history window, paging, include_deleted, and the payment history changes against source, and they hold up. Consolidating into LogListQuery is the right call. Two things to fix before merge: the new MOS sentence now contradicts the null wording next to it, and the PR description needs an edit.

PR description

The description has a lot of internal material in it: source file paths and line numbers, class and method names, internal repo names, and commit hashes from private repos. Most of it sits in "Source anchors" and "Notes for reviewers". This repo is public, so please edit the description to keep the conclusions and drop the references. "The source orders results newest first" and "voice and message logs ignore include_deleted" are the right level. Delete the "Source anchors" table outright, and reword the RTT and include_deleted history notes as conclusions only.

Technical

1. MOS: the 4.5 sentence contradicts the null wording. specs/signalwire-rest/voice-api/logs/models/core.tsp:103 says each CallQualityMetrics field "is null when the call has no measurement for it, such as a call that never carried audio". Two lines down, audio_in_mos now says "a call that received no audio packets also scores 4.5". A reader can't tell which case gets null and which gets 4.5. As far as I can tell from source, both are true. null means the call never set up an audio stream, and 4.5 means the stream was set up but no inbound packets arrived. Say that, and point to the field that separates the two. Suggested text for the voice logs and Compatibility API audio_in_mos:

It ranges from about 1 to 4.5, where 4.5 is the best score. A call whose audio stream received no inbound packets also reports 4.5, so check audio_in_media_packet_count to tell that case from a clean call.

Make the same change in specs/compatibility-api/calls/models/core.tsp:192. In specs/compatibility-api/calls/models/webhooks.tsp:44 and fern/products/compatibility-api/pages/cxml/voice/overview.mdx:155, use AudioInMediaPacketCount instead. This also fixes "It ranges from about 1 to 4.5. 4.5 is the best score", which reads awkwardly with a sentence that opens on a numeral.

2. created_before at an exact timestamp. The source does treat the bound as "at or before", so log-list-query.tsp is right. Your own test, though, showed that passing a log's created_at as created_before left that log out. Any reader who tries the same thing will decide the docs are wrong. Your millisecond-rounding explanation fits, since response timestamps carry millisecond precision. Before merge, test whether created_at plus 1 ms brings the log back. If it does, add one sentence to created_before: "The created_at in a response is rounded to the millisecond, so to include a specific log, pass a time at least 1 ms after it." If you can't confirm it, keep the current text and leave this in the reviewer notes.

Everything else checked out against source:

  • All five log lists accept the three date filters in the formats listed, read values without an offset as UTC, and bound them inclusively.
  • created_on covers one UTC day, and lists return newest first.
  • links.next carries the filters forward.
  • The one-year window and its 422 code are correct.
  • page_size defaults to 50 with a maximum of 1000, and a page_number above 0 requires page_token.
  • Voice and message logs never return deleted activity. Fax, video, and conference logs honor include_deleted, which defaults to false.
  • Payment history returns newest first, created_before is exclusive there, and the new links example matches the real link format.
  • No parameter an endpoint supports was dropped.
  • The 4.5 score for a stream with no inbound packets checks out.

Style

3. Split the history-window sentence. specs/signalwire-rest/_globally_shared/log-list-query.tsp:56 runs about 40 words. Suggested:

Lists return at most one year of history. Logs created before the start of the UTC day one year ago are never returned. A created_before, created_on, or created_after value earlier than that returns 422 with the code exceeds_history_logs_limit.

4. Link the error code. Optional. exceeds_history_logs_limit has its own entry on the error codes page, whose slug gives /docs/apis/error-codes. Linking it on first mention in logListBehavior fits the house rule. No check covers #anchor fragments, so confirm the anchor on the preview.

5. Nit. The code comments at lines 10 and 50 of log-list-query.tsp use "honour" and "behaviour", while the rest of the specs use US spelling. They aren't emitted, so fix them only if you're in the file anyway.

Other

  • The generated output matches the source. The signalwire-rest OpenAPI diff is the per-API parameter components collapsing into LogListQuery.* plus the description, example, and MOS changes, with no unrelated removals. The Compatibility API diff is only the two MOS strings.
  • Spreading LogListQuery and declaring include_deleted only on the fax, video, and conference models, with a comment saying why, follows the shared-contract guidance in spec-conventions.
  • Pre-existing, not from this PR: specs/relay/calling/events/shared.tsp:190 gives the MOS range as "~1.0-5.0", which contradicts the 4.5 ceiling documented everywhere else. Worth a follow-up.

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

Labels

None yet

Projects

None yet

2 participants