Archived context note: point-in-time audit output retained for traceability.
Use current rules and runbooks for active decisions. Seealphaswarm_docs/archive/README.md.
AlphaSwarm Metadata & Lineage Consolidation Hard-Rules Audit
Scope audited: metadata/aspect refactor files listed in the request (plus directly adjacent migration/agent boundary checks needed for AGENTS hard-rule validation).
Mode: read-only audit (no code changes), targeted grep/read validation.
Rule 6 (immutable migrations): FAILβ
Evidenceβ
- Shipped migration edited:
alembic/versions/0046_workflow_versioning.pywas modified after commit.- Diff evidence (
git diff ccd02e7..HEAD -- alembic/versions/0046_workflow_versioning.py):alembic/versions/0046_workflow_versioning.py:184["experiment_id"], ["alphaswarm_experiments.id"], ondelete="SET NULL"(wasexperiments.id)
alembic/versions/0046_workflow_versioning.py:187["test_id"], ["alphaswarm_tests.id"], ondelete="SET NULL"(wastests.id)
- Diff evidence (
- Unexpected parallel 0049 migration files present:
alembic/versions/0049_paper_baseline_aspects.py:20->down_revision = "0048_metadata_aspects"alembic/versions/0049_paper_metadata_seed_aspects.py:21->down_revision = "0048_metadata_aspects"- This creates two
0049-level descendants from0048in-tree.
- Requested chain segments do point correctly:
alembic/versions/0048_metadata_aspects.py:23->down_revision = "0047_data_fabric_foundation"alembic/versions/0049_paper_metadata_seed_aspects.py:21->down_revision = "0048_metadata_aspects"
Rule 7 (settings-only env access): PASS (in scoped new code)β
Evidenceβ
- No direct
os.environ,os.getenv, oros.environ.getfound in the targeted metadata/aspect refactor modules (metadata package, new MCP tools, DataHub aspect files, trading gate files, aspect API route, and 0048/0049 metadata migrations). alphaswarm/config/settings.pycontains env reads by design (centralized settings source of truth), which is compliant.
Violations in scoped new codeβ
- None found.
Rule 22 (DataMCPTool boundary): PASS (no new violations in refactor scope)β
Evidenceβ
git diff --name-only ccd02e7..HEAD -- alphaswarm/agentsreturned no changed files for this refactor window.- No new
alphaswarm/agents/*modules in the audited scope introducedfrom alphaswarm.persistence.models...imports.
Violations in scoped new codeβ
- None found.
Rule 26 (CredentialResolver): FAILβ
Violationsβ
alphaswarm/data/datahub/aspect_puller.py:228token=(settings.datahub_token or None),- Direct service token access outside
alphaswarm/credentials/; should resolve throughCredentialResolver.
Rule 29 (BaseDataset + EntityPicker): FAILβ
Violationsβ
alphaswarm_client/src/routes/metadata/aspects/page.tsx:183- Free-text URN field:
<Input ... placeholder="urn:alphaswarm:dataset:prod:alphaswarm_silver_alpha_vantage.daily_bars" ... />- This is an entity-selection input path implemented as free text instead of a cache-backed picker.
alphaswarm_client/src/routes/metadata/aspects/page.tsx:135- Inline TODO confirms missing picker integration:
replace with EntityPicker.
Rule 33-34 (tenancy + experiment_id): FAILβ
33 ownership/tenancy evidenceβ
- ORM mixins present:
alphaswarm/persistence/models_aspects.py:27->class MetadataEntity(Base, ProjectScopedMixin):alphaswarm/persistence/models_aspects.py:38->class EntityAspect(Base, ProjectScopedMixin):
- Workspace tenancy filter implemented in primary reads:
alphaswarm/data/mcp/tools/aspects.py:33-37(workspace_id == ctx.workspace_id OR workspace_id IS NULL)alphaswarm/data/mcp/tools/aspects.py:762history query applies_workspace_scope_clause(ctx)alphaswarm/data/mcp/tools/datahub.py:136-144scoped EntityAspect read applies(workspace_id == ctx.workspace_id OR IS NULL)
- Violation (missing tenancy filter on an EntityAspect read):
alphaswarm/data/mcp/tools/aspects.py:670-676- Query reads latest
EntityAspectby URN/aspect without applying_workspace_scope_clause(ctx)(or equivalent workspace predicate).
34 experiment_id evidenceβ
- No new run table added by metadata migrations (
0048,0049_*are aspect/entity focused). MlTestResultis modeled and persisted as an aspect, not a run row:alphaswarm/metadata/openmetadata/models_ml.py:216->class MlTestResult(...)alphaswarm/tasks/ml_test_tasks.py:224->write_aspect(session, model_urn, "mlTestResult", payload)
- Conclusion: no
experiment_idrequirement triggered for these aspect records.
Style checks (__future__, print, Pydantic V2, logging): PASS (in scoped new code)β
Evidenceβ
from __future__ import annotationspresent across new metadata/aspect Python modules (includingalphaswarm/metadata/*,alphaswarm/persistence/models_aspects.py,alphaswarm/data/datahub/aspect_*,alphaswarm/data/mcp/tools/aspects.py,alphaswarm/data/mcp/tools/namespace_policy.py,alphaswarm/rag/document_aspects.py,alphaswarm/api/routes/metadata_aspects.py,alphaswarm/trading/metadata_gate.py,alembic/versions/0048*,alembic/versions/0049*).- No
print()function usage found in scoped new Python files (onlyConsole().print(...)inalphaswarm/metadata/schema_export.py, which is not the built-inprint()call). - No
.dict()/.parse_obj()/pydantic.v1usage found in scoped new Python files. - Modules using
import loggingin scoped files definelogger = logging.getLogger(__name__).
Style violations in scoped new codeβ
- None found.
Aggregate verdict: RED (blocking violations)β
Blocking hard-rule findings:
- Rule 6: shipped migration
0046_workflow_versioning.pyedited post-commit. - Rule 6: concurrent
0049_*descendants from0048present (baseline+metadata_seed). - Rule 26: direct
settings.datahub_tokenaccess inalphaswarm/data/datahub/aspect_puller.py:228. - Rule 29: free-text URN entity selection in
alphaswarm_client/src/routes/metadata/aspects/page.tsx:183. - Rule 33: unscoped
EntityAspectread inalphaswarm/data/mcp/tools/aspects.py:670-676.
Out-of-scope / adjacent pre-existing findings (informational)β
- Rule 22 boundary (existing agent modules): direct persistence-model imports exist under
alphaswarm/agents/*(examples:alphaswarm/agents/runtime.py:232,alphaswarm/agents/analysis/reflector.py:43,alphaswarm/agents/strategy_memory.py:30). - Rule 26 credential pattern (existing):
alphaswarm/data/datahub/client.py:35usessettings.datahub_tokendirectly. - Rule 7 env access (existing/non-targeted areas):
alphaswarm/api/routes/sources.py:360,alphaswarm/api/routes/sources.py:628alembic/versions/0051_seed_wiley_tech.py(multipleos.environ.get(...)calls)
- Pydantic V2 style (existing/non-targeted):
alphaswarm/data/iceberg_catalog.py:1292->.dict()alphaswarm/data/airbyte/embedded.py:142->.dict()