bastion/weight-system
Skill8 starsChanged 4 months agoMITView on GitHub
Calculates dynamic persona priority and manages weight adjustments (current_weight). Persists changes in USER.md and records history with timestamp and justification in personas/{slug}/weight-history.md.
In this repository17 other files it gives its agents.
- bastion/agentskills-installSkill
- bastion/agentskills-publishSkill
- bastion/calendarSkill
- bastion-pet-packSkill
- bastion/channel-scaffoldSkill
- bastion/crisis-modeSkill
- bastion/life-logSkill
- mcporterSkill
- bastion/mesh-connectSkill
- bastion/mobile-connectSkill
- bastion/onboardingSkill
- bastion/output-validatorSkill
- bastion/persona-engineSkill
- bastion/proactive-engineSkill
- bastion/self-improvingSkill
- bastion/skill-writerSkill
- bastion/weekly-reviewSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 70
When crisis-mode detects a crisis and identifies affected persona:
- Very specific: line 87
Every Monday at 9am, HEARTBEAT triggers weekly-review, which:
- Very specific: line 92
After confirmation, calls adjust_weight() for each persona with accepted suggestion
- Very specific: line 98
When a pattern is promoted or decayed, self-improving records the change:
- Very specific: line 124
After confirmation, call adjust_weight()
- Very specific: line 239
If the slug doesn't exist in USER.md, UserMdAdapter.get_current_weight() raises KeyError.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: bastion/weight-system
Objective
Manage Bastion's dynamic persona weight system:
- Calculate priority of a persona given current context (deep work, deadline)
- Adjust current_weight in a persisted and auditable way
- Record history of all changes with timestamp and justification
Concepts
base_weight vs current_weight
| Field | Description | When it changes |
base_weight | Fixed weight defined at persona creation (0.0–1.0) | Rarely — only by explicit user edit |
current_weight | Current dynamic weight (0.0–1.0) | Crises, weekly reviews, learnings, manual adjustments |
current_weight is the value used in all priority and matching calculations.
Priority Formula
priority = current_weight
+ 0.1 × (deep_work)
+ 0.2 × (deadline ≤ 4h)
+ 0.15 × (deadline ≤ 12h)
+ 0.1 × (deadline ≤ 24h)
+ 0.05 × (deadline ≤ 48h)Result is always clamped to [0.0, 1.0].
Deadline bonuses are additive — a 3h deadline accumulates bonuses for ≤4h, ≤12h, ≤24h and ≤48h simultaneously.
Examples:
| current_weight | deep_work | deadline | priority |
| 0.7 | false | none | 0.70 |
| 0.7 | true | none | 0.80 |
| 0.7 | false | 3h | 1.00 (clamped de 1.20) |
| 0.5 | true | 20h | 0.75 |
| 0.9 | false | 50h | 0.90 |
When This Skill is Triggered
1. Crisis Boost (bastion/crisis-mode)
When crisis-mode detects a crisis and identifies affected persona:
adjust_weight(
persona_slug=<crisis persona slug>,
delta=+0.3,
justification="Crisis boost: <crisis description>",
persistence=UserMdAdapter(...)
)Clamp ensures result never exceeds 1.0.
2. Weekly Review (bastion/weekly-review)
Every Monday at 9am, HEARTBEAT triggers weekly-review, which:
- Analyzes last 50 life_log records per persona
- Compares usage pattern with current weights
- Suggests adjustments to user
- After confirmation, calls
adjust_weight()for each persona with accepted suggestion
3. Self-Improving (bastion/self-improving)
When a pattern is promoted or decayed, self-improving records the change:
adjust_weight(
persona_slug=<slug>,
delta=<+0.05 for promotion, -0.05 for decay>,
justification="Pattern promoted to HOT: <pattern name>",
persistence=UserMdAdapter(...)
)4. Manual Adjustment by User
User can request direct adjustment:
"Increase Tech Lead persona weight to 0.95"
"Reduce Entrepreneur weight by 0.1"Flow:
- Identify persona by name or slug
- Calculate necessary delta
- Confirm with user:
"{locale:confirm_adjust}" - After confirmation, call
adjust_weight()
Persistence
USER.md
current_weight of each persona is maintained in USER.md frontmatter:
personas:
- slug: "tech-lead"
name: "Tech Lead"
current_weight: 0.9
- slug: "empreendedor"
name: "Entrepreneur"
current_weight: 0.7UserMdAdapter updates this value automatically on each adjust_weight() call.
personas/{slug}/weight-history.md
Each adjustment generates a history line:
# Weight History
- 2025-01-15T10:30:00+00:00 | 0.7000 → 1.0000 | Crisis boost: production server down
- 2025-01-22T09:00:00+00:00 | 1.0000 → 0.8500 | Weekly review: usage normalized after crisis
- 2025-01-29T09:00:00+00:00 | 0.8500 → 0.9000 | Pattern promoted to HOT: deploy-checklistFormat of each line:
- {ISO 8601 timestamp} | {old_weight:.4f} → {new_weight:.4f} | {justification}Architecture (Hexagonal)
Skill uses Protocol/Adapter pattern to decouple business logic from persistence:
WeightPersistenceProtocol (port)
├── get_current_weight(slug) → float
├── set_current_weight(slug, weight) → None
└── append_weight_history(slug, entry) → None
UserMdAdapter (default concrete adapter)
├── Reads/writes USER.md (YAML frontmatter)
└── Appends to personas/{slug}/weight-history.mdTo swap the persistence backend (e.g., database), implement a new adapter that satisfies WeightPersistenceProtocol — without changing calculate_priority() or adjust_weight().
CLI Commands
IMPORTANT: CLI Command When running inside Bastion, invoke these operations through the declared tool interface. Do not simulate tool results.
from skills.weight_system.weight_system import (
calculate_priority,
adjust_weight,
UserMdAdapter,
WeightHistoryEntry,
)
from pathlib import Path
# Instantiate the adapter
adapter = UserMdAdapter(
user_md_path=Path("USER.md"),
personas_dir=Path("personas"),
)
# Calculate priority
priority = calculate_priority(
current_weight=0.7,
deep_work=True,
deadline_hours=6.0,
)
# → 0.95 (0.7 + 0.1 + 0.15)
# Adjust weight (crisis boost)
new_weight = adjust_weight(
persona_slug="tech-lead",
delta=+0.3,
justification="Crisis boost: critical production deploy",
persistence=adapter,
)
# → persists to USER.md + appends to personas/tech-lead/weight-history.mdEdge Cases
Clamp to [0.0, 1.0]
Any delta that would take the weight below 0.0 or above 1.0 is silently clamped:
adjust_weight("tech-lead", delta=+0.5, ...) # current=0.9 → new=1.0 (not 1.4)
adjust_weight("tech-lead", delta=-0.5, ...) # current=0.1 → new=0.0 (not -0.4)Persona not found in USER.md
If the slug doesn't exist in USER.md, UserMdAdapter.get_current_weight() raises KeyError.
The caller must handle this error and verify the persona exists before adjusting.
weight-history.md file doesn't exist
The UserMdAdapter creates the file automatically on the first write, including the # Weight History header.
personas/{slug}/ folder doesn't exist
The UserMdAdapter creates the folder automatically via mkdir(parents=True, exist_ok=True).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

