Skip to content

Commit 7b13c27

Browse files
committed
feat(clients): client sessions with a recorded traffic log, phase C1 (D-0077)
harness-clients is the client-session service of CLIENT-TESTING.md: each session is a reference storage and authorization server of its own, mounted under {base}/s/{sid}/, with a session API, a session page, and a log of every request the client sends, redacted and annotated (what it addressed, whose token, how presented, whether the session handed out the URL, what the URL advertised). Bounds and expiry per section 8.2. RefLwsServer and RefAuthorizationServer can now be mounted in another server, containment no longer follows paths, and six traps (opaque pages and linksets, flat URLs, PUT only for text, a decoy realm, index lag) are off by default. A new self-test scenario runs every definition with all traps set: all 203 pass. It found type-search-content-location-protected assuming nested URLs; it now checks for a type fragment instead. Reads now advertise Allow and Accept-Patch.
1 parent 5c49679 commit 7b13c27

30 files changed

Lines changed: 3165 additions & 84 deletions

File tree

‎CLIENT-TESTING.md‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ Its URLs:
124124

125125
| Path | What it is |
126126
|---|---|
127-
| `{base}/s/{sid}/storage/` | the storage: its storage description and root container |
128-
| `{base}/s/{sid}/as/` | the authorization server: RFC 8414 metadata, JWKS, token endpoint |
129-
| `{base}/s/{sid}/op/` | the OpenID Provider: discovery, JWKS, authorize, token, login form |
130-
| `{base}/s/{sid}/id/{name}` | alice's and bob's identity documents (CID suite) |
131-
| `{base}/s/{sid}/_t/…` | trap resources (§6.1) |
127+
| `{base}/s/{sid}/storage/` | the storage: its storage description and root container; resources it names under `_r/`, trap URLs under `_t/` (§6.1) |
128+
| `{base}/s/{sid}/as/` | the authorization server: JWKS and token endpoint. Its RFC 8414 metadata is at `/.well-known/lws-configuration{base path}/s/{sid}/as` |
129+
| `{base}/s/{sid}/op/` | the OpenID Provider: discovery, JWKS, authorize, token, login form (C4) |
130+
| `{base}/s/{sid}/id/{name}` | alice's and bob's identity documents (CID suite; C4) |
132131

133132
Paths, not hostnames, separate sessions, so one reverse-proxy rule covers the service.
134133
LWS URIs are opaque to clients, so the prefix costs nothing.
@@ -163,12 +162,17 @@ tested once.
163162

164163
### 4.4 Session API
165164

166-
Plain HTTP and JSON, authenticated with the session key as a Bearer token:
167-
- `POST {base}/sessions` creates a session and returns its id, key and URLs. It is
168-
rate-limited, and may need sign-in (§12).
165+
Plain HTTP and JSON, authenticated with the session key as a Bearer token. Phase C1 built
166+
everything here except results, faults and reset, which come with phases C2 and C3;
167+
[harness-clients/README.md](harness-clients/README.md) documents what exists.
168+
- `POST {base}/sessions` creates a session and returns its id, key and URLs, and access
169+
tokens for alice and bob. It is rate-limited, and may need sign-in (§12).
170+
- `GET {base}/sessions/{sid}` describes the session; `POST {base}/sessions/{sid}/tokens/{name}`
171+
hands out a fresh token; `GET {base}/sessions/{sid}/page` is the session page, which reads
172+
the key from its URL's fragment.
169173
- `GET {base}/sessions/{sid}/results` returns results as JSON, or as EARL or JUnit XML with
170174
`?format=`.
171-
- `GET {base}/sessions/{sid}/exchanges` returns the traffic log, paged and redacted.
175+
- `GET {base}/sessions/{sid}/exchanges?after=N` returns the traffic log, paged and redacted.
172176
- `POST {base}/sessions/{sid}/faults` arms a fault, the same as ticking a fault task.
173177
- `POST {base}/sessions/{sid}/reset` resets results; `DELETE {base}/sessions/{sid}` ends
174178
the session.
@@ -284,11 +288,12 @@ without noticing; clients relying on unspecified behaviour trip over them.
284288
default and can be switched off on the session page, to separate this trap from other
285289
problems.
286290
- **Opaque linkset URLs.** A linkset is reachable only through `rel="linkset"`.
287-
- **Only some methods advertised.** Some resources omit PUT from `Allow`, and
288-
`Accept-Patch` lists a single format.
289-
- **A decoy resource** listed in the root container, which answers `401` with a challenge
290-
whose `realm` does not contain it (`authz-challenge-realm-param`). A conformant client
291-
neither requests nor presents a token for it.
291+
- **Only some methods advertised.** Binary data resources (any media type but text, JSON, XML
292+
or an RDF syntax) refuse PUT and omit it from `Allow`, and `Accept-Patch` lists a single
293+
format.
294+
- **A decoy resource** listed first in the root container, which answers `401` with a
295+
challenge whose `realm` does not contain it (`authz-challenge-realm-param`). A conformant
296+
client neither requests nor presents a token for it.
292297
- **A lagging index.** Search and type-index results trail writes by a few seconds, as
293298
`client-no-read-your-writes` allows.
294299

