Skip to content

[Feature]: Session assembles fetched elements into POCOs and caches PSM records #446

Closed

Description

@antoineatsoprasteria

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the SysML2.NET
  • I have searched open and closed issues to ensure it has not already been reported

Description

Session (SySML2.NET.REST/Session.cs) only exposes a raw IPsmApiClient: every read hits the server, and elements come back as DTOs the caller must assemble itself. SySML2.NET.REST does not reference SysML2.NET.Dal, so the Assembler is unreachable from the session.

Proposal

  1. Element model of the current commit. The session works on one project and one commit at a time. It holds a single IAssembler and the (projectId, commitId) it was built from, exposed as ISession.CurrentCommit. ISession.GetModel(projectId, commitId) returns the existing POCO cache without a request when the pair matches CurrentCommit (API & Services §7.1.2: "Commits are immutable"). Otherwise it pages through GetElementsByProjectCommitAsync, synchronizes a fresh Assembler and replaces the current one — re-synchronizing the existing one would keep elements absent from the new commit. A branch-scoped read resolves Branch.head first, then follows the same path.

  2. Record cache, policy per type from the §7.1.2 Mutability/Destruction table:

    • Commit, DataVersion: cached permanently.
    • Tag: cached permanently, evicted when deleted through the session.
    • Project, Branch, Query: configurable time-to-live, evicted on any write through the session that affects them (post, put, delete, commit or merge on the branch).

    List endpoints still reach the server (page cursors are opaque) but populate the cache. The PSM defines no ETag/Cache-Control, so freshness is decided client-side.

  3. Placement. Session.Client becomes a caching decorator around PsmApiClient, generated from the OpenAPI alongside AutoGenPsmApiClient, so callers keep one API and no write can bypass invalidation. The policy table stays hand-written.

  4. Close() and re-Open() drop the Assembler, reset CurrentCommit and clear the record cache. ConcurrentDictionary throughout, matching Assembler.Cache.

Tasks

  • Add a ProjectReference from SySML2.NET.REST to SysML2.NET.Dal
  • ISession.GetModel(projectId, commitId) + branch overload and ISession.CurrentCommit, backed by a single Assembler replaced on commit change
  • Hand-written per-record-type cache policy and store
  • Generator template emitting the caching IPsmApiClient decorator
  • Time-to-live option for mutable records
  • Tests: repeated GetModel on the current commit issues no HTTP call; switching to a commit where an element was removed leaves no trace of it in the POCO cache; a write evicts the affected Branch/Project; time-to-live expires mutable records; Close() clears everything

Steps to Reproduce

Not applicable — feature request.

System Configuration

  • SysML2.NET version: 0.26.0 (SysML2.NET.REST)
  • Environment (Operating system, version and so on): any
  • .NET Framework version: netstandard2.1, net10.0
  • Additional information: Systems Modeling API & Services 1.0 REST/HTTP PSM

Activity

  1. added a commit that references this issue on Nov 19, 2026
    581630c
  2. linked a pull request that will close this issueFix #446 : session assembler #450on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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