finos / finos/morphir

Audit IR ingestion parity through Insight and XRay

Open
#792 0 comments 0 reactions 0 assignees View on GitHub
ir-bindings morphir-cli
Dominant language
Rust
Stars
209
Forks
65
Avg merge
8h 55m
Merged PRs (30d)
126

Description

# IR ingestion contract audit

Follow-up to #790.

## Purpose

Run one deliberate, read-only review of every supported or specified Morphir IR
ingestion route through the normalized UI AST and the Insight and XRay views.
The review must produce one complete support matrix and one consolidated
findings report. It must not fix findings or trigger another PR-bot review.

This corrects a gap in the XRay review process. The implementation reviews were
organized around small commit ranges and individual acceptance slices. The
exhaustive semantic fixture covered V3, while the V4 smoke project exercised
only a few expanded forms. As a result, the reviews proved renderer coverage
and a narrow V4 happy path, but not representation parity across the V4 schema
or across storage layouts.

## Prior review history and mandatory regression anchors

The audit must retain and independently re-prove every prior PR #790 review
finding. A finding marked fixed is a regression anchor, not a row to skip:

- Codex review `5103345835`, inline comment `3925698261`: a fresh clone could
not run the documented mise setup before trusting `.config/mise/config.toml`.
Addressed by parent commits `ef584982` and `41db85f4`. This is outside the IR
semantic matrix but remains a checkout/setup precondition for the audit.
- Codex review `5103916579`: nested tuple patterns and subjects produced
misaligned Insight decision-table columns. Addressed in morphir-ui commits
`887d95c`, `050322f`, `e822422`, and `8b785e7`, vendored by parent commit
`298e00ce`. Re-prove recursive, opaque, opposing, and arity-mismatch cases.
- Codex review `5104505026`: exact baseline release string `4.0.0` was rejected,
and schema-valid flattened V4 access wrappers failed definition extraction.
Addressed in morphir-ui commits `d7487d3`, `bdab4a4`, and `28c5558`, vendored
by parent commit `d121e9bd`. Re-prove all schema-listed access spellings and
wrapper forms, attributes/doc preservation, map boundaries, exact release
dispatch, and accurate diagnostics.
- Codex review `5105072844`: compact V4 `Variable`, `Reference`, `Constructor`,
`Tuple`, `List`, and `Literal` wrapper payloads degraded to unknown nodes.
Addressed in morphir-ui commits `06da156` and `21116b5`, vendored by parent
commit `b2eb5615`. Re-prove every compact and expanded form, scalar literal
inference, non-finite rejection, and own-data-property behavior.

Preserve these deliberate exclusions and unresolved contexts:

- Do not silently expand decoder support from the baseline `4.0.0` release to
`4.1.0`. The current exact-release policy recognizes later release strings
but rejects unsupported releases accurately. Report any conflict between
that policy and the schema as a contract/capability decision, not as an
automatic parser fix.
- The published books-and-records fixture still contains retired
`product-(i-d)` name syntax. That fixture issue is tracked separately as
#793; do not weaken canonical name parsing to make it pass.
- The latest compact-value fix intentionally received no further external bot
review. Its local tests and CI are evidence, but this audit must re-evaluate
it independently.
- YAML single-file and JSON/YAML document-tree routes do not currently all
reach a normalized library in the UI. Record each missing route explicitly
rather than treating a manifest-only load as end-to-end support.

## Scope

Audit these input profiles:

1. V3 single-file JSON
2. V3 single-file YAML
3. V4 single-file JSON
4. V4 single-file YAML
5. V4 JSON document tree/VFS
6. V4 YAML document tree/VFS

For each applicable profile, follow both entry paths:

- browser file or folder loading;
- connected `morphir live` workspace loading.

Trace each route through parsing/loading, normalization into the shared AST,
definition selection, Insight transformation/rendering, and XRay
projection/rendering. A route that is specified but not implemented is a
product capability gap, not automatically a decoder defect.

