Skip to content

[Config json format consolidation] #2 Add JSON schema, cross-field validation, and migrate examples to new config format - #49

Merged
Soham Das (SohamDas2021) merged 6 commits into
mainfrom
user/sodas/ConsolidateConfigParams_2
Mar 26, 2026
Merged

Soham Das (SohamDas2021) merged 6 commits into
mainfrom
user/sodas/ConsolidateConfigParams_2

Conversation

@SohamDas2021

@SohamDas2021 Soham Das (SohamDas2021) commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Step 2 of multi-step consolidation process.

Adds schemas/mxc-config.v1.schema.json for editor validation and tooling. Adds platform/containment compatibility checks and schema version validation in config_parser.rs. Rewrites docs/schema.md to document the new format. Migrates all 15 example configs to use process.commandLine, containerId, lifecycle, and platform fields. All existing configs still accepted via dual-read fallback.


PR 1 ✅ Merged

  • version, containerId, process section with dual-read fallback. Vm/MicroVm enum variants.
    Manual Default for CodexRequest.

PR 2 🔄 In review -> This PR

  • schemas/mxc-config.v1.schema.json. Schema version validation. idleTimeoutMs dual-read. containerId →
    app_container_name mapping. Migrate 15 examples + 16 test configs. Update docs/schema.md.

PR 3

  • Add LifecycleConfig struct. Parse lifecycle.destroyOnExit/preservePolicy with dual-read from legacy
    fields. wslc alias for container key. Update sdk/src/types.ts, cli/README.md, cli/ARCHITECTURE.md,
    sdk/README.md.

PR 4

  • Drop script, workingDirectory, top-level timeout, container alias, appContainer.name,
    lxc.containerName, lxc.destroyOnExit, clearPolicyOnExit, removeRulesOnExit from parser. Bump
    SUPPORTED_MAJOR_VERSION to 2.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is part of the config JSON format consolidation, adding a v1 JSON Schema for editor/tooling support, introducing cross-field validation in the Rust config parser, updating documentation, and migrating example configs toward the new top-level/sectioned format.

Changes:

  • Added cross-field validation in config_parser.rs (platform↔containment compatibility + schema major version gating) and expanded test coverage.
  • Introduced schemas/mxc-config.v1.schema.json and rewrote docs/schema.md to describe the new config shape.
  • Migrated the checked-in example configs from legacy top-level fields (script, timeout, etc.) toward process.commandLine, containerId, platform, and lifecycle.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/wxc_common/src/config_parser.rs Adds platform/containment validation and schema version checks; updates/extends parser tests.
schemas/mxc-config.v1.schema.json New JSON Schema describing the “v1” config format for tooling validation/autocomplete.
docs/schema.md Updates documentation to the new schema-driven format and adds notes on validation/versioning.
examples/01_hello_world.json Migrates to process.commandLine + containerId; drops appContainer.name.
examples/02_filesystem_access.json Migrates to process.* and containerId; removes legacy policy cleanup flags.
examples/03_network_restricted.json Migrates to process.* and containerId; removes legacy network cleanup flags.
examples/04_combined_restrictions.json Migrates to process.* and containerId; removes legacy cleanup flags.
examples/05_custom_python.json Migrates to process.* and containerId; drops appContainer.name.
examples/06_network_capabilities_only.json Migrates to process.* and containerId; drops appContainer.name.
examples/07_test_delete.json Migrates to process.commandLine and containerId; drops appContainer.name.
examples/08_pwsh.json Migrates to process.commandLine and containerId; removes appContainer section previously used for naming.
examples/09_sandbox_hello_world.json Moves timeout under process.timeout for sandbox example.
examples/10_sandbox_network_isolated.json Moves timeout under process.timeout for sandbox example.
examples/11_localhost_proxy_appcontainer.json Migrates to process.* and containerId; drops appContainer.name.
examples/11_lxc_hello_world.json Migrates to process.commandLine, platform, and lifecycle; removes lxc.destroyOnExit.
examples/12_builtin_test_proxy_appcontainer.json Migrates to process.* and containerId; drops appContainer.name.
examples/12_lxc_filesystem_access.json Migrates to process.*, platform, and lifecycle; removes lxc.destroyOnExit.
examples/13_lxc_network_restricted.json Migrates to process.*, platform, and lifecycle; removes lxc.destroyOnExit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wxc_common/src/config_parser.rs Resolved
Comment thread schemas/mxc-config.v1.schema.json Resolved
Comment thread schemas/mxc-config.v1.schema.json Resolved
Comment thread schemas/mxc-config.v1.schema.json Outdated
Comment on lines +222 to +237
"wslc": {
"type": "object",
"description": "WSLC SDK-specific settings. Used when containment is 'wslc'.",
"properties": {
"image": {
"type": "string",
"default": "alpine:latest",
"description": "OCI container image name (e.g., 'python:3.12', 'ubuntu:22.04')."
},
"storagePath": {
"type": "string",
"description": "Storage path for WSLC session image store. Omit for SDK default."
}
},
"additionalProperties": false
},

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema defines WSLC settings under the top-level key wslc, but config_parser.rs currently reads WSLC settings from a top-level container object (RawConfig.container). Configs authored to this schema will therefore drop WSLC settings at runtime. Either rename the schema property to container (and document it), or update the parser to accept wslc (preferably with a dual-read fallback).

