Skip to content

feat: LWS Protocol Mode (DRAFT)#88

Draft
melvincarvalho wants to merge 2 commits intogh-pagesfrom
feature/lws-mode
Draft

feat: LWS Protocol Mode (DRAFT)#88
melvincarvalho wants to merge 2 commits intogh-pagesfrom
feature/lws-mode

Conversation

@melvincarvalho
Copy link
Copy Markdown
Contributor

Summary

Adds preliminary implementation of W3C Linked Web Storage (LWS) protocol mode as an optional configuration flag.

Status: 🚧 DRAFT - This PR captures the initial infrastructure for LWS support. Not intended for immediate merge - waiting for ecosystem signals (see #87).

Changes

Config Infrastructure

  • ✅ Added --lws-mode CLI flag
  • ✅ Added JSS_LWS_MODE environment variable support
  • ✅ Added lwsMode config file option
  • ✅ Server displays "LWS Mode: enabled (DRAFT)" in config output

Core Implementation

  • PUT restriction: In LWS mode, PUT returns 404 for non-existent resources with helpful error message suggesting POST
  • Preserves LDP mode: Default behavior unchanged (PUT creates or updates)
  • ✅ Request decoration: request.lwsMode available to all handlers

Testing

  • ✅ Basic LWS test suite (test/lws.test.js)
    • Tests PUT rejection for non-existent resources
    • Tests PUT success for updates
    • Tests POST for creation (already works)
    • Documents key LWS differences

Documentation

Key Difference

Solid/LDP Mode (default):

PUT /alice/new.json → 201 Created (creates resource)

LWS Mode:

PUT /alice/new.json → 404 Not Found (suggests POST instead)
POST /alice/ + Slug → 201 Created (required for creation)
PUT /alice/existing.json → 204 No Content (updates work)

What's NOT Implemented Yet

From the full plan in #87, this PR only implements the foundation:

  • ❌ Link header-based container detection (still uses trailing slash)
  • ❌ Linkset metadata endpoints (/resource;linkset)
  • ❌ JSON Merge Patch for metadata
  • ❌ Full test matrix (only basic tests included)

These are intentionally deferred until we see ecosystem adoption.

Why This PR Exists

This PR:

  1. Captures the analysis from evaluating LWS PR Login with did:nostr #37
  2. Proves feasibility - demonstrates LWS mode can coexist with LDP
  3. Enables experimentation - developers can test LWS semantics
  4. Preserves work - when/if LWS gains traction, we have a foundation

Decision Criteria for Merge

Recommend merging when:

  • ✅ At least 3 other servers implement LWS protocol
  • ✅ At least 5 client apps use LWS endpoints
  • ✅ W3C Solid CG shows interest in LWS alignment
  • ✅ LWS spec reaches Candidate Recommendation

Current status (Jan 2026):

Testing

# Run LWS-specific tests
npm test -- test/lws.test.js

# Run full suite (LWS tests are isolated)
npm test

Related

Checklist

  • Config flag infrastructure
  • Basic PUT restriction logic
  • Tests demonstrating behavior
  • README documentation
  • Full container detection (deferred)
  • Linkset endpoints (deferred)
  • Complete test matrix (deferred)

Note: Keeping as draft until ecosystem signals warrant merge. Can be rebased/updated as LWS spec evolves.

Add optional --lws-mode flag to support W3C Linked Web Storage protocol
semantics alongside current Solid/LDP implementation.

Changes:
- Add lwsMode config flag (CLI, env var, config file)
- Implement PUT restriction in LWS mode (updates only, not creation)
- Add request.lwsMode decoration in server
- Add basic LWS tests demonstrating PUT/POST behavior
- Document LWS mode in README with examples

Key difference: In LWS mode, PUT returns 404 for non-existent resources
and suggests using POST for creation (server-assigned URIs with Slug).

Status: DRAFT - LWS spec is in early stages. This captures the basic
infrastructure for future development. See issue #87 for full plan.

Related: #87
Spec: w3c/lws-protocol#37
Per Eric's clarification on Solid CG call, LWS protocol allows PUT
for resource creation - it's not forbidden. POST with Slug is the
emphasized pattern, but PUT creation is still valid.

Changes:
- Remove PUT 404 rejection in LWS mode (src/handlers/resource.js)
- Update tests to verify PUT creation works (test/lws.test.js)
- Update README to reflect correct LWS semantics
- Document that current LWS mode is infrastructure-only

LWS mode now primarily serves as foundation for future features:
- Link header-based container detection
- Linkset metadata endpoints
- JSON Merge Patch for metadata

Related: #87 (comment added with CG clarification)
@melvincarvalho
Copy link
Copy Markdown
Contributor Author

Update: PUT Restriction Removed

⚠️ Important clarification from Solid CG call: Eric confirmed that LWS allows PUT for resource creation - it's not forbidden.

Changes in Latest Commit

Removed the PUT restriction that was in the initial implementation. The PUT/POST semantics are now identical between LWS mode and default mode.

What changed:

  • ✅ Removed PUT 404 rejection in src/handlers/resource.js
  • ✅ Updated tests to verify PUT creation works
  • ✅ Updated README to reflect correct LWS semantics
  • ✅ Clarified that current LWS mode is infrastructure-only

Current Status

The --lws-mode flag now serves as infrastructure foundation with no behavioral changes:

Feature Status
Config flag ✅ Implemented
PUT/POST behavior ✅ Same as default (PUT creates/updates)
Link header containers ❌ Not implemented (future)
Linkset endpoints ❌ Not implemented (future)
JSON Merge Patch ❌ Not implemented (future)

Real LWS Differentiators (for future implementation)

  1. Link header-based container detection (alternative to trailing slash)
  2. Linkset metadata endpoints (/resource;linkset)
  3. JSON Merge Patch for metadata updates
  4. POST+Slug emphasized (but PUT still allowed)

Since this now has zero behavioral impact, could potentially merge as foundation infrastructure, or keep as draft until actual LWS features are implemented.

See issue #87 for discussion: #87 (comment)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant