Skip to content

docs: documentation index, architecture overview, contract events reference, and resource budget - #590

Closed
Chidimj wants to merge 7 commits into
codebestia:mainfrom
Chidimj:docs/documentation-suite
Closed

docs: documentation index, architecture overview, contract events reference, and resource budget#590
Chidimj wants to merge 7 commits into
codebestia:mainfrom
Chidimj:docs/documentation-suite

Conversation

@Chidimj

@Chidimj Chidimj commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Adds four documentation entry points that were missing. Docs only — no code changed (+1242 lines, 0 deletions).

Addresses issues #589, #587, #581, #582. Auto-close keywords intentionally omitted — see note at the bottom.

Doc Issue
docs/README.md Documentation index and map (#589)
docs/architecture-overview.md System architecture overview (#587)
contracts/docs/contracts-events.md Contract events reference (#581)
contracts/docs/concepts-resource-budget.md WASM size and resource budget (#582)

Each was developed on its own branch (docs/589-*, docs/587-*, docs/581-*, docs/582-*) and merged here so the cross-links between them resolve. Per-issue detail is in the individual commit messages.

Verified, not assumed

  • All 70 .md files in the repo are indexed exactly once
  • 0 broken links across all five changed files
  • Mermaid diagram renders through mermaid-cli with no parse errors
  • WASM sizes measured from a real cargo build --release --target wasm32-unknown-unknown, arithmetic re-checked against the measured bytes

Defect found while writing the events reference

The backend chain listener subscribes to a proposal_executed topic that no contract publishes. proposals emits symbol_short!("executed") and symbol_short!("execut") instead; group_treasury has no execution event at all. The listener's statusMap has a proposal_executed: 'executed' entry, so the code path exists but is unreachable — a proposal never reaches executed status in the off-chain mirror via the listener.

Pre-existing, and not introduced in any single commit: "executed" (dc4169e, 2026-05-29), "execut" (9929bf9, 2026-06-25), and the listener's 'proposal_executed' (78f8bb9, 2026-06-26) were written by three different authors across four weeks, with no test crossing the boundary to catch the mismatch. symbol_short! permits 9 characters and "executed" is 8, so the truncation in execut looks unforced.

Documented here, not fixed — changing an emitted topic is a behavioural change to the chain interface and wants its own issue and review. Worth noting for whoever takes it: fixing the topic requires a redeploy, and events already emitted on-chain keep the old name permanently, so the listener likely needs to match all three names through a transition rather than only the corrected one.

Four further consumption gaps are documented in the same file: group_treasury has no execution event tying a fund movement back to its proposal; deposit and withdraw (the two value-movement events) have no consumer; only one contract id is watched for treasury topics, while both contracts publish a proposal_created with different payloads and different id widths (u32 vs u64); and vote-level events are unconsumed.

Notes on the issue text

Three files referenced by the issues do not exist in this repository, and never have (checked full history):

  • Documentation index and map #589 refers to a top-level CONTRIBUTING.md and a docs/adr/ directory. The "start here" path therefore ends at the Contributing section of the root README, with a note to repoint it if a dedicated CONTRIBUTING.md is added.
  • System architecture overview #587 refers to IMPLEMENTATION_DOCS.md as the existing long-form design spec. The overview links to the per-app docs as the deeper reference instead.

#582 implies the contracts are near the size limit. They are not — group_treasury 31,843 B (31.1% of the 100 KB gate), proposals 25,931 B (25.3%), token_transfer 10,539 B (10.3%). The doc records the real headroom and identifies the constraint that actually binds first: all three contracts keep per-proposal and per-voter data in instance storage, which grows unbounded and is read and written whole on every call, with several functions doing linear scans over it.

On the Closes #N keywords

Deliberately omitted. All four issues are currently unassigned on GitHub, which does not match the expectation that they were assigned, so the issue numbers are worth confirming before wiring up auto-close. Happy to add Closes #589 / Closes #587 / Closes #581 / Closes #582 (each on its own line — the keyword does not chain across a comma) once confirmed.

Adds docs/README.md as the single entry point to the repository's
documentation. Every .md file in the repo (excluding generated output
and dependency directories) is listed exactly once with a one-line
description.

Documents are grouped by reader intent rather than by directory:
new contributor, backend developer, frontend developer, contract
developer, operator, security reviewer, and AI/data developer. A
document needed by two roles is listed under both, since each section
is meant to stand alone.

Includes a "Start here" path for first-time contributors that ends at
the contribution guidelines, and a maintenance section stating that the
index must be updated whenever a document is added, moved, or removed.

The root README now links to the index and to the architecture
overview.

Note: the issue refers to a top-level CONTRIBUTING.md and a docs/adr/
directory. Neither exists in this repository, so the "Start here" path
ends at the Contributing section of the root README and calls out that
it should be repointed if a dedicated CONTRIBUTING.md is added.
Adds docs/architecture-overview.md as the orientation entry point for
the system: one Mermaid diagram showing all four apps, the stateful
infrastructure (Postgres, Redis, object storage, Weaviate), the Stellar
network, and the external LLM provider, plus a table naming the
protocol on every edge.

Each component gets a short paragraph covering its responsibility and,
explicitly, what it must never do — the invariants that are easy to
break accidentally (the gateway must not acquire a decryption path,
Redis must not be treated as durable, the AI agent must not gate a
transfer).

Two end-to-end paths are traced concretely against the current code:
sending an encrypted message (per-device envelope encryption through
deliveryPipeline fan-out to delivery receipts) and executing a treasury
withdrawal (on-chain propose/vote/execute with the listener maintaining
an off-chain mirror).

The document is explicitly scoped as orientation only and defers to the
per-app documents, which it links throughout.

Notes a real defect found while tracing path 2: the backend listener
subscribes to a `proposal_executed` topic that no contract publishes —
`proposals` emits the truncated symbols `executed` and `execut`. The
per-event detail belongs in the contract events reference (codebestia#581); this
document links to it.

The issue refers to IMPLEMENTATION_DOCS.md as the existing long-form
design spec. No such file exists in this repository, so this document
links to the per-app docs as the deeper reference instead.
Adds contracts/docs/contracts-events.md documenting all sixteen
env.events().publish(...) call sites across token_transfer,
group_treasury and proposals: topic tuple, data payload field by field,
the state change each event signals, and whether the publish happens
before or after the corresponding storage write.

Emission order is called out per event because two of them —
group_treasury's proposal_approved and proposal_rejected — publish
before the proposal is persisted, setting the status on the in-memory
struct first. Not observable to an off-chain consumer given transaction
atomicity, but relevant when reading the contract.

A summary table marks each event as consumed or unconsumed by the
backend listener, and a dedicated section collects the five consumption
gaps found while cross-referencing the contracts against
stellarListener.ts:

- the listener subscribes to `proposal_executed`, a topic no contract
  publishes. proposals emits `executed` and `execut` instead, so the
  status map entry is unreachable and a proposal never reaches the
  executed status in the off-chain mirror via the listener
- group_treasury has no execution event tying a fund movement back to
  the proposal that authorised it
- deposit and withdraw, the two value-movement events, have no consumer
- only one contract id is watched for treasury topics, and both
  contracts publish a `proposal_created` with different payloads and
  different id widths (u32 vs u64)
- vote-level events are unconsumed; on-chain votes are invisible to the
  backend until a transition event fires

Also documents two payload gaps (DepositEvent and WithdrawEvent omit
the token address despite per-token balance tracking) and notes that
the proposer's auto-approval emits no withdraw_vote, so counting those
events undercounts approvals by one.

The `executed` / `execut` split is flagged as a naming defect rather
than a constraint: symbol_short! permits 9 characters and "executed" is
8, so the truncation is unforced.

Cross-links the backend chain listener source, the treasury API doc,
and the deployment doc.
Adds contracts/docs/concepts-resource-budget.md covering the deployed
size constraint and the wider resource picture around it.

Documents the gate as CI actually implements it: 102,400 bytes per
contract, enforced in the "Report WASM binary sizes" step of
contracts-ci.yml, run per-contract across a fail-fast:false matrix,
measured against the raw cargo build output with no wasm-opt step, and
posted to the PR as an update-in-place comment keyed on a marker
comment. Notes that the gate is per-contract rather than cumulative and
that the step reports the full table before failing.

Records current sizes measured from a local release build, with
headroom: group_treasury 31,843 B (31.1% of gate), proposals 25,931 B
(25.3%), token_transfer 10,539 B (10.3%). Includes the command to
reproduce them, since sizes drift with soroban-sdk upgrades.

Documents each [profile.release] setting and the cost of changing it,
including that overflow-checks = true costs size deliberately and
should not be traded away in contracts that move funds.

Gives concrete size-reduction techniques in effort order: profile with
twiggy first, run stellar contract optimize, replace panic string
literals with a #[contracterror] enum, keep formatting machinery out of
the shipped path, deduplicate generic instantiations, split along a real
boundary, and only then raise the threshold.

Closes with the resources beyond raw size — CPU instructions, memory,
ledger entry reads/writes, events, rent/TTL, and transaction size — and
identifies the constraint that actually binds first in this codebase:
all three contracts keep per-proposal and per-voter data in instance
storage, which grows unbounded and is read and written whole on every
call, and several functions do linear scans over it.
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Chidimj Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@github-actions

Copy link
Copy Markdown

👋 Hi @Chidimj, thanks for your contribution!

Pull requests from contributors must target the dev branch — only the repo maintainer merges into main.

This PR is being closed automatically. Please open a new PR (or retarget this one by reopening it after editing the base branch) against dev.

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