Skip to content

feat: add package settings to manifest schema - #3

Merged
sabraman merged 1 commit into
mainfrom
codex/package-settings-schema
May 15, 2026
Merged

feat: add package settings to manifest schema#3
sabraman merged 1 commit into
mainfrom
codex/package-settings-schema

Conversation

@sabraman

@sabraman sabraman commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds manifest v1 schema support for package settings. The schema now accepts boolean and enum setting declarations, and the package contract documents how firmware persists those values outside package archives.

Validation

  • python3 -m json.tool schema/manifest.v1.schema.json
  • python3 tools/validate_manifest.py --profile publish ../marginalia-examples/*/manifest.json

Summary by CodeRabbit

  • New Features

    • Packages can now declare user-configurable settings with boolean and enum types.
  • Documentation

    • Added detailed documentation on how to define package settings, including supported setting types, configuration storage, and identifier stability requirements.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces a package settings feature to manifest v1 by defining a JSON Schema contract for user-configurable settings and documenting how they are persisted and used. Settings support boolean and enum types with required default values and must maintain stable identifiers across versions.

Changes

Package Settings Feature

Layer / File(s) Summary
Settings schema definition
schema/manifest.v1.schema.json
Manifest v1 now includes a top-level settings array property. Each setting is validated via oneOf to be either a boolean setting (with id, label, type: "boolean", optional default) or an enum setting (with id, label, type: "enum", non-empty unique options array, and required default string).
Settings documentation
docs/package-contract.md
Package contract specifies where firmware persists settings state in /.marginalia/package-state/<package-id>.json, lists supported types (boolean, enum), provides a manifest example declaring settings, and establishes that setting ids must remain stable across versions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A settings tale in schema and prose,
Boolean, enum—the manifest grows,
Persisted outside, stable through time,
User choices preserved in JSON's rhyme!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'feat: add package settings to manifest schema' directly and clearly summarizes the main change: adding a new 'settings' feature to the manifest schema. It accurately reflects the primary objective of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/package-settings-schema

Comment @coderabbitai help to get the list of available commands and usage tips.

@sabraman sabraman changed the title Add package settings to manifest schema feat: add package settings to manifest schema May 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/package-contract.md (1)

81-85: ⚡ Quick win

Clarify that every setting declaration must include a default value.

The section describes types and stability, but not the requirement that each setting must provide default. Adding that sentence here would keep author guidance aligned with validation behavior.

Also applies to: 101-103

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/package-contract.md` around lines 81 - 85, Add a single clear sentence
to the "Supported setting types in manifest v1" section stating that every
setting declaration must include a default value (e.g., "Each setting
declaration must include a `default` value.") and duplicate the same sentence in
the corresponding paragraph around the stability/types discussion later in the
file (the similar block near lines 101-103) so author guidance matches
validation behavior; reference the manifest version "manifest v1" and the term
`default` to make locating and verifying the change straightforward.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@schema/manifest.v1.schema.json`:
- Around line 102-103: Update the manifest schema so both setting variants
include "default" in their "required" arrays (i.e., add "default" alongside
"id","label","type") and enforce for enum settings that the declared default
appears in the "options" list; implement this either by adding a JSON Schema
constraint that validates the enum default against the "options" array or by
adding a check in tools/validate_manifest.py that verifies for each enum-type
setting the default value is present in its options array. Ensure you reference
the manifest schema's "required" array, the "default" property, and the enum
"options" property when making the changes.

---

Nitpick comments:
In `@docs/package-contract.md`:
- Around line 81-85: Add a single clear sentence to the "Supported setting types
in manifest v1" section stating that every setting declaration must include a
default value (e.g., "Each setting declaration must include a `default` value.")
and duplicate the same sentence in the corresponding paragraph around the
stability/types discussion later in the file (the similar block near lines
101-103) so author guidance matches validation behavior; reference the manifest
version "manifest v1" and the term `default` to make locating and verifying the
change straightforward.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e221bbc8-070a-4bda-a9f6-68e265b3e576

📥 Commits

Reviewing files that changed from the base of the PR and between 2e93cae and d575fe4.

📒 Files selected for processing (2)
  • docs/package-contract.md
  • schema/manifest.v1.schema.json

Comment on lines +102 to +103
"required": ["id", "label", "type"],
"properties": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

# First, locate and read the schema file
fd -t f "manifest.v1.schema.json" | head -1

Repository: marginalia-os/marginalia-sdk

Length of output: 103


🏁 Script executed:

# Read the schema file to understand its structure and size
wc -l schema/manifest.v1.schema.json

Repository: marginalia-os/marginalia-sdk

Length of output: 107


🏁 Script executed:

# Read the relevant section (lines 90-160 to get full context)
sed -n '90,160p' schema/manifest.v1.schema.json | cat -n

Repository: marginalia-os/marginalia-sdk

Length of output: 2484


🏁 Script executed:

# Check if validate_manifest.py exists
fd -t f "validate_manifest.py"

Repository: marginalia-os/marginalia-sdk

Length of output: 99


🏁 Script executed:

# Check the validate_manifest.py file size and read it
wc -l tools/validate_manifest.py

Repository: marginalia-os/marginalia-sdk

Length of output: 103


🏁 Script executed:

# Read the validation file to understand current enforcement
cat -n tools/validate_manifest.py

Repository: marginalia-os/marginalia-sdk

Length of output: 6029


Require setting defaults and validate enum defaults against declared options.

default is currently optional for both setting variants, and enum default is only constrained as a non-empty string. The validation tool performs only schema-level checks with no custom logic to enforce or verify these constraints. This allows manifests with missing or invalid initial values to pass validation.

Add default to the required array for both variants. For enum settings, validate that the default value is present in the options array (either through JSON Schema constraints or custom validation in tools/validate_manifest.py).

Suggested schema changes
           {
             "type": "object",
             "additionalProperties": false,
-            "required": ["id", "label", "type"],
+            "required": ["id", "label", "type", "default"],
             "properties": {
               "id": {
                 "type": "string",
                 "maxLength": 48,
                 "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
           {
             "type": "object",
             "additionalProperties": false,
-            "required": ["id", "label", "type", "options"],
+            "required": ["id", "label", "type", "options", "default"],
             "properties": {
               "id": {
                 "type": "string",
                 "maxLength": 48,
                 "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@schema/manifest.v1.schema.json` around lines 102 - 103, Update the manifest
schema so both setting variants include "default" in their "required" arrays
(i.e., add "default" alongside "id","label","type") and enforce for enum
settings that the declared default appears in the "options" list; implement this
either by adding a JSON Schema constraint that validates the enum default
against the "options" array or by adding a check in tools/validate_manifest.py
that verifies for each enum-type setting the default value is present in its
options array. Ensure you reference the manifest schema's "required" array, the
"default" property, and the enum "options" property when making the changes.

@sabraman
sabraman merged commit 0ac29b8 into main May 15, 2026
2 checks passed
@sabraman
sabraman deleted the codex/package-settings-schema branch May 15, 2026 22:57
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