The audit covers every schema-defined type expression, pattern, literal, and
value expression, including accepted compact and expanded spellings, access
wrappers, documentation, attributes, recursive nesting, and malformed or
future-compatible fallback behavior. V3/V4 semantic equivalents must normalize
to equivalent ASTs. JSON/YAML and single-file/document-tree storage choices
must not change the rendered semantic result.

The audit excludes unrelated CLI serving, deployment, performance,
observability, and multi-user production hardening.

## Normative sources and implementation boundaries

Treat these as normative or contract-defining inputs:

- `website/static/schemas/morphir-ir-v3.json`
- `website/static/schemas/morphir-ir-v4.json`
- `website/static/schemas/morphir-ir-v4-document-tree-files.json`
- `docs/spec/ir/schemas/v4/json-profile.md`
- `docs/spec/ir/schemas/v4/yaml-profile.md`
- `docs/spec/ir/schemas/v4/document-tree-files.md`
- `crates/morphir/src/commands/migrate.rs`

Inspect at least these implementation boundaries:

- `crates/morphir/src/commands/ui/`
- `ecosystem/morphir-ui/apps/morphir-web/src/workspace/browser-provider.ts`
- `ecosystem/morphir-ui/apps/morphir-web/src/connected/connected-provider.ts`
- `ecosystem/morphir-ui/packages/morphir-ir/src/decode.ts`
- `ecosystem/morphir-ui/packages/morphir-ir/src/ast-decode.ts`
- `ecosystem/morphir-ui/packages/morphir-ir/src/names.ts`
- `ecosystem/morphir-ui/packages/morphir-ir/src/ast.ts`
- `ecosystem/morphir-ui/packages/morphir-insight/src/`
- `ecosystem/morphir-ui/packages/morphir-ui/src/views/insight/`

Use existing tests and fixtures as evidence, but do not treat their existence or
green status as proof that a schema alternative is covered.

## Deliverables and stop rule

Produce:

1. A representation matrix with a row for every schema-defined alternative and
columns for all applicable input profiles and entry paths. Each cell must be
`supported`, `rejected with diagnostic`, `degrades to unknown`, `not
implemented`, or `not applicable`, with evidence.
2. One ranked findings report. Every finding must cite the schema/contract,
source location, minimal reproduction, observed result, expected result, and
affected matrix cells.
3. A short gap summary grouped as code defect, missing product capability,
fixture/spec inconsistency, or test-only gap.
4. A proposed issue breakdown that keeps delivery blockers separate from
optional hardening.

Do not edit source, add tests, create fix commits, request GitHub reviews, or
stop after the first valid finding. Complete the matrix and report all findings
in one pass. Implementation begins only after maintainers review and prioritize
the consolidated report.

## Reusable review prompt

