Skip to content

feat: advance data provider and accounting completion - #2283

Merged
rodoHasArrived merged 4 commits into
mainfrom
codex/data-provider-accounting-checkpoint-20260715
Jul 15, 2026
Merged

feat: advance data provider and accounting completion#2283
rodoHasArrived merged 4 commits into
mainfrom
codex/data-provider-accounting-checkpoint-20260715

Conversation

@rodoHasArrived

@rodoHasArrived rodoHasArrived commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

Reason

The provider/accounting WIP needed to close operational gaps in diagnostics, canonical identity, valuation evidence, automated-journal durability, posting idempotency, and accounting-close workflows. Two concrete regressions required follow-up: the approved AAPL valuation failed LedgerPeriodPostingGuard.ValidateSecurityMasterLineage because its test fixture lacked authoritative Security Master evidence, and the UI verification lane could hang indefinitely around UiServer startup.

Testing performed

  • bash scripts/ci.sh completed successfully
  • Relevant unit tests were added or updated
  • Relevant integration tests were added or updated
  • GitHub Actions quality-gate passed

Focused evidence collected on Windows/.NET 10:

  • dotnet build src/Meridian.Ui.Shared/Meridian.Ui.Shared.csproj -c Debug --no-restore --no-dependencies --disable-build-servers -m:1 /p:UseSharedCompilation=false /p:BuildProjectReferences=false — passed with 0 errors and 16 warnings after rebuilding current dependencies.
  • dotnet build src/Meridian.Application/Meridian.Application.csproj -c Debug --no-restore --no-dependencies --disable-build-servers -m:1 /p:UseSharedCompilation=false /p:BuildProjectReferences=false — passed with 0 errors and 30 warnings after correcting the unpriced.Length compile error.
  • Focused DailyValuation_AaplSecurityMasterFixture_PassesPostingGuard xUnit execution — passed, 1/1, against the real LedgerPeriodPostingGuard.
  • Exact focused UiServer_RegistersLifecycleRoutes_ForManagedShutdown execution — still aborts under VSTest's two-minute hang detector. The test now has a 30-second StartAsync guard, but the current focused run blocks before that guard is reached, indicating remaining constructor/composition work rather than a proven startup fix.
  • Full DailyValuation_ApprovedPostedAndRestarted_HydratesMarkedStatementsAndNavIdempotently execution and bash scripts/ci.sh remain pending; the all-tests assembly was not a reliable validation surface during this run because the worktree required staged dependency rebuilds and its discovery path also stalled.

Safety review

  • This pull request targets main
  • No direct push to main was performed
  • No tests were disabled or bypassed
  • No secrets or credentials were committed
  • No unrelated changes were included

Governance changes