Copilot uses AI. Check for mistakes.
Comment thread schemas/mxc-config.v1.schema.json Resolved
Comment thread docs/schema.md Outdated
Comment on lines +52 to +55
"idleTimeoutMs": 300000
},

"wslc": { // WSLC SDK-specific

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs show WSLC settings under a wslc object and sandbox settings using idleTimeoutMs, but config_parser.rs currently reads WSLC settings from a top-level container object and sandbox timeout from sandbox.idleTimeout. Please align the documented field names with what the parser accepts (or explicitly call out the legacy names / dual-read behavior).

Suggested change
"idleTimeoutMs": 300000
},
"wslc": { // WSLC SDK-specific
"idleTimeout": 300000
},
"container": { // Container / WSLC SDK-specific

Copilot uses AI. Check for mistakes.
Comment thread examples/01_hello_world.json Resolved
Comment thread schemas/mxc-config.v1.schema.json Resolved
Comment thread examples/11_lxc_hello_world.json Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wxc_common/src/config_parser.rs Resolved
Comment thread schemas/mxc-config.v1.schema.json Resolved
Comment thread examples/11_lxc_hello_world.json Resolved
Comment thread examples/12_lxc_filesystem_access.json Outdated
"script": "ls -la /mnt/shared && echo 'test' > /mnt/output/result.txt && cat /mnt/output/result.txt",
"process": {
"commandLine": "ls -la /mnt/shared && echo 'test' > /mnt/output/result.txt && cat /mnt/output/result.txt"
},

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LXC example omits platform. With the new platform/containment validation in config_parser.rs, platform defaults to "windows" and this config will be rejected (LXC requires platform "linux"). Add "platform": "linux" here (and in other LXC examples) or adjust the parser defaulting behavior.

Suggested change
},
},
"platform": "linux",

