Add Phase 1 distributed lean workstation agent foundation

This commit is contained in:
A R R R Associates
2026-08-22 11:37:25 +05:30
parent 798a2532c1
commit c8b7dcb805
9 changed files with 269 additions and 7 deletions
+35
View File
@@ -183,6 +183,41 @@ class BranchStorageNode(CommonBase):
updated_at_utc: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc), nullable=False)
class ERPWorkstationAgent(CommonBase):
"""A physical workstation running the lean ERP Local Agent.
Workstations are intentionally separate from BranchStorageNode: a branch keeps
one canonical storage node/root while any number of office PCs may use that
node's authenticated outbound tunnel for Tally/local-tool capabilities.
"""
__tablename__ = "erp_workstation_agents"
__table_args__ = (
UniqueConstraint("storage_node_id", "agent_instance_id", name="uq_erp_workstation_agent_instance"),
)
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
tenant_id: Mapped[int] = mapped_column(ForeignKey("tenants.id", ondelete="CASCADE"), nullable=False, index=True)
branch_id: Mapped[int | None] = mapped_column(ForeignKey("branches.id", ondelete="SET NULL"), nullable=True, index=True)
storage_node_id: Mapped[int] = mapped_column(ForeignKey("branch_storage_nodes.id", ondelete="CASCADE"), nullable=False, index=True)
agent_instance_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
machine_fingerprint: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
machine_name: Mapped[str] = mapped_column(String(200), nullable=False)
platform_name: Mapped[str | None] = mapped_column(String(120), nullable=True)
agent_version: Mapped[str | None] = mapped_column(String(40), nullable=True, index=True)
capabilities_json: Mapped[str | None] = mapped_column(Text, nullable=True)
tally_connected: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
tally_company_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
tally_companies_json: Mapped[str | None] = mapped_column(Text, nullable=True)
status: Mapped[str] = mapped_column(String(30), nullable=False, default="online", index=True)
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, index=True)
first_seen_at_utc: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), nullable=False)
last_seen_at_utc: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), nullable=False, index=True)
last_seen_ip: Mapped[str | None] = mapped_column(String(80), nullable=True)
storage_node = relationship("BranchStorageNode")
class DocumentStorageJob(CommonBase):
"""Cloud-to-local branch storage transfer job.