Check every governance file modified:

  • No governance files changed
  • .github/workflows/**
  • .github/CODEOWNERS
  • .github/pull_request_template.md
  • AGENTS.md
  • scripts/ci.sh

Governance-file changes require explicit human approval.

Remaining before merge

  • Diagnose and resolve the focused UiServer constructor/composition hang, then rerun the exact startup test.
  • Execute the full daily-valuation post/restart integration test against a coherent current build.
  • Sync the branch with current origin/main; the checkpoint is currently 35 commits behind and 3 commits ahead.
  • Run bash scripts/ci.sh and wait for required GitHub Actions checks.

@rodoHasArrived
rodoHasArrived marked this pull request as ready for review July 15, 2026 14:22

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the daily mark-to-market valuation, period-close controls, and trade-fill ledger posting durability. Key changes include a WAL-backed trade-fill posting store for restart-safe replay of accepted fills, atomic hard-close persistence, and a durable remediation SLA queue in the backfill UI. Additionally, connection diagnostics have been refactored into the ProviderSdk. The review feedback suggests optimizing the DailyMarkToMarketService by merging the carrying-value validation loop into the main processing loop to avoid redundant iterations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +324 to +331
foreach (var key in positionKeys)
{
if (!carryingValues.TryGetValue(key, out var carryingValue) || carryingValue is null)
{
throw new InvalidOperationException(
$"Carrying-value source omitted requested security/account key {key.Symbol}/{key.FinancialAccountId ?? "unscoped"}.");
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This loop iterates over all positionKeys just to validate the carryingValues dictionary. To improve efficiency, this check can be merged into the main processing loop below (starting on line 333). This would avoid iterating over the positions twice.

@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: 806ffbe092

ℹ️ 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 on lines +750 to +755
catch (Exception ex)
{
var dropped = Interlocked.Increment(ref _droppedExecutionReports);
// Preserve the per-side-effect progress object. An identical gateway replay can
// resume at the failed step without applying portfolio/session/publication twice.
_logger.LogError(
"Execution report channel full; dropped fill report for order {OrderId} ({Symbol} {FilledQuantity} @ {FillPrice}); {DroppedCount} dropped in total — ExecutionReports consumers must drain faster",
fillIncrement.OrderId, fillIncrement.Symbol, fillIncrement.FilledQuantity, fillIncrement.FillPrice, dropped);
ex,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not swallow fill handoff failures after portfolio mutation

When _tradeEventPublisher.Publish throws before it has accepted the fill durably, this catch runs after the paper portfolio was already mutated and PortfolioApplied was set, but before TradeEventPublished, session recording, and execution-channel publication complete. Because the exception is only logged, PlaceOrderAsync can still return success and there is no guaranteed replay for gateways that do not emit the identical report again, leaving the ledger/session/subscribers missing the fill; rethrow or persist a retry before returning.

Useful? React with 👍 / 👎.

Comment on lines +124 to +128
.Select(position => new MarkToMarketPosition(
position.Symbol,
position.Quantity,
position.CostBasis,
scope.AccountId)));

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 Reject or support short snapshot quantities

PositionRecord.Quantity is documented as signed, so durable snapshots can contain negative short positions. This mapping forwards the signed quantity into MarkToMarketPosition, and the valuation run later constructs DailyPortfolioPriceMark, whose constructor rejects Quantity <= 0; any scheduled valuation with an open short therefore fails generically instead of being valued or blocked with a controlled message. Please either handle short valuation semantics here or fail closed before building the mark.

Useful? React with 👍 / 👎.

request.CompanyId,
request.EvidenceAssessments),
request.EvidenceAssessments,
BatchCorrelationId: null),

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 the event intake batch correlation

When an event-projected intake request supplies BatchCorrelationId, this wrapper drops it by always constructing the prepared request with null. IntakeCoreAsync uses that prepared value for both the saved TreasuryContext.BatchCorrelationId and the draft-save correlation id, so event batches cannot retain or recover their shared batch identity and fall back to per-event idempotency keys.

Useful? React with 👍 / 👎.

@rodoHasArrived
rodoHasArrived merged commit d1ce900 into main Jul 15, 2026
12 of 22 checks passed

@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: 8b998eaafb

ℹ️ 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 on lines 314 to +319
State = DailyValuationScheduleStateDto.Scheduled,
LastRunAtUtc = existing?.LastRunAtUtc,
LastScheduledForUtc = null,
JournalEntryId = existing?.JournalEntryId,
JournalEntryId = null,
JournalEntryIds = [],
BatchCorrelationId = null,

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 Reject reconfiguration while valuation is running

When an existing daily valuation schedule is already Running, this save path still resets it to Scheduled and clears LastScheduledForUtc/batch state. The worker claims a due schedule by persisting Running before it resolves positions and drafts; reconfiguring during that window can erase the durable claim, allow another host/tick to re-run the same NextRunAtUtc, or let the in-flight worker overwrite the operator's new configuration. Mirror the running-state conflict used for monthly schedules before saving the replacement.

Useful? React with 👍 / 👎.

Comment on lines +41 to 48
.Where(item => string.Equals(
item.TenantId,
tenantContext.TenantId,
StringComparison.OrdinalIgnoreCase))
.Where(item => tenantContext.CompanyId is null || string.Equals(
.Where(item => string.Equals(
item.CompanyId,
tenantContext.CompanyId,
StringComparison.OrdinalIgnoreCase))

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 tenantless schedule reads

For legacy tenantless workstation sessions, tenantContext.TenantId/CompanyId are null and this strict equality now filters out every tenant-owned schedule instead of preserving the prior fail-open read behavior; WorkstationTenantContext still documents that the tenant gate is write-side and that reads stay fail-open. This silently empties the monthly schedule list for those deployments, and the same strict filter was added to the daily valuation schedule list below, so keep the previous tenantContext.* is null || ... behavior unless a read endpoint explicitly requires tenant scope.

Useful? React with 👍 / 👎.

@rodoHasArrived
rodoHasArrived deleted the codex/data-provider-accounting-checkpoint-20260715 branch July 17, 2026 03:42
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