field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

commit 3aead36faf2ce5f45bd4280e1bdaa9a693ad8abc
parent 7442bb50026bc179f6405fd1cbebb7a0591d3036
Author: triesap <tyson@radroots.org>
Date:   Sat,  3 Oct 2026 03:42:53 +0000

test: retain healthy idle fixture connections

- Keep idle WebSockets open while the fixture is active
- Preserve handshake and partial frame read deadlines
- Cover idle continuation and incomplete frames with real sockets
- Verify tooling and the complete affected standalone lane

Diffstat:
MTeraFFI/provenance.json | 26+++++++++++++-------------
MTeraFFI/source.lock | 4++--
MTeraFFI/source/aarch64-apple-darwin.json | 20+++++++++++++-------
MTeraFFI/source/aarch64-apple-ios-sim.json | 20+++++++++++++-------
MTeraFFI/source/aarch64-apple-ios.json | 20+++++++++++++-------
Mrelease/provenance.json | 4++--
Mscripts/local-social-fixture.py | 4++++
Ascripts/test_local_social_relay.py | 126+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscripts/verify-package-contract.sh | 1+
9 files changed, 187 insertions(+), 38 deletions(-)

diff --git a/TeraFFI/provenance.json b/TeraFFI/provenance.json @@ -92,19 +92,19 @@ "sha256": "e1c4926a9eef1db20cf5e0b7c17c6afae45773d88f7743502ccb5dcb4eab26ae" }, { - "bytes": 142758, + "bytes": 143011, "path": "source/aarch64-apple-darwin.json", - "sha256": "be9a93016ca96304f26018a10b863f9be976fc7229254d2f5194fa26d800e680" + "sha256": "598ddf533e91ed2a3dfe3b4b6827a3e823eae1a09825bc28d28a43e8c2bf78e1" }, { - "bytes": 142602, + "bytes": 142855, "path": "source/aarch64-apple-ios-sim.json", - "sha256": "37fbe08857dc690fced458e81bac0ed014cf29fc588b507c6fc708406d5586b4" + "sha256": "c2c0c58ad1ad7ee77d8baf3490899af3e34d54b73e8940072c6768f077876aba" }, { - "bytes": 142598, + "bytes": 142851, "path": "source/aarch64-apple-ios.json", - "sha256": "7b822bf8afea5bbaf5afc7dc099f5d5fc9140f8dacaf93696720d348a82143c3" + "sha256": "48331bc6eeb9a86247a167089e840a1302fb8087a994ba69faf158c35d0b8939" } ], "language": "swift", @@ -112,7 +112,7 @@ "schema": "radroots.artifact-manifest.v2", "source": { "repository": "https://github.com/radrootslabs/tera", - "tree": "3f78cda10ef2c45f49b887f38619ce75dcc0eec0" + "tree": "2b657cd1eb84af0fd5559c9e841845b489e9ef80" }, "source_records": { "aarch64-apple-darwin": "source/aarch64-apple-darwin.json", @@ -174,19 +174,19 @@ "sha256": "5d74060f97e52dad69ab7567c16d6b6b34acfab846f468450d89e2394a8a69d5" }, { - "bytes": 142758, + "bytes": 143011, "path": "TeraFFI/source/aarch64-apple-darwin.json", - "sha256": "be9a93016ca96304f26018a10b863f9be976fc7229254d2f5194fa26d800e680" + "sha256": "598ddf533e91ed2a3dfe3b4b6827a3e823eae1a09825bc28d28a43e8c2bf78e1" }, { - "bytes": 142602, + "bytes": 142855, "path": "TeraFFI/source/aarch64-apple-ios-sim.json", - "sha256": "37fbe08857dc690fced458e81bac0ed014cf29fc588b507c6fc708406d5586b4" + "sha256": "c2c0c58ad1ad7ee77d8baf3490899af3e34d54b73e8940072c6768f077876aba" }, { - "bytes": 142598, + "bytes": 142851, "path": "TeraFFI/source/aarch64-apple-ios.json", - "sha256": "7b822bf8afea5bbaf5afc7dc099f5d5fc9140f8dacaf93696720d348a82143c3" + "sha256": "48331bc6eeb9a86247a167089e840a1302fb8087a994ba69faf158c35d0b8939" } ], "schema": "tera.installed-native-artifacts.v1" diff --git a/TeraFFI/source.lock b/TeraFFI/source.lock @@ -1,7 +1,7 @@ schema = "tera.installed-source.v1" repository = "https://github.com/radrootslabs/tera" -source_tree = "3f78cda10ef2c45f49b887f38619ce75dcc0eec0" -manifest_sha256 = "84fbc1e9a9f87da799629d1194660d4f8bdd7245b8b390c3fbebe4989577de05" +source_tree = "2b657cd1eb84af0fd5559c9e841845b489e9ef80" +manifest_sha256 = "9309f414a72871dd586a09068b8d8678cdf527481983f06d5989713392149d3b" source_date_epoch = 1787871027 [foundation] diff --git a/TeraFFI/source/aarch64-apple-darwin.json b/TeraFFI/source/aarch64-apple-darwin.json @@ -2878,10 +2878,10 @@ "sha256": "087faddef16e99f10bb7ad7b39d649e7e410b558ed1f9f4f4e498ab861eea622" }, "scripts/local-social-fixture.py": { - "bytes": 100862, - "git_blob": "2246c8d14a780f282be9bb5dce3ae51e6ce3e5e2", + "bytes": 101032, + "git_blob": "4cbe745064f3bed7a9c0a359c40dd5996c5d7478", "mode": "100644", - "sha256": "c1eb9051388f99b0aae5a8211108565f414ae90fec9cb6876b76bd1c68440631" + "sha256": "31b482693d217eb2859847e197c434c43fc104da63917d93e11c69ebfebca9a0" }, "scripts/local_social_test_support.py": { "bytes": 582, @@ -2997,6 +2997,12 @@ "mode": "100644", "sha256": "81ff78918d1c7ef642f1ebc598d48ea0d8445ea31be783493a0d75581b0d73b1" }, + "scripts/test_local_social_relay.py": { + "bytes": 4454, + "git_blob": "1d2ab5387568effe45fcbc9ce2f4c0782272ab1e", + "mode": "100644", + "sha256": "8e9fad61bc7d1c951502ecc4c1305db7bbf51d426cd5fd4c445443884509e5da" + }, "scripts/test_maintainability_ratchet.py": { "bytes": 6308, "git_blob": "7d1cb1bb3a154895640f2e6d83a6f8a6e29367f1", @@ -3022,10 +3028,10 @@ "sha256": "a917dfbc1d8ecac7d1539670651e4b468059bc77dfe31aeefbc6c6eb21bebbfb" }, "scripts/verify-package-contract.sh": { - "bytes": 1575, - "git_blob": "7dd58131736db25391e8731d21d0137d00c16a2a", + "bytes": 1614, + "git_blob": "170f25c675b29871a46cbfa5675a5d8cf919eebb", "mode": "100755", - "sha256": "682ca03f4cb6aec0ea5d2e5c4205d36cfb3c41b6207e8bff3fa0329be29d6a92" + "sha256": "e9f3dfdc2932b7a5b32154c08c8ff4512f80ff40ebd05f1ee8d0a2154fa14441" }, "scripts/xcode.sh": { "bytes": 22437, @@ -3041,6 +3047,6 @@ } }, "policy": "staged_inputs", - "tree": "3f78cda10ef2c45f49b887f38619ce75dcc0eec0" + "tree": "2b657cd1eb84af0fd5559c9e841845b489e9ef80" } } diff --git a/TeraFFI/source/aarch64-apple-ios-sim.json b/TeraFFI/source/aarch64-apple-ios-sim.json @@ -2874,10 +2874,10 @@ "sha256": "087faddef16e99f10bb7ad7b39d649e7e410b558ed1f9f4f4e498ab861eea622" }, "scripts/local-social-fixture.py": { - "bytes": 100862, - "git_blob": "2246c8d14a780f282be9bb5dce3ae51e6ce3e5e2", + "bytes": 101032, + "git_blob": "4cbe745064f3bed7a9c0a359c40dd5996c5d7478", "mode": "100644", - "sha256": "c1eb9051388f99b0aae5a8211108565f414ae90fec9cb6876b76bd1c68440631" + "sha256": "31b482693d217eb2859847e197c434c43fc104da63917d93e11c69ebfebca9a0" }, "scripts/local_social_test_support.py": { "bytes": 582, @@ -2993,6 +2993,12 @@ "mode": "100644", "sha256": "81ff78918d1c7ef642f1ebc598d48ea0d8445ea31be783493a0d75581b0d73b1" }, + "scripts/test_local_social_relay.py": { + "bytes": 4454, + "git_blob": "1d2ab5387568effe45fcbc9ce2f4c0782272ab1e", + "mode": "100644", + "sha256": "8e9fad61bc7d1c951502ecc4c1305db7bbf51d426cd5fd4c445443884509e5da" + }, "scripts/test_maintainability_ratchet.py": { "bytes": 6308, "git_blob": "7d1cb1bb3a154895640f2e6d83a6f8a6e29367f1", @@ -3018,10 +3024,10 @@ "sha256": "a917dfbc1d8ecac7d1539670651e4b468059bc77dfe31aeefbc6c6eb21bebbfb" }, "scripts/verify-package-contract.sh": { - "bytes": 1575, - "git_blob": "7dd58131736db25391e8731d21d0137d00c16a2a", + "bytes": 1614, + "git_blob": "170f25c675b29871a46cbfa5675a5d8cf919eebb", "mode": "100755", - "sha256": "682ca03f4cb6aec0ea5d2e5c4205d36cfb3c41b6207e8bff3fa0329be29d6a92" + "sha256": "e9f3dfdc2932b7a5b32154c08c8ff4512f80ff40ebd05f1ee8d0a2154fa14441" }, "scripts/xcode.sh": { "bytes": 22437, @@ -3037,6 +3043,6 @@ } }, "policy": "staged_inputs", - "tree": "3f78cda10ef2c45f49b887f38619ce75dcc0eec0" + "tree": "2b657cd1eb84af0fd5559c9e841845b489e9ef80" } } diff --git a/TeraFFI/source/aarch64-apple-ios.json b/TeraFFI/source/aarch64-apple-ios.json @@ -2874,10 +2874,10 @@ "sha256": "087faddef16e99f10bb7ad7b39d649e7e410b558ed1f9f4f4e498ab861eea622" }, "scripts/local-social-fixture.py": { - "bytes": 100862, - "git_blob": "2246c8d14a780f282be9bb5dce3ae51e6ce3e5e2", + "bytes": 101032, + "git_blob": "4cbe745064f3bed7a9c0a359c40dd5996c5d7478", "mode": "100644", - "sha256": "c1eb9051388f99b0aae5a8211108565f414ae90fec9cb6876b76bd1c68440631" + "sha256": "31b482693d217eb2859847e197c434c43fc104da63917d93e11c69ebfebca9a0" }, "scripts/local_social_test_support.py": { "bytes": 582, @@ -2993,6 +2993,12 @@ "mode": "100644", "sha256": "81ff78918d1c7ef642f1ebc598d48ea0d8445ea31be783493a0d75581b0d73b1" }, + "scripts/test_local_social_relay.py": { + "bytes": 4454, + "git_blob": "1d2ab5387568effe45fcbc9ce2f4c0782272ab1e", + "mode": "100644", + "sha256": "8e9fad61bc7d1c951502ecc4c1305db7bbf51d426cd5fd4c445443884509e5da" + }, "scripts/test_maintainability_ratchet.py": { "bytes": 6308, "git_blob": "7d1cb1bb3a154895640f2e6d83a6f8a6e29367f1", @@ -3018,10 +3024,10 @@ "sha256": "a917dfbc1d8ecac7d1539670651e4b468059bc77dfe31aeefbc6c6eb21bebbfb" }, "scripts/verify-package-contract.sh": { - "bytes": 1575, - "git_blob": "7dd58131736db25391e8731d21d0137d00c16a2a", + "bytes": 1614, + "git_blob": "170f25c675b29871a46cbfa5675a5d8cf919eebb", "mode": "100755", - "sha256": "682ca03f4cb6aec0ea5d2e5c4205d36cfb3c41b6207e8bff3fa0329be29d6a92" + "sha256": "e9f3dfdc2932b7a5b32154c08c8ff4512f80ff40ebd05f1ee8d0a2154fa14441" }, "scripts/xcode.sh": { "bytes": 22437, @@ -3037,6 +3043,6 @@ } }, "policy": "staged_inputs", - "tree": "3f78cda10ef2c45f49b887f38619ce75dcc0eec0" + "tree": "2b657cd1eb84af0fd5559c9e841845b489e9ef80" } } diff --git a/release/provenance.json b/release/provenance.json @@ -2,7 +2,7 @@ "artifacts": { "app_api_sha256": "020924097c0d7efc33128cb8fd3d3b2026d95f57c44da71880e585aff80f070b", "ffi_api_sha256": "5d74060f97e52dad69ab7567c16d6b6b34acfab846f468450d89e2394a8a69d5", - "ffi_provenance_sha256": "84fbc1e9a9f87da799629d1194660d4f8bdd7245b8b390c3fbebe4989577de05", + "ffi_provenance_sha256": "9309f414a72871dd586a09068b8d8678cdf527481983f06d5989713392149d3b", "info_plist_sha256": "b55010dd73b34bf5ad910a888be0ea1ae45f2a5c14329fa6a57059a317bdbd42", "privacy_manifest_sha256": "0f2103257ba596fbcaeb1d6a4dffe3ae021e84c010178852c6bf500a8cfb0f19", "sbom_sha256": "f0a15c2c9ad7799539fbc52fd1fdbcf17f4046b6f86cfe0a9b8980adc0079e10", @@ -22,7 +22,7 @@ "lib_revision": "189c49b74b4bafc142b00b76b296477931139e72", "source_date_epoch": 1787871027, "swift_package_lock_sha256": "8aec408132602a249111a65903c985cca5898ec316a45916d88ba756f08ea40d", - "tera_ffi_source_tree": "3f78cda10ef2c45f49b887f38619ce75dcc0eec0", + "tera_ffi_source_tree": "2b657cd1eb84af0fd5559c9e841845b489e9ef80", "xcode_package_lock_sha256": "3656728f8251f3ea644aa150d154819766470ca7bd4f85b7c51fdf301d361d16" }, "version": "0.1.0-alpha" diff --git a/scripts/local-social-fixture.py b/scripts/local-social-fixture.py @@ -12,6 +12,7 @@ import ipaddress import json import os import re +import select import signal import socket import socketserver @@ -1183,6 +1184,9 @@ def read_exact(stream: socket.socket, length: int) -> bytes: def read_frame(stream: socket.socket) -> tuple[int, bytes] | None: try: + # Idle is not a failure vector; partial frames retain the read deadline. + while not select.select([stream], [], [], 15)[0]: + pass first, second = read_exact(stream, 2) except (ConnectionError, OSError, TimeoutError): return None diff --git a/scripts/test_local_social_relay.py b/scripts/test_local_social_relay.py @@ -0,0 +1,126 @@ +"""Real socket checks for idle versus incomplete fixture WebSocket frames.""" + +import importlib.util +import json +import select +import socket +import threading +import unittest +from contextlib import contextmanager +from pathlib import Path +from unittest import mock + +SPEC = importlib.util.spec_from_file_location( + "local_social_relay_fixture", Path(__file__).with_name("local-social-fixture.py") +) +assert SPEC is not None and SPEC.loader is not None +fixture = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(fixture) + + +def masked_frame(opcode, payload): + assert len(payload) < 126 + mask = b"test" + body = bytes(byte ^ mask[index % 4] for index, byte in enumerate(payload)) + return bytes([0x80 | opcode, 0x80 | len(payload)]) + mask + body + + +@contextmanager +def relay_socket(wait): + client, server = socket.socketpair() + errors = [] + finished = threading.Event() + state = mock.Mock() + state.query.return_value = [] + + class ScaledReadSocket: + def settimeout(self, value): + assert value == 15 + server.settimeout(0.05) + + def recv(self, length): + return server.recv(length) + + def sendall(self, value): + server.sendall(value) + + def fileno(self): + return server.fileno() + + handler = type("RelaySocketTestHandler", (fixture.RelayHandler,), {"state": state}) + + def serve(): + try: + handler(ScaledReadSocket(), ("127.0.0.1", 0), None) + except (ConnectionError, OSError) as error: + errors.append(type(error)) + finally: + server.close() + finished.set() + + with mock.patch.object(fixture, "select", mock.Mock(select=wait), create=True): + thread = threading.Thread(target=serve) + thread.start() + client.settimeout(1) + try: + client.sendall( + b"GET / HTTP/1.1\r\nUpgrade: websocket\r\n" + b"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n\r\n" + ) + response = client.recv(4096) + assert response.startswith(b"HTTP/1.1 101") + yield client, state, finished, errors + finally: + client.close() + thread.join(1) + assert not thread.is_alive(), "Fixture handler leaked after peer close" + + +class LocalSocialRelaySocketTests(unittest.TestCase): + def test_idle_connection_survives_timeout_then_answers_exact_subscription(self): + idle = threading.Event() + calls = [] + + def wait(read, write, error, timeout): + self.assertEqual(timeout, 15) + calls.append(timeout) + if len(calls) == 1: + result = select.select(read, write, error, 0.05) + self.assertFalse(result[0]) + idle.set() + return result + return select.select(read, write, error, 1) + + with relay_socket(wait) as (client, state, finished, errors): + self.assertTrue(idle.wait(1), "Idle frame boundary was not reached") + self.assertFalse(finished.is_set(), "Healthy idle connection was closed") + state.query.assert_not_called() + client.sendall(masked_frame(1, b'["REQ","idle-read",{"limit":1}]')) + first, second = fixture.read_exact(client, 2) + self.assertEqual(first, 0x81) + self.assertLess(second, 126) + payload = fixture.read_exact(client, second) + self.assertEqual(json.loads(payload), ["EOSE", "idle-read"]) + state.query.assert_called_once_with([{"limit": 1}]) + state.publish.assert_not_called() + client.sendall(masked_frame(8, b"")) + self.assertTrue(finished.wait(1)) + self.assertEqual(errors, []) + self.assertGreaterEqual(len(calls), 2) + + def test_partial_frame_still_expires_without_query_or_publication(self): + def wait(read, write, error, timeout): + self.assertEqual(timeout, 15) + return select.select(read, write, error, 1) + + with relay_socket(wait) as (client, state, finished, errors): + client.sendall(b"\x81") + self.assertTrue(finished.wait(1), "Partial frame read deadline was lost") + self.assertEqual(client.recv(1), b"") + state.query.assert_not_called() + state.publish.assert_not_called() + self.assertEqual(errors, []) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/verify-package-contract.sh b/scripts/verify-package-contract.sh @@ -23,6 +23,7 @@ sh "$repo_root/scripts/ffi-provenance.sh" contract-check scripts/test_kotlin_smoke.py \ scripts/test_xcode_selection.py \ scripts/test_local_social_fixture.py \ + scripts/test_local_social_relay.py \ scripts/test_legacy_upgrade_fixture.py )