Skip to content

Commit fe907ee

Browse files
hyperpolymathclaude
andcommitted
chore(v-ecosystem): RSR compliance + Trustfiles + docs for all v-api-interfaces modules
- Added SPDX headers to v-rest/v-graphql/v-grpc src/abi/Types.idr (were missing) - Added validated_status() bounds-checking wrapper around unsafe http.Status casts in all 8 V source files (v-rest, v-graphql, v-grpc, v-jsonrpc, v-trpc, verisimdb-rest, verisimdb-graphql, verisimdb-grpc) - Created contractiles/Trustfile.a2ml for all 12 protocol modules with module-specific threat models, invariant checks, and recovery strategies - Created README.md for verisimdb-graphql and verisimdb-grpc (were missing) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d18eba5 commit fe907ee

File tree

25 files changed

+531
-8
lines changed

25 files changed

+531
-8
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Trustfile.a2ml -- v-capnproto
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
4+
#
5+
# Contractile trust specification for the v-capnproto protocol module.
6+
# Evaluated by the contractile-cli (must/trust/dust/intend/k9) toolchain.
7+
8+
[trust]
9+
post-quantum-keys = "pending"
10+
threat-model = "network-facing-binary"
11+
formal-verification = "idris2-abi"
12+
audit-status = "unaudited"
13+
14+
[must]
15+
invariant-checks = ["input-validation", "bounds-checking", "utf8-validation", "segment-bounds-checking", "pointer-traversal-limit"]
16+
build-contract = "v build src/"
17+
18+
[dust]
19+
recovery = "reconnect-with-backoff"
20+
rollback = "discard-segment-and-retry"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Trustfile.a2ml -- v-graphql
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
4+
#
5+
# Contractile trust specification for the v-graphql protocol module.
6+
# Evaluated by the contractile-cli (must/trust/dust/intend/k9) toolchain.
7+
8+
[trust]
9+
post-quantum-keys = "pending"
10+
threat-model = "network-facing-query"
11+
formal-verification = "idris2-abi"
12+
audit-status = "unaudited"
13+
14+
[must]
15+
invariant-checks = ["input-validation", "bounds-checking", "utf8-validation", "query-depth-limit", "introspection-control"]
16+
build-contract = "v build src/"
17+
18+
[dust]
19+
recovery = "retry-with-partial-data"
20+
rollback = "return-error-response"

v-ecosystem/v-api-interfaces/v-graphql/src/abi/Types.idr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- SPDX-License-Identifier: PMPL-1.0-or-later
2+
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
--
14
module VApi.ABI.Types
25

36
import Data.Bits

