Skip to content

Audit legacy global metadata fallbacks without regressing context-owned relation loading #134

Closed

Description

@philipgreat

Verified current state

The active PortableSQLDataService relation path already uses attachRelation(target, resolvedRelationDescriptor, value), not BaseEntity.addRelation. PortableSQLDatabaseTest.TOPN_009_relationHydrationUsesServiceMetadataWithoutGlobalRegistry passes with EntityMetaFactory.registerGlobal(null). Thus this issue must not be described as a current relation-query failure.

The following fallback sites remain in current main (2af3701), but reachability and supported status are not yet established:

  • BaseEntity.addRelation(String, Entity): global metadata, no internal production caller found after the descriptor-based relation change; direct application API remains.
  • EntityFactory.defaultFactory(): global metadata; no production caller found in repository search.
  • GenericSQLProperty/GenericSQLRelation.setPropertyValue(UserContext, ...): legacy ResultSet reference hydration calls EntityMetaFactory.get() even though context is available; no production call site found in repository search.
  • PortableSQLRepository.resolveDescriptor(): falls back to global metadata when constructed without a metadata snapshot. Schema-only dialect adapters construct such repositories; verify whether this method can be reached from those adapters.
  • BaseRequest's context-free fallback: intentionally retained only for the deprecated JSON dynamic-search compatibility entry point in Bind JSON dynamic search to invoking-context metadata #127.

Required audit and change

  1. Prove which sites are reachable through a supported application/runtime API, including external library callers; do not infer dead code solely from repository search.
  2. For supported context-bearing paths, use invoking-context metadata or an already-resolved descriptor.
  3. For no-context compatibility APIs, document/deprecate or replace them with an explicit context/descriptor form; do not silently select another runtime's model.
  4. Preserve schema-only adapter construction and existing generated application behavior.

Acceptance evidence

  • A two-runtime, same-type-name/different-descriptor test for every reachable supported path.
  • Global registry deliberately absent or poisoned while context-bound paths execute.
  • Explicit behavior for context-free compatibility calls.
  • Full Maven tests and Java examples; live SQL checks if a SQL hydration path is proven reachable.
  • A call-path classification table marking each listed site active, compatibility-only, or dead, backed by tests or bytecode/call-site evidence.