@@ -469,13 +474,15 @@ Gate 2 did for the server-side schema.
469474
when their type exists (C2). Coverage everywhere counts the server-side requirements only.
470475
*Done when:* COVERAGE.md lists client requirements separately, generated from the tags.
471476
Section 11 points to that list.
472-
- **C1: session deployment.**
477+
- **C1: session deployment. Done 2026-10-05 (D-0077).**
473478
- `RefLwsServer`'s state split from its lifecycle, and the session manager.
474479
- The recorder and URL ledger, the traps, and quotas and expiry.
475480
- The session API without results, and a page showing only the traffic log.
476481
477482
*Done when:* `curl` with a session token can create, list and delete in a session's
478-
storage, and the log shows the redacted exchanges with their annotations.
483+
storage, and the log shows the redacted exchanges with their annotations. The traps also
484+
passed the server-side check: every definition passes against a reference deployment with
485+
them set.
479486
- **C2: rules.**
480487
- Gate C.
481488
- The new format version: schema, loader and lint for `ObservationTest`.

‎DECISIONS.md‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,3 +2525,83 @@ or a fixture catalog, counts as server-side.
25252525
cites `access-jsonld-context-lws-v1`.
25262526

25272527
Drafted by an agent; waits on branch `catalog/conformance-classes`.
2528+
2529+
### D-0077 — client sessions (phase C1): a mountable reference deployment, legal traps, a recorded traffic log
2530+
The new module `harness-clients` is the client-session service of CLIENT-TESTING.md. It is plain
2531+
embedded Jetty and depends on `harness-fixtures`. Each session is a reference storage and
2532+
authorization server of its own under `{base}/s/{sid}/`, with the session API, a session page
2533+
and a traffic log. Phase C1's acceptance holds: `curl` with a session token creates, lists and
2534+
deletes, and the log shows each exchange redacted and annotated.
2535+
2536+
**The reference servers mount.**
2537+
- `RefLwsServer.mounted(storageUri, as, owner, traps)` and `RefAuthorizationServer.mounted(issuer)`
2538+
build servers without a Jetty server of their own; `handler()` serves them inside another.
2539+
- A mounted storage builds its URLs from its public URI, not from the request, so it works
2540+
behind a reverse proxy.
2541+
- A mounted authorization server's issuer has a path, so its metadata is where RFC 8414 section
2542+
3.1 puts it: `/.well-known/lws-configuration` followed by that path.
2543+
- `TokenValidator` takes the authorization server's keys in process.
2544+
- The standalone servers and the self-test are unchanged.
2545+
2546+
**Containment is no longer read from paths.** A stored resource records its container, so:
2547+
- `rel="up"`, deletion and subscription topics work for URLs that do not nest;
2548+
- a topic covers a resource when it is one of the resource's ancestors, not a prefix of its URL;
2549+
- topic and search lookups map a URI to a path through the storage's base.
2550+
2551+
**Traps** (`Traps`, CLIENT-TESTING.md section 6.1) are off by default:
2552+
- opaque page URLs;
2553+
- flat resource URLs;
2554+
- opaque linkset URLs;
2555+
- PUT only on text, JSON, XML and RDF media types;
2556+
- a decoy, listed first in the root so that a client reading one page meets it;
2557+
- an index lag.
2558+
2559+
A new self-test scenario, `TRAPPED`, runs every definition against a secured deployment with all
2560+
traps set and a 1-second lag. All 203 pass, which is what shows the traps are legal.
2561+
2562+
**The trapped self-test found a definition that assumed nested URIs.**
2563+
- `type-search-content-location-protected` found alice's search result by her test
2564+
container's path in the result's id, and checked bob's answer for that path.
2565+
- With flat URLs neither works, and the test went inapplicable after a minute of polling.
2566+
- It now gives her resource a type whose fragment, `#ContentLocationProtectedSecret`, appears
2567+
nowhere else. A precondition requires her result to carry that type (lws10-index: "each item
2568+
... MUST carry at least the matched resource's id and its type"), and the check looks for the
2569+
fragment in bob's answer.
2570+
- It still fails against the broken storage.
2571+
2572+
**One change to the reference's behaviour:** every read now advertises the methods the resource
2573+
supports in `Allow`, and for a data resource the patch format in `Accept-Patch`. That is the
2574+
core MUST that servers "use standard HTTP headers to advertise their capabilities", and it is
2575+
what a client is told to check. No definition's outcome changed. The class comment's claim that
2576+
deliveries are unsigned and never retried, stale since D-0066 and D-0070, is corrected.
2577+
2578+
**The traffic log.**
2579+
- The storage marks each request with what it addressed and whose valid token it carried.
2580+
- The service records every request to a session's storage and authorization server, with:
2581+
- its answer, the response body kept up to 64 KiB;
2582+
- how the token was presented, and its fingerprint (the first twelve hex digits of its
2583+
SHA-256);
2584+
- what the URL last advertised.
2585+
- Credential headers, `access_token` in a query, and the credential fields of token requests and
2586+
responses are fingerprinted, never kept.
2587+
- The URL ledger learns what each answer hands out:
2588+
- the URLs in `Location`, `Content-Location` and `Link`;
2589+
- a challenge's `as_uri`, with the metadata URL RFC 8414 derives from it;
2590+
- the session URLs in the JSON the server generates.
2591+
2592+
A request outside the ledger is marked built by the client. CORS preflights are answered and
2593+
recorded.
2594+
2595+
**Sessions.**
2596+
- The id is 96 random bits, and public.
2597+
- The key is 256 random bits, shown once and stored as a SHA-256 hash, compared in constant time.
2598+
- The session page reads the key from its URL's fragment, which never reaches the server or a
2599+
Referer, and calls the API with it. It is served with a strict Content Security Policy and
2600+
writes what clients sent only as text.
2601+
- The bounds are those of section 8.2, with defaults in `ClientLabConfig`.
2602+
- Notifications are not delivered from a session (`deliverOnlyTo(uri -> false)`) until phase C5
2603+
brings the outbound guard.
2604+
- Identity documents and the session OpenID Provider are phase C4. Until then a client
2605+
authenticates with the tokens the session hands out.
2606+
2607+
Drafted by an agent; waits on branch `clients/c1-sessions`.

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and `CLAUDE.md` (session ground rules) before working on this repo.
3535
|---|---|
3636
| `harness-core` | catalog, the definitions loader and lint, the engine, identities and credentials, reporting — no Spring |
3737
| `harness-fixtures` | reference LWS server (open/secured/broken), reference authorization server (and its broken twin), the reference deployment the self-test loop runs against |
38+
| `harness-clients` | client-session service for testing LWS clients ([CLIENT-TESTING.md](CLIENT-TESTING.md)): a reference storage and authorization server per session, every request recorded; `java -jar harness-clients/target/touchstone-clients.jar` |
3839
| `harness-cli` | picocli front end (`run`, `coverage`, `diff`) |
3940
| `harness-mcp` | Spring AI MCP server over the core engine |
4041
| `catalog/` | requirements catalog (Turtle), 5 spec modules, versioned per spec draft |

‎definitions/lws10/index/manifest.yamlld‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,9 +2951,11 @@ entries:
29512951
across clients". alice searches for a type only her private resource has. If her answer
29522952
carries a Content-Location, bob fetching it must not see her resource: he may be refused,
29532953
or answered with what he may read, but alice's result set must not reach him. Applies only
2954-
when the search response carries Content-Location. The check reads bob's body for the path
2955-
of this test's container, which every one of alice's results contains (a precondition makes
2956-
sure), so it holds whether bob's answer is a refusal, empty, or a filtered page.
2954+
when the search response carries Content-Location. The check reads bob's body for the
2955+
fragment of the type only alice's resource has, which her result carries ("each item ...
2956+
MUST carry at least the matched resource's id and its type"; a precondition makes sure), so
2957+
it holds whether bob's answer is a refusal, empty, or a filtered page. It looks for the type,
2958+
not for a path: a resource's URI need not lie under its container's.
29572959
status: Proposed
29582960
level: MUST
29592961
source:
@@ -2967,10 +2969,10 @@ entries:
29672969
hierarchy:
29682970
- dataResource: secret
29692971
contentType: text/turtle
2970-
body: "<> a <${test.container}#Secret> ."
2972+
body: "<> a <${test.container}#ContentLocationProtectedSecret> ."
29712973
linkHeaders:
29722974
- rel: type
2973-
href: "${test.container}#Secret"
2975+
href: "${test.container}#ContentLocationProtectedSecret"
29742976
steps:
29752977
- label: the storage offers a Type Search Service (otherwise this test does not apply)
29762978
precondition: true
@@ -2985,32 +2987,32 @@ entries:
29852987
some:
29862988
- pointer: /type
29872989
hasValue: TypeSearchService
2988-
- label: alice's search finds her resource, under this test's container (otherwise this test does not apply)
2990+
- label: alice's search finds her resource, with its type (otherwise this test does not apply)
29892991
precondition: true
29902992
poll: {within: 60, every: 3}
29912993
request:
29922994
method: QUERY
29932995
url: "${service.TypeSearchService}"
29942996
contentType: application/lws-query+json
29952997
bodyJSON:
2996-
type: ["${test.container}#Secret"]
2998+
type: ["${test.container}#ContentLocationProtectedSecret"]
29972999
response:
29983000
statusCode: 200
29993001
json:
30003002
- pointer: /items
30013003
some:
30023004
- pointer: /id
30033005
equalsIri: "${secret}"
3004-
- pointer: /id
3005-
matches: 'type-search-content-location-protected/'
3006+
- pointer: /type
3007+
hasValue: "${test.container}#ContentLocationProtectedSecret"
30063008
- label: the search response names a result resource (otherwise this test does not apply)
30073009
precondition: true
30083010
request:
30093011
method: QUERY
30103012
url: "${service.TypeSearchService}"
30113013
contentType: application/lws-query+json
30123014
bodyJSON:
3013-
type: ["${test.container}#Secret"]
3015+
type: ["${test.container}#ContentLocationProtectedSecret"]
30143016
response:
30153017
statusCode: 200
30163018
otherHeaders:
@@ -3024,4 +3026,4 @@ entries:
30243026
url: "${results}"
30253027
response:
30263028
statusCode: ["2xx", "4xx"]
3027-
bodyMatches: '^(?![\s\S]*type-search-content-location-protected/)'
3029+
bodyMatches: '^(?![\s\S]*#ContentLocationProtectedSecret)'

‎docs/how-it-works.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Touchstone is a Java 21 Maven project with four modules, plus the data they oper
1818
|---|---|
1919
| `harness-core` | The engine: catalog loading, the definitions loader and lint, the engine that runs them, identities and credentials, and every report writer. It has no Spring dependency, so every front end can use it. |
2020
| `harness-fixtures` | Servers Touchstone controls: the reference LWS server, the reference authorization server, and broken twins of both. |
21+
| `harness-clients` | The client-session service, for testing LWS clients: each session is a reference storage and authorization server of its own, with every request recorded ([CLIENT-TESTING.md]({% include src.html path="CLIENT-TESTING.md" %})). |
2122
| `harness-cli` | The `touchstone` command (`run`, `coverage`, `diff`), built as one runnable jar. |
2223
| `harness-mcp` | A Model Context Protocol server over the same engine, for AI agents. |
2324
| `catalog/` | The requirements catalog: one Turtle file per specification document. |
@@ -183,6 +184,12 @@ provides both.
183184
`401` with a challenge for a missing or invalid token and `403` for a valid agent
184185
without access, and honours grants;
185186
- `BROKEN`: claims to protect resources but never challenges or refuses.
187+
188+
It can also set traps: behaviour the drafts allow but a client must not assume away. Page
189+
and linkset URLs are opaque, resource URLs do not nest under their container's, binary
190+
resources refuse PUT, a decoy in the root challenges with a foreign realm, and the index
191+
lags behind writes. Client sessions set them all; the server self-test sets them once, to
192+
prove they are legal.
186193
- **`RefAuthorizationServer`** publishes RFC 8414 metadata and a JWKS, and exchanges
187194
CID (HTTPS and did:key subjects), OpenID Connect and SAML subject tokens for access
188195
tokens (RFC 8693), validating each the way its suite says. Its broken twin exchanges anything.
@@ -191,13 +198,17 @@ provides both.
191198

192199
`./mvnw verify` runs the loop in `DefinitionsSelfTest`:
193200

194-
- against the secured deployment, all 101 definitions run, and every one passes except
195-
the notification test, which is inapplicable because the reference advertises no
196-
notification service it does not have;
201+
- against the secured deployment, all 203 definitions run, and every one passes except the
202+
single-page pagination test, which is inapplicable because the reference splits that
203+
container into pages;
204+
- against the same deployment with every trap set, the same holds: a definition that failed
205+
there would assume something the drafts leave open;
197206
- against an open storage, exactly the tests that need authentication are inapplicable;
198-
- against the broken authorization server, the 19 credential tests of the three
207+
- against the broken authorization server, the 26 negative tests of the three
199208
authentication suites fail, and so does the unknown-storage test;
200-
- against the broken storage, its 14 access-control tests fail.
209+
- against the broken storage, its 23 access-control tests fail;
210+
- against a storage that leaks notifications, the two delivery-authorization tests and the
211+
signature test fail.
201212

202213
Each broken twin fails exactly the tests that exist to catch it, which is what shows those
203214
tests can fail.

0 commit comments

Comments
 (0)