Constructive Events
Event tracking, gamification, progressive trust, and achievement-based rewards. Configured through blueprints (EventTracker nodes + achievements[]) and module options (trust_ladder), and managed via the ORM.
When to Apply
Use this skill when:
- Adding event tracking to tables (EventTracker node)
- Defining achievements with requirements and credit rewards
- Building invite virality chains (EventReferral with max_depth)
- Implementing period-aware recurring achievements
- Tracking analytics events on row changes
- Turning evidence into access — trust ladders, earned levels, capability rewards
Architecture
Table row change
→ EventTracker trigger (compound conditions evaluated)
→ record_event(event_name, actor_id)
→ app_events log (partitioned, time-based retention)
→ upsert_achievement() → event_aggregates updated
→ tg_check_achievements
→ level_achieved() → level_grants created
→ tg_achievement_reward → credits granted
→ tg_invitee_achievement → record_event for inviter
Features
| Feature |
Node/Config |
Purpose |
| EventTracker |
Table nodes[] |
Record events on row INSERT/UPDATE/DELETE |
| achievements[] |
Top-level blueprint |
Levels with requirements and rewards |
| has_invite_achievements |
Entity type flag |
Auto-wire invitee achievement chain |
| EventReferral |
Table nodes[] |
Attribute events to inviters (multi-level) |
| period_interval |
Event type config |
Auto-reset counts for recurring achievements |
| trust_ladder |
events_module option |
Seed a ladder of rungs that earn capability bits and capacity |
Trust Ladders
A trust ladder is a set of rungs that turn recorded evidence into access — the same levels/requirements/rewards machinery as achievements[], with rungs that reward a capability rather than a credit. Request one by slug when the events module is provisioned:
["events_module", { "scope": "app", "trust_ladder": "humanity" }]
| Slug |
Question it answers |
Rungs |
humanity |
Does this account belong to someone? |
reachable (email or phone or captcha) → profile_complete badge |
metered |
How much may this account consume? |
reachable → accountable → established → trusted → vouched, each buying limit capacity |
Humans, bots and agents climb identically — nothing in a ladder asserts humanity, it accumulates evidence that costs something to fake. No shipped module preset requests a ladder yet, so it must be named explicitly today. Full rung tables, rung fields, and the metered limit baseline: trust-ladders.md.
Levels and Capabilities
A level reached through events can project into the access-control system: the reward attached to a rung sets a capability with kind = 'level' on the member's row, so an RLS policy can require it exactly like a granted capability (levels: ["level.reachable"]). This is how earned trust becomes enforceable access rather than a display badge — a rung with no capability reward is a badge and grants nothing.
Two things to know before designing around it:
- Owners and admins hold every level automatically. Their membership is given the complete capability set, so a level requirement never constrains them inside their own entity. See
constructive-access-control → admin-owner-member.md.
- Levels are earned, never granted. Do not expose
kind = 'level' rows in a grant or profile picker; filter capability lists by kind.
See constructive-access-control → named-capabilities.md for the capability model itself.
EventTracker
{
"tables": [{
"table_name": "user_profiles",
"nodes": [
{ "$type": "EventTracker", "data": {
"event_name": "avatar_uploaded",
"events": ["UPDATE"],
"watch_fields": ["avatar_url"],
"conditions": { "field": "avatar_url", "op": "IS NOT NULL" }
}}
]
}]
}
EventReferral (Multi-Level Referral)
{ "$type": "EventReferral", "data": {
"event_name": "purchase_completed",
"max_depth": 3
}}
max_depth (1–10) walks up the claimed_invites chain N levels, crediting each ancestor inviter.
References
Cross-References
1---2name: constructive-events3description: EventTracker, achievements, trust ladders, referrals, invite virality — EventTracker blueprint node for recording events on row changes, achievements[] for levels with credit rewards, the humanity and metered trust ladders that turn evidence into capability bits, EventReferral for multi-level referral chains, period-aware counting. Use when asked to 'add analytics', 'track events', 'add achievements', 'gamification', 'progressive trust', 'trust ladder', 'humanity', 'verify a human', 'levels', 'EventTracker', 'level requirements', 'achievement rewards', 'invite virality', 'referral credits', 'EventReferral', 'max_depth', 'multi-level referral', or when working with events_module in blueprints.4---56# Constructive Events78Event tracking, gamification, progressive trust, and achievement-based rewards. Configured through blueprints (EventTracker nodes + `achievements[]`) and module options (`trust_ladder`), and managed via the ORM.910## When to Apply1112Use this skill when:13- Adding event tracking to tables (EventTracker node)14- Defining achievements with requirements and credit rewards15- Building invite virality chains (EventReferral with max_depth)16- Implementing period-aware recurring achievements17- Tracking analytics events on row changes18- Turning evidence into access — trust ladders, earned levels, capability rewards1920## Architecture2122```23Table row change24 → EventTracker trigger (compound conditions evaluated)25 → record_event(event_name, actor_id)26 → app_events log (partitioned, time-based retention)27 → upsert_achievement() → event_aggregates updated28 → tg_check_achievements29 → level_achieved() → level_grants created30 → tg_achievement_reward → credits granted31 → tg_invitee_achievement → record_event for inviter32```3334## Features3536| Feature | Node/Config | Purpose |37|---------|-------------|---------|38| **EventTracker** | Table `nodes[]` | Record events on row INSERT/UPDATE/DELETE |39| **achievements[]** | Top-level blueprint | Levels with requirements and rewards |40| **has_invite_achievements** | Entity type flag | Auto-wire invitee achievement chain |41| **EventReferral** | Table `nodes[]` | Attribute events to inviters (multi-level) |42| **period_interval** | Event type config | Auto-reset counts for recurring achievements |43| **trust_ladder** | `events_module` option | Seed a ladder of rungs that earn capability bits and capacity |4445## Trust Ladders4647A **trust ladder** is a set of rungs that turn recorded evidence into access — the same levels/requirements/rewards machinery as `achievements[]`, with rungs that reward a *capability* rather than a credit. Request one by slug when the events module is provisioned:4849```json50["events_module", { "scope": "app", "trust_ladder": "humanity" }]51```5253| Slug | Question it answers | Rungs |54|---|---|---|55| `humanity` | Does this account belong to someone? | `reachable` (email **or** phone **or** captcha) → `profile_complete` badge |56| `metered` | How much may this account consume? | `reachable` → `accountable` → `established` → `trusted` → `vouched`, each buying limit capacity |5758Humans, bots and agents climb identically — nothing in a ladder asserts humanity, it accumulates evidence that costs something to fake. **No shipped module preset requests a ladder yet**, so it must be named explicitly today. Full rung tables, rung fields, and the `metered` limit baseline: [trust-ladders.md](./references/trust-ladders.md).5960## Levels and Capabilities6162A level reached through events can project into the access-control system: the reward attached to a rung sets a capability with `kind = 'level'` on the member's row, so an RLS policy can require it exactly like a granted capability (`levels: ["level.reachable"]`). This is how earned trust becomes enforceable access rather than a display badge — a rung with no capability reward is a badge and grants nothing.6364Two things to know before designing around it:6566- **Owners and admins hold every level automatically.** Their membership is given the complete capability set, so a level requirement never constrains them inside their own entity. See [`constructive-access-control` → admin-owner-member.md](../constructive-access-control/references/admin-owner-member.md#owner-and-admin-hold-every-capability).67- **Levels are earned, never granted.** Do not expose `kind = 'level'` rows in a grant or profile picker; filter capability lists by `kind`.6869See [`constructive-access-control` → named-capabilities.md](../constructive-access-control/references/named-capabilities.md#two-kinds-of-capability) for the capability model itself.7071## EventTracker7273```json74{75 "tables": [{76 "table_name": "user_profiles",77 "nodes": [78 { "$type": "EventTracker", "data": {79 "event_name": "avatar_uploaded",80 "events": ["UPDATE"],81 "watch_fields": ["avatar_url"],82 "conditions": { "field": "avatar_url", "op": "IS NOT NULL" }83 }}84 ]85 }]86}87```8889## EventReferral (Multi-Level Referral)9091```json92{ "$type": "EventReferral", "data": {93 "event_name": "purchase_completed",94 "max_depth": 395}}96```9798`max_depth` (1–10) walks up the `claimed_invites` chain N levels, crediting each ancestor inviter.99100## References101102| File | Content |103|------|---------|104| [event-tracker.md](./references/event-tracker.md) | EventTracker configuration reference |105| [achievements.md](./references/achievements.md) | Achievement levels, requirements, rewards |106| [trust-ladders.md](./references/trust-ladders.md) | Progressive trust — the `humanity` and `metered` ladders, rung fields, capability rewards |107| [event-referral.md](./references/event-referral.md) | Referral attribution and multi-level chains |108| [invite-virality.md](./references/invite-virality.md) | Invite virality chain wiring |109| [triggers.md](./references/triggers.md) | Trigger internals and compound conditions |110111## Cross-References112113- **Limits and credits:** [`constructive-billing`](../constructive-billing/SKILL.md)114- **Entity types and invites:** [`constructive-entities`](../constructive-entities/SKILL.md)115- **Background jobs (shared conditions system):** [`constructive-jobs`](../constructive-jobs/SKILL.md)116- **Blueprint definitions:** [`constructive-blueprints`](../constructive-blueprints/SKILL.md)