```text
Perform a deliberate, read-only contract audit of Morphir IR ingestion through
the web UI. This is not a diff review and not a request to fix code. Review the
whole contract boundary once, then return one consolidated report. Do not stop
after the first finding and do not request another reviewer.

Goal
Prove whether semantically equivalent Morphir IR reaches equivalent normalized
ASTs and remains usable in both Insight and XRay across:

- V3 single-file JSON
- V3 single-file YAML
- V4 single-file JSON
- V4 single-file YAML
- V4 JSON document tree/VFS
- V4 YAML document tree/VFS

Exercise both browser file/folder loading and connected `morphir live`
workspace loading wherever applicable. Document-tree layouts are V4-only.

Sources of truth
Read the relevant AGENTS.md files first. Then use:

- website/static/schemas/morphir-ir-v3.json
- website/static/schemas/morphir-ir-v4.json
- website/static/schemas/morphir-ir-v4-document-tree-files.json
- docs/spec/ir/schemas/v4/json-profile.md
- docs/spec/ir/schemas/v4/yaml-profile.md
- docs/spec/ir/schemas/v4/document-tree-files.md
- crates/morphir/src/commands/migrate.rs

Trace the implementation through:

- crates/morphir/src/commands/ui/
- ecosystem/morphir-ui/apps/morphir-web/src/workspace/browser-provider.ts
- ecosystem/morphir-ui/apps/morphir-web/src/connected/connected-provider.ts
- ecosystem/morphir-ui/packages/morphir-ir/src/{decode,ast-decode,names,ast}.ts
- ecosystem/morphir-ui/packages/morphir-insight/src/
- ecosystem/morphir-ui/packages/morphir-ui/src/views/insight/

Audit method

1. Reconcile PR #790 review history first. Re-prove review IDs `5103345835`,
`5103916579`, `5104505026`, and `5105072844` against the current source and
record each as passing, regressed, deliberately excluded, or superseded.
2. Inventory every schema-defined alternative before evaluating support:
envelope/release spellings; distribution and module shapes; access wrappers;
docs and attributes; names, paths, and FQNames; all type expressions; all
patterns; all literals; all value expressions; inline and granular
document-tree definitions.
3. For every alternative, enumerate compact, expanded, legacy-compatible, and
recursive forms that the schema explicitly accepts. Do not infer support
from one representative example.
4. Build a matrix across the six profiles and two entry paths. Mark each cell
only as: supported; rejected with diagnostic; degrades to unknown; not
implemented; or not applicable. Cite a test, controlled probe, or direct
source trace for every non-obvious result.
5. Validate cross-profile invariants: equivalent JSON and YAML, and equivalent
single-file and document-tree inputs, must normalize to equivalent ASTs and
render the same selected definition in Insight and XRay.
6. Verify that every valid semantic node reaches the shared AST without an
UnknownNode, omission, crash, or data loss, and that Insight/XRay handle every
normalized kind. Verify unknown future tags degrade safely.
7. Probe malformed boundaries: nulls, arrays where maps are required, missing
required fields, ambiguous access wrappers or manifests, mixed serialization
profiles, duplicate/invalid names, inherited properties/accessors in direct
decoder calls, unsupported versions, and size/path confinement already
promised by the loaders. Use only trusted local fixtures and controlled
values.
8. Run the relevant existing tests, but do not treat green tests as coverage.
Identify matrix rows with no executable evidence.

Classification

- Code defect: a currently supported route violates its schema or loses,
misnormalizes, or misrenders valid IR.
- Missing product capability: a specified/desired route has no complete loader
path to Insight/XRay (for example, a loader stops at document-tree metadata).
- Fixture/spec inconsistency: published examples or fixtures violate the
normative contract.
- Test-only gap: behavior is correct by source trace and probe but lacks durable
coverage.

Report format

1. Findings first, ranked Critical, Important, Minor. For each finding include:
contract citation, source location, minimal reproduction, expected versus
observed behavior, affected matrix cells, and the smallest sensible fix
boundary. If there are no findings, say so explicitly.
2. The complete representation matrix, including unsupported and untested
cells. Do not omit passing rows.
3. A prior-review ledger for Codex review IDs `5103345835`, `5103916579`,
`5104505026`, and `5105072844`, including current evidence and disposition.
4. Coverage gaps and fixture/spec inconsistencies, including #793 and
the deliberate exact-release policy for `4.1.0`.
5. Proposed follow-up issues grouped into delivery blockers and optional
hardening. Avoid unrelated refactors or productionization.
6. Commands/probes run and their results.

Stop after the consolidated report. Do not edit code, add tests, commit, push,
comment on a PR, or trigger a bot review.
```

Contributor guide

Open the contributing guide

Research direction

Read the relevant AGENTS.md files first, then compare the three schemas and V4 profile documents with crates/morphir/src/commands/ui/, the browser and connected providers, and the morphir-ir, morphir-insight, and insight-view packages. Run the relevant existing tests and controlled probes without editing code. Done means a complete six-profile, two-entry-path support matrix, prior-review ledger, and ranked findings report with evidence and follow-up issue boundaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, typescript
Domain
documentation, testing
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.