Skip to content

With no declared schema at hand, the newest of the family governs - #23

Closed
MartenH wants to merge 2 commits into
mainfrom
newest-schema-at-hand
Closed

MartenH wants to merge 2 commits into
mainfrom
newest-schema-at-hand

Conversation

@MartenH

@MartenH MartenH commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Files declaring only releases that are not in the schema directory stop with no schema compiled, even when the directory holds a newer release of the same family. The fallback to "the newest at hand" only ran among declared schemas. So the workaround was to copy the schema under a declared name.

compile_schemas now adds, for a namespace with no declared schema at hand and per declared family, the newest schema in the directory of that family and namespace that compiles; newer ones that did not compile stay listed, so the note can say so. choose_governing ranks it as usual, so the existing note still names the newest declared release, and the schema carries a note that no file declares it. A schema of another family or namespace is not taken, so ungoverned remains for a directory with nothing suitable.

Newer schemas are not strictly additive, so a file may use something the governing schema dropped. Such a file gets an XML schema finding, and rules already reports the roles involved for older schemas it has at hand.

Tests: test_with_no_declared_schema_at_hand_the_newest_of_the_family_governs, on the existing synthetic schemas, covers both the fallback and a directory without the family.

🤖 Generated with Claude Code

The merge rules and the XML schema came from a schema the files
declare, or none: a directory holding only a newer release than any
file names gave `no schema compiled`, though that release would do.

Where no declared schema of a namespace is in the directory, the newest
schema of a declared family and of that namespace is added, and governs
by the usual ranking. It is said that no file declares it.

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:05:50.253604Z 354913b 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: 08ef1a52b3

ℹ️ 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 Outdated
continue
}
text := os.read_file(f) or { continue }
if text.contains('targetNamespace="${ns}"') {

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 Read the candidate namespace as an XML attribute

When an otherwise suitable schema writes its namespace as targetNamespace='urn:x' or includes whitespace around =, this literal substring check rejects it even though the existing XSD reader accepts it through d.attr(root, 'targetNamespace') in flatxml/xsd/read.v. With no declared schema available, the model consequently remains ungoverned despite a usable schema in the directory. Read the root attribute through the XML parser instead of matching its serialization; this also avoids accepting namespace text that appears only in a comment.

Useful? React with 👍 / 👎.

Comment thread arxmodel/schemas.v Outdated
mut best_release := Release{}
for f in all {
r := release_of(f) or { continue }
if r.prefix !in families || (best != '' && r.compare(best_release) <= 0) {

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 Select fallback candidates within the governing family

When documents in one namespace declare multiple families and none of their declared schemas is available, this comparison chooses a single candidate across all families. For example, if most documents declare missing A_1.xsd, a minority declare missing B_1.xsd, and the directory contains A_2.xsd and B_9.xsd, only B_9.xsd is added. However, choose_governing() still selects family A by document count and places B in g.others, leaving g.use == -1 despite the usable A fallback. Determine the governing family before selecting its fallback, or retain a candidate per family so the existing governing selection can use the appropriate one.

Useful? React with 👍 / 👎.

Comment thread arxmodel/schemas.v Outdated
Comment on lines +158 to +162
if best != '' {
sc.uses << &SchemaUse{
name: os.file_name(best)
ns: ns
path: best

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 Try older fallback schemas when the newest cannot compile

When no declared schema is available and the newest matching schema fails compilation, only that candidate has been added to sc.uses, so choose_governing() cannot fall back to an older matching schema that would compile. For example, with missing declared LIB_1.xsd, usable LIB_2.xsd, and LIB_3.xsd referencing a missing include, the added LIB_3.xsd fails in compile_use() and the model remains ungoverned; merely adding that unusable newer release to a previously working schema directory therefore breaks loading. Retain older matching candidates or retry them after compilation failure so the newest successfully compiled fallback can govern.

Useful? React with 👍 / 👎.

The fallback picked one file across families before anything compiled, by matching
text, so a schema written with other quoting was missed, a namespace with several
families could add the wrong one, and a newest release that does not compile left
the model ungoverned though an older one would do. Each family declared now tries
its schemas newest first, reading targetNamespace from the parsed root, until one
compiles; those that did not stay, so the governing note can say so.

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 namespace read as text 👍 read from the parsed root; test with other quoting and a comment-only match
P2 candidate across families 👍 one schema per family declared; test added
P2 newest does not compile 👍 tried newest first until one compiles, the rest stay listed; test added

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 354913b455

ℹ️ 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 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Closed in favour of an explicit --schema FILE: a schema picked from a directory by its file name is a guess, and it changes when the directory does.

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