Copilot uses AI. Check for mistakes.
Comment thread examples/13_lxc_network_restricted.json Outdated
Comment on lines 1 to 6
{
"script": "wget -qO- https://api.github.com/zen || echo 'Network blocked as expected'",
"process": {
"commandLine": "wget -qO- https://api.github.com/zen || echo 'Network blocked as expected'"
},
"containment": "lxc",
"lxc": {

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LXC example omits platform. With the new platform/containment validation in config_parser.rs, platform defaults to "windows" and this config will be rejected (LXC requires platform "linux"). Add "platform": "linux" here (and in other LXC examples) or adjust the parser defaulting behavior.

Copilot uses AI. Check for mistakes.
Comment thread schemas/mxc-config.v1.schema.json Outdated
"type": "object",

"anyOf": [
{ "required": ["script"] },

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This schema’s top-level anyOf requires script in one branch, but script is not defined under properties while additionalProperties is false. That makes the script branch impossible to satisfy (any document with script would be invalid). Either add script to properties (if legacy support is intended) or remove the script branch from anyOf.

Suggested change
{ "required": ["script"] },

Copilot uses AI. Check for mistakes.
Comment thread schemas/mxc-config.v1.schema.json Resolved
Comment thread schemas/mxc-config.v1.schema.json Outdated
Comment on lines +161 to +177
"appContainer": {
"type": "object",
"description": "AppContainer-specific settings. Used when containment is 'appcontainer'.",
"properties": {
"leastPrivilege": {
"type": "boolean",
"default": false,
"description": "Enforce least privilege mode."
},
"capabilities": {
"type": "array",
"items": { "type": "string" },
"default": [],
"description": "AppContainer capabilities (e.g., 'internetClient', 'registryRead')."
}
},
"additionalProperties": false

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appContainer in the parser supports fields like learningMode (and previously name), and the example configs in this PR still use learningMode, but the schema only allows leastPrivilege and capabilities with additionalProperties: false. This makes the examples/configs invalid under the published schema; either extend the schema to include the supported AppContainer fields or update the examples/docs to match the schema.

Copilot uses AI. Check for mistakes.
Comment thread docs/schema.md Resolved
Comment thread docs/schema.md
"removeRulesOnExit": true, // Remove firewall rules after execution
"proxy": { "localhost": 8080 } // Port of a localhost proxy
"defaultPolicy": "block", // "allow" or "block"
"enforcementMode": "firewall", // "capabilities", "firewall", or "both"

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs’ “Full Schema” network section omits supported firewall-list fields (allowedHosts/blockedHosts) that are parsed by config_parser.rs and used in the examples. Consider documenting these fields here (or explicitly stating they’re omitted) to avoid misleading readers.

Suggested change
"enforcementMode": "firewall", // "capabilities", "firewall", or "both"
"enforcementMode": "firewall", // "capabilities", "firewall", or "both"
"allowedHosts": ["api.example.com:443"], // Optional: hosts explicitly allowed when defaultPolicy is "block"
"blockedHosts": ["*.tracker.com"], // Optional: hosts explicitly blocked when defaultPolicy is "allow"

Copilot uses AI. Check for mistakes.
@SohamDas2021 Soham Das (SohamDas2021) changed the title [Config json format consolidation] Add JSON schema, cross-field validation, and migrate examples to new config format [Config json format consolidation] #2 Add JSON schema, cross-field validation, and migrate examples to new config format Mar 26, 2026
Comment thread docs/schema.md Outdated
"internetClient",
"privateNetworkClientServer"
]
"version": "1", // Schema version (current: "1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Versions must use SemVer. This should be 0.1.0-alpha.

@shschaefer
shschaefer self-requested a review March 26, 2026 14:03
Comment thread schemas/mxc-config.v1.schema.json Outdated
"type": "string",
"enum": ["linux", "windows"],
"default": "windows",
"description": "Host platform where wxc-exec runs. Must be compatible with the selected containment backend (e.g., AppContainer/Sandbox/WSLC require 'windows', LXC requires 'linux')."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking-out-loud: do we want to say runtime executable versus wxc-exec? But let's not focus too much on that for now.

@@ -0,0 +1,181 @@
{

@bbonaby Branden Bonaby (bbonaby) Mar 26, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the direction here with appContainer and lxc etc already being scoped into their own objects. I wonder if we should lean into that more consistently and make backend-specific configuration fully structured around the selected containment.

Right now, we have backend-specific containers:

"appContainer": { ... },
"lxc": { ... }

But there isn't a strong relationship between them. e.g

"containment": "appcontainer" | "lxc" | 

configs can technically include multiple backend sections at once and nothing enforces that only the relevant backend config is present. E.g Folks looking at the schema might think they can mix and match containment backends.

My suggestion would be to see if we can formalize this pattern, so each backend owns its own schema and is conditionally validated.
Some like:

{
  "type": "object",
  "required": [
    "containment",
    "backends"
  ],
  "properties": {
    "containment": {
      "type": "string",
      "enum": [
        "appcontainer",
        "lxc"
      ]
    },
    "backends": {
      "type": "object",
      "properties": {
        "appcontainer": {
          "$ref": "#/$defs/appContainerConfig"
        },
        "lxc": {
          "$ref": "#/$defs/lxcConfig"
        }
      },
      "additionalProperties": false
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "containment": {
            "const": "appcontainer"
          }
        }
      },
      "then": {
        "properties": {
          "backends": {
            "required": [
              "appcontainer"
            ],
            "maxProperties": 1
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "containment": {
            "const": "lxc"
          }
        }
      },
      "then": {
        "properties": {
          "backends": {
            "required": [
              "lxc"
            ],
            "maxProperties": 1
          }
        }
      }
    }
  ]
}

So then this would be valid:

{
  "containment": "lxc",
  "backends": {
    "lxc": {
      "distribution": "alpine"
    }
  }
}

and these will not be valid

{
  "containment": "lxc",
  "backends": {
    "appcontainer": {}
  }
}
{
  "containment": "lxc",
  "backends": {
    "lxc": {},
    "appcontainer": {}
  }
}
{
  "containment": "appcontainer",
  "backends": {}
}

Just a suggestion though, I thought it would be cleaner this way. This also allows what goes into Networking, Filesystem to be scoped inside the backends schema rather than at the top level. E.g today currently all of those are top level objects and not all their properties will be supported for every backend. Having each backend have their own schema imo gives us clear separation in the future. But this is all just a suggestion, I'll leave it up to you.

@SohamDas2021
Soham Das (SohamDas2021) merged commit ab5bcdd into main Mar 26, 2026
6 checks passed
@MGudgin
Gudge (MGudgin) deleted the user/sodas/ConsolidateConfigParams_2 branch April 9, 2026 14:11
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.

4 participants