Skip to content

--schema FILE: one schema governs, whatever the files declare - #24

Merged
MartenH merged 2 commits into
mainfrom
one-schema
Oct 31, 2026
Merged

MartenH merged 2 commits into
mainfrom
one-schema

Conversation

@MartenH

@MartenH MartenH commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Replaces #23. Files declaring only releases that are not in the schema directory stop with no schema compiled, and the way round was to copy a schema under a declared name. #23 picked the newest schema of the family from the directory, which is a guess that changes when the directory does. Here the schema is stated instead.

  • --schema FILE works wherever --schema-dir does, and is refused beside it, --rules or --no-schema. serve workers and git-setup carry it on.
  • A model file takes schema = "x.xsd", and the library OpenOptions.schema; compile_schemas also takes a schema file for its directory.
  • The schema governs every file of its target namespace, whatever they declare, and those declaring nothing. A file of another namespace stays ungoverned, and a schema no file is of says so: no schema governs urn:a: X.xsd is of namespace urn:b.
  • no schema compiled now says a schema can be named.
  • merge writes the schema by its file name as the output's location, and git-setup keeps --schema in the drivers rather than caching a rules file, since a rules file is held to what the files declare.

arxmodel policy --schema already existed as a flag and keeps its meaning, so parse_opts now takes the command. schema was also the example of an unknown model file setting in open_test.v; that test now uses schemas.

blobly_net reads schema_dir from a model file to list its inputs, so a model file using schema needs that read too when it next vendors arxmodel. rule_files already names the schema.

Tests: v test . passes, as do scripts/inputs_cli_test.sh and scripts/git_driver_test.sh, which now cover --schema, its refusals, policy --schema and git-setup. New cases in releases_test.v cover a file that declares another release, one declaring none, a schema of another namespace and the model file key.

🤖 Generated with Claude Code

A model whose declared release is not at hand stopped with `no schema compiled`, and
the way round was to copy a schema under a declared name. Now the schema is stated:
`--schema FILE` on the commands that read by a schema, `schema` in a model file,
`OpenOptions.schema` in the library. It governs every file of its target namespace,
those declaring nothing too; nothing is inferred from a directory or a file name.

`policy --schema` keeps its meaning, so the parser asks which command it is reading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T21:28:14.160471Z 11305a2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 632b4f5ef0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread arxmodel/schemas.v
Comment on lines +177 to +180
for k in out.undeclared.keys() {
if declared_schema(m.set.docs[k]).ns == ns {
one.docs << k
out.undeclared.delete(k)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve a valid schema location when exporting undeclared inputs

When merge --schema FILE reads a document without xsi:schemaLocation, adding it to one.docs breaks the assumption in export.v:root_location that these documents actually declare the governing schema. That function reads the first document's empty declared location and emits xsi:schemaLocation="urn:arxmodel:test:lib ", which is not a valid namespace/location pair and is rejected on a subsequent normal load. Inputs declaring another release likewise retain that release's location despite being merged by the explicit schema. Update export to distinguish explicitly governed documents from declarations and use the selected schema's location.

Useful? React with 👍 / 👎.

Comment thread cmd/arxmodel/compare.v
// the schema directory.
fn setup_rules_file(o Opts, repo string, top string) string {
dir := '--schema-dir ${os.quoted_path(os.real_path(o.schema_dir))}'
dir := '${schema_flag(o)} ${os.quoted_path(os.real_path(o.schema_dir))}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain explicit-schema semantics in installed Git drivers

For a repository with tracked ARXML files that declare no schema, git-setup --schema FILE successfully compiles the selected schema but setup_rules_file then replaces the option with --rules. The installed drivers consequently call rules_file_check, which rejects those same documents with 0 namespaces declared; one model has one. A schema with an unranked filename or a different release family similarly fails the rules-file checks even though direct --schema accepts it. Preserve --schema for these drivers, or carry its namespace-only governing semantics into the cached rules, rather than silently reverting to declaration-based validation.

Useful? React with 👍 / 👎.

Comment thread arxmodel/schemas.v Outdated
Comment on lines +184 to +187
if one.docs.len > 0 {
one.docs.sort()
compile_use(one, opts.policy)
out.uses.prepend(one)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Choose a nonempty version when comparing with an explicit schema

When comparing an added document that has no schema declaration, diff --schema FILE /dev/null bare.arxml fails with 0 namespaces declared; one model has one instead of reporting the addition. choice.v:choose still selects its input through newest_declaring, which defaults to the first version when neither version declares a release; that version is empty here, so this guard skips compiling the explicitly selected schema and leaves no governing entry. The same path makes git-diff --schema fall back to a textual diff for such additions. Explicit-schema comparisons should select a nonempty matching version rather than depend on release declarations.

Useful? React with 👍 / 👎.

Each of these assumed the files declare their schema. An export now names the stated
schema by its file name, where it wrote an empty location for a file declaring none;
git-setup keeps --schema, since a cached rules file is held to what the files declare;
and a version with no documents is read by the stated schema too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MartenH

MartenH commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author
finding reaction what happened
P2 export location 👍 a stated schema is written by its file name; the export reloads, CLI test added
P2 git drivers 👍 git-setup keeps --schema; test covers a tracked file declaring nothing
P2 empty side of a diff 👍 a version with no documents is read by the stated schema; CLI test added

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 11305a2d43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MartenH
MartenH merged commit b96802b into main Oct 31, 2026
2 checks passed
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