fix(sec): warn when deferred imports stay stale
This commit is contained in:
@@ -23,7 +23,11 @@ from app.services.data_import import (
|
||||
STATUS_PROMOTED,
|
||||
run_import,
|
||||
)
|
||||
from app.services.sec_fundamentals_importer import SecFundamentalsImporter
|
||||
from app.services.sec_fundamentals_importer import (
|
||||
SecFundamentalsImporter,
|
||||
StagedFundamentals,
|
||||
)
|
||||
from app.services.sec_universe import ResolvedUniverse
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -232,6 +236,32 @@ async def test_consistency_gate_defers_without_alert_when_facts_lag_index(engine
|
||||
assert await _count(factory, SystemEvent) == 0 # expected SEC lag does not alert
|
||||
|
||||
|
||||
async def test_companyfacts_lag_does_not_mask_second_validation_failure():
|
||||
importer = SecFundamentalsImporter(today=date(2026, 5, 3))
|
||||
importer._latest_index_date = date(2026, 5, 2)
|
||||
staged = StagedFundamentals(
|
||||
resolved=ResolvedUniverse(),
|
||||
missing_xbrl=[{
|
||||
"cik": "0000320193",
|
||||
"accession": "GHOST",
|
||||
"form": "10-Q",
|
||||
"index_date": date(2026, 5, 1),
|
||||
"age_days": 2,
|
||||
"reason": "not_in_companyfacts",
|
||||
}],
|
||||
invalid_payloads=[{
|
||||
"cik": "0000789019",
|
||||
"reason": "missing facts structure",
|
||||
}],
|
||||
)
|
||||
|
||||
result = await importer.validate(None, staged)
|
||||
|
||||
assert not result.ok
|
||||
assert not result.retryable
|
||||
assert len(result.messages) == 2
|
||||
|
||||
|
||||
async def test_gate_separates_missing_submissions_from_missing_facts(engine):
|
||||
"""An index row the issuer's own filing list does not carry is a different
|
||||
failure from a Company-Facts lag, and must not be reported as one."""
|
||||
|
||||
Reference in New Issue
Block a user