v-ecosystem/v-api-interfaces/v-graphql/src/graphql.v

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,19 @@ fn gnosis_health() GnosisHealthResult {
261261

262262
// --- Helpers ---
263263

264+
// validated_status converts an integer HTTP status code to http.Status
265+
// with bounds checking to avoid unsafe casts.
266+
fn validated_status(code int) http.Status {
267+
// HTTP status codes are 100-599; default to 200 OK if out of range.
268+
if code >= 100 && code <= 599 {
269+
return unsafe { http.Status(code) }
270+
}
271+
return .ok
272+
}
273+
264274
fn json_response(status_code int, body string) http.Response {
265275
return http.new_response(
266-
status: unsafe { http.Status(status_code) }
276+
status: validated_status(status_code)
267277
header: http.new_header(key: .content_type, value: 'application/json')
268278
body: body
269279
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Trustfile.a2ml -- v-grpc
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
4+
#
5+
# Contractile trust specification for the v-grpc protocol module.
6+
# Evaluated by the contractile-cli (must/trust/dust/intend/k9) toolchain.
7+
8+
[trust]
9+
post-quantum-keys = "pending"
10+
threat-model = "network-facing-rpc"
11+
formal-verification = "idris2-abi"
12+
audit-status = "unaudited"
13+
14+
[must]
15+
invariant-checks = ["input-validation", "bounds-checking", "utf8-validation", "message-size-limit", "metadata-validation"]
16+
build-contract = "v build src/"
17+
18+
[dust]
19+
recovery = "retry-with-backoff"
20+
rollback = "return-status-error"

v-ecosystem/v-api-interfaces/v-grpc/src/abi/Types.idr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- SPDX-License-Identifier: PMPL-1.0-or-later
2+
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
--
14
module VApi.ABI.Types
25

36
import Data.Bits

v-ecosystem/v-api-interfaces/v-grpc/src/grpc.v

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,19 @@ fn gnosis_health() GnosisHealthResult {
271271

272272
// --- Helpers ---
273273

274+
// validated_status converts an integer HTTP status code to http.Status
275+
// with bounds checking to avoid unsafe casts.
276+
fn validated_status(code int) http.Status {
277+
// HTTP status codes are 100-599; default to 200 OK if out of range.
278+
if code >= 100 && code <= 599 {
279+
return unsafe { http.Status(code) }
280+
}
281+
return .ok
282+
}
283+
274284
fn grpc_response(status_code int, body string) http.Response {
275285
return http.new_response(
276-
status: unsafe { http.Status(status_code) }
286+
status: validated_status(status_code)
277287
header: http.new_header(key: .content_type, value: 'application/grpc+json')
278288
body: body
279289
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Trustfile.a2ml -- v-jsonrpc
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
4+
#
5+
# Contractile trust specification for the v-jsonrpc protocol module.
6+
# Evaluated by the contractile-cli (must/trust/dust/intend/k9) toolchain.
7+
8+
[trust]
9+
post-quantum-keys = "pending"
10+
threat-model = "network-facing-rpc"
11+
formal-verification = "idris2-abi"
12+
audit-status = "unaudited"
13+
14+
[must]
15+
invariant-checks = ["input-validation", "bounds-checking", "utf8-validation", "json-schema-validation", "id-deduplication"]
16+
build-contract = "v build src/"
17+
18+
[dust]
19+
recovery = "retry-with-id-dedup"
20+
rollback = "return-error-response"

v-ecosystem/v-api-interfaces/v-jsonrpc/src/jsonrpc.v

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ pub fn (s Server) start() {
185185

186186
// --- Helpers ---
187187

188+
// validated_status converts an integer HTTP status code to http.Status
189+
// with bounds checking to avoid unsafe casts.
190+
fn validated_status(code int) http.Status {
191+
// HTTP status codes are 100-599; default to 200 OK if out of range.
192+
if code >= 100 && code <= 599 {
193+
return unsafe { http.Status(code) }
194+
}
195+
return .ok
196+
}
197+
188198
fn error_response(id json.Any, code int, message string) Response {
189199
return Response{
190200
id: id
@@ -209,7 +219,7 @@ fn encode_response(resp Response) string {
209219

210220
fn json_resp(status_code int, body string) http.Response {
211221
return http.new_response(
212-
status: unsafe { http.Status(status_code) }
222+
status: validated_status(status_code)
213223
header: http.new_header(key: .content_type, value: 'application/json')
214224
body: body
215225
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Trustfile.a2ml -- v-mqtt
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
4+
#
5+
# Contractile trust specification for the v-mqtt protocol module.
6+
# Evaluated by the contractile-cli (must/trust/dust/intend/k9) toolchain.
7+
8+
[trust]
9+
post-quantum-keys = "pending"
10+
threat-model = "network-facing-pubsub"
11+
formal-verification = "idris2-abi"
12+
audit-status = "unaudited"
13+
14+
[must]
15+
invariant-checks = ["input-validation", "bounds-checking", "utf8-validation", "topic-filter-validation", "qos-level-bounds"]
16+
build-contract = "v build src/"
17+
18+
[dust]
19+
recovery = "reconnect-with-backoff"
20+
rollback = "close-and-reopen"

0 commit comments

Comments
 (0)