Activity

  1. changed the title [-]Audit remaining global metadata fallbacks in Java entity helpers and hydration[/-] [+]Audit legacy global metadata fallbacks without regressing context-owned relation loading[/+] on Sep 22, 2026
  2. philipgreat commented on Sep 22, 2026

    @philipgreat
    ContributorAuthor

    Verified baseline correction: PortableSQLDataService already assembles relation graphs from resolved descriptors; TOPN_009 passes with the global registry null. I implemented the separately reachable legacy ResultSet mapper fix on branch fix/context-owned-relation-134, commit 8c0e544: GenericSQLProperty and GenericSQLRelation now create reference placeholders from the invoking UserContext's metadata, after checking for SQL NULL. A two-runtime same-name test alternates context A/B with the process-global registry poisoned or unset. Focused test, full mvn -q test, ./scripts/verify-examples.sh, and git diff --check passed locally. This is a branch checkpoint, not a claim that all #134 fallback sites are closed; hold PR/merge behind the current ordered queue.

  3. philipgreat commented on Sep 22, 2026

    @philipgreat
    ContributorAuthor

    Additional toolchain verification for branch 8c0e544: the focused LegacyReferenceHydrationContextTest passes on JDK 17, and the full mvn -q test reactor passes on JDK 21 (the version actually configured by CI) as well as on the default local JDK 25. A full JDK 17 reactor invocation stops at the existing generated conformance example's Maven Enforcer RequireJavaVersion [21,) rule; it is not a regression in this branch. The CI setup step was mislabeled JDK 17 despite java-version: '21'; corrected separately on #132 head ea89c3b.

  4. philipgreat commented on Sep 22, 2026

    @philipgreat
    ContributorAuthor

    Ordered-queue local preflight: merged the pushed legacy hydration fix 8c0e544 onto current-main + latest #126 + #128 + #129 + #120 as local integration commit c0c69c4adb4b310eb84a91900ede158cf5bbcc74. Merge was conflict-free. JDK 21 focused LegacyReferenceHydrationContextTest exited 0; full mvn -q test exited 0; ./scripts/verify-examples.sh exited 0; git diff --check passed. This is local evidence only, not a PR or main merge. Test-generated SQLite DB and .local/ are not staged. Further legacy global fallbacks in BaseRequest, BaseEntity, EntityFactory and old provider adapters remain separate audit items; this result does not claim those are closed.

  5. philipgreat commented on Sep 22, 2026

    @philipgreat
    ContributorAuthor

    Call-path audit on the combined current source: PortableSQLDataService attaches loaded relations through its descriptor-aware attachRelation method; production source has no calls to BaseEntity.addRelation. EntityFactory.defaultFactory has no production call sites in this repository. PortableSQLDataService constructs PortableSQLRepository with explicit metadata, while legacy dialect executors construct it with null metadata only for ensurePhysicalSchema; their normal query path is SqlDataServiceExecutor. Therefore the remaining global fallbacks are not evidence that the current PortableSQLDataService relation loader crosses runtime boundaries. They remain public/legacy API hazards requiring separate context-aware design and tests; do not replace active descriptor-aware loading or claim #134 fully closed from the focused GenericSQLProperty/Relation fix.

  6. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    Additional partial #134 remediation prepared as stacked draft PR #145 (head cf3109e). PortableSQLRepository now fails explicitly if a schema-only instance lacking a runtime metadata snapshot is asked to hydrate a relation; it no longer borrows process-global metadata. A focused test poisons the global-fallback premise by registering a valid global factory and proves this repository still refuses cross-entity hydration. JDK 21 focused test, full Maven reactor, all Java examples, and diff check passed. PR remains draft behind #144. Public BaseEntity.addRelation and EntityFactory.defaultFactory global paths remain open, so issue #134 is not closed.

  7. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    A second partial #134 change is available as stacked draft PR #146 (head b2397d0). It adds EntityFactory.forContext(context) and forMetadata(metadata), with a two-runtime/same-type-name test that poisons global metadata yet returns the type belonging to each context. The no-arg global factory is deprecated with a migration hint, but not removed. JDK 21 focused test, full Maven tests, all Java examples, and diff check passed. PR #146 is stacked after #145; BaseEntity.addRelation and other compatibility entry points remain unresolved.

  8. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    Another partial remediation is draft PR #149, stacked after #146. It adds context-owned relation attachment to the public Entity API and deprecates the legacy global-metadata overload. A two-runtime same-type-name test proves that each context selects its own relation descriptor with the global registry wrong or null. JDK 21 focused/full Maven tests and all Java examples passed locally. The old no-context overload remains for compatibility, and other #134 fallbacks still require audit; this does not close the issue.

  9. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    Reopened after #145 merge: the issue was auto-closed at merge time, but #145 is explicitly partial. Remaining acceptance work includes BaseEntity.addRelation global metadata behavior, no-context EntityFactory compatibility behavior (#146 is still draft), and the call-path classification/evidence table. The accepted #145 change only makes schema-only PortableSQLRepository relation hydration fail closed. Keep #134 open until each supported path is audited and verified.

  10. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    Reopened after #146 merge. The context-bound EntityFactory path is now available, but #134 still requires the BaseEntity.addRelation context path (#149 remains draft) and the final call-path classification/evidence review. The deprecated no-context factory is intentionally retained for compatibility, so this issue is not complete.

  11. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    Current #134 call-path audit after #149 (issue remains open):

    Site Classification Current behavior and evidence
    PortableSQLDataService.attachRelation Active normal query path Uses a resolved relation descriptor, not BaseEntity.addRelation; TOPN_009_relationHydrationUsesServiceMetadataWithoutGlobalRegistry runs with global metadata absent. A two-runtime normal SQL relation test is still missing.
    GenericSQLProperty / GenericSQLRelation.setPropertyValue Public legacy context-bearing mapper, compatibility-only internally #135 resolves reference descriptors from the invoking context. LegacyReferenceHydrationContextTest alternates two runtimes with global metadata poisoned and null.
    PortableSQLRepository.resolveDescriptor Active in streamInternal, including schema-only repository constructions #145 keeps own entity descriptor for schema and rejects cross-entity hydration without a runtime metadata snapshot. schemaOnlyRepositoryMustNotHydrateRelationFromGlobalMetadata poisons global metadata.
    EntityFactory.defaultFactory Public no-context compatibility API #146 adds forContext/forMetadata; defaultFactory is deprecated and fails with migration hint if global metadata is absent. EntityFactoryContextTest covers same-type-name runtimes with poisoned global metadata for the new path.
    BaseEntity.addRelation(String, Entity) Public no-context compatibility API, not called by the normal service relation loader #149 adds addRelation(context, ...), deprecates old overload, and fails with migration hint when global metadata is absent. BaseEntityTest covers two context models, poisoned/null global, and invalid relation rejection.
    BaseRequest metadataFactory global fallback Deprecated context-free JSON dynamic-search compatibility path JsonRequests.findWithJson(context, ...) binds invoking-context metadata; JsonRequestsContextTest alternates two same-name models with poisoned global metadata.

    Open audit requirement: add two-runtime same-type-name execution coverage for the normal PortableSQLDataService SQL relation path, and decide whether deprecated no-context APIs with an existing global registry need an explicit runtime warning or a stronger migration boundary. Do not close #134 from the partial PR merges alone.

  12. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    Current-head evidence update (2026-09-23): PR #158 merged the normal SQLite Q-path two-runtime/same-type-name test. Its independent runtime databases map the same relation through parent_a versus parent_b; each query succeeds with the process-global metadata deliberately pointed at the other runtime or unset. The call-path audit is retained in docs/issues/issue-context-owned-metadata-boundaries.md. PR #159 merged non-breaking warnings and tests for deprecated no-context Entity.addRelation, EntityFactory.defaultFactory, and JsonRequests.findWithJson. Both PRs passed exact-head Build and Test, examples, and postgres-mysql checks.

    Do not close this issue as a claim of full isolation: manually registered process-global compatibility APIs still cannot infer the owning runtime. The remaining decision is whether to keep warned single-runtime compatibility or make those old APIs fail closed even with a global registry; that is a breaking public-API choice. The normal context-bound query and mutation paths are verified separately.

  13. philipgreat commented on Sep 23, 2026

    @philipgreat
    ContributorAuthor

    2026-09-23 audit decision: close #134 as a call-path/isolation audit, NOT as a claim that deprecated context-free compatibility APIs are multi-runtime safe. Supported multi-runtime calls must use invoking-context metadata or an explicit descriptor. Retain the no-context overloads only for explicitly registered single-runtime compatibility, with deprecation + runtime warning, fail-closed behavior when no global registry exists, and documented migration entry points. Do not silently upgrade this compatibility carve-out into a context-isolation guarantee. Evidence: docs/issues/issue-context-owned-metadata-boundaries.md classifies every listed call path; merged PR #158 covers normal SQLite Q relation loading with two same-name/different-descriptor runtimes and wrong/absent global registry; #135/#145/#146/#149 cover legacy mapper, schema-only repository, factory, and relation APIs; #159 adds deprecated-entry warnings and tests. Current main PR #161 passed Build and Test, examples, and postgres-mysql on its exact head. Any future removal/fail-closed change even with a registered global factory should be a separately scoped breaking-API issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions