Your agent should know
what your app is supposed to do.

Teach it the rules your team already knows: who can invite a teammate, how discounts work, what a refund must restore. Keep that knowledge connected to the tests.

reflow / NorthstarIllustrative example

Application knowledge

Business rules, journeys and the source behind them.
business-rules / team-access.mdMarkdown

Team access & permissions

Northstar is a shared workspace for a commerce team. A person’s role determines what they can change, from inviting a teammate to issuing a refund.

Expected behavior

An invitation preserves the role selected by its sender.

Owners and admins can invite editors and viewers. Accepting an invitation grants exactly that role; it never promotes someone to owner.

Who can do what

RoleInvite teammatesManage orders
OwnerYesEdit & refund
AdminYesEdit & refund
EditorNoEdit & refund
ViewerNoRead only

References

src/team/invitations.tssrc/auth/permissions.ts/settings/team

Flows that check this rule

  • invite-member
  • accept-invitation
  • verify-role

Invite a viewer, accept as that person, then confirm that order editing is unavailable.

Read Markdown original
# Team access & permissions

Northstar is a shared workspace for a commerce team. A person’s role determines what they can change, from inviting a teammate to issuing a refund.

## Expected behavior

An invitation preserves the role selected by its sender.

Owners and admins can invite editors and viewers. Accepting an invitation grants exactly that role; it never promotes someone to owner.

## Who can do what

| Role | Invite teammates | Manage orders |
| --- | --- | --- |
| Owner | Yes | Edit & refund |
| Admin | Yes | Edit & refund |
| Editor | No | Edit & refund |
| Viewer | No | Read only |

## References

- src/team/invitations.ts
- src/auth/permissions.ts
- /settings/team

## Flows

- invite-member
- accept-invitation
- verify-role

Invite a viewer, accept as that person, then confirm that order editing is unavailable.

## Still to explore

An invitation sent before its sender changes role has not been explored.
journeys / invite-a-teammate.mdMarkdown

Invite a teammate

Maya manages the Northstar store. She invites Alex to check order statuses without changing orders or customer data.

Expected behavior

Alex joins the same workspace with the Viewer role.

The invitation is tied to Alex’s email address and selected role. Signing in with a different address must not accept it.

At each step

StepExpected behavior
Send invitationEmail and selected role appear in pending invitations.
Accept invitationThe invited address is verified before joining.
Open the workspaceOrders are readable; editing controls are unavailable.

References

src/team/invitations.tssrc/auth/accept-invitation.ts/join

Flows that check this rule

  • invite-member
  • accept-invitation
  • verify-role

The accepted membership has the same workspace, email address and role as the invitation.

Read Markdown original
# Invite a teammate

Maya manages the Northstar store. She invites Alex to check order statuses without changing orders or customer data.

## Expected behavior

Alex joins the same workspace with the Viewer role.

The invitation is tied to Alex’s email address and selected role. Signing in with a different address must not accept it.

## At each step

| Step | Expected behavior |
| --- | --- |
| Send invitation | Email and selected role appear in pending invitations. |
| Accept invitation | The invited address is verified before joining. |
| Open the workspace | Orders are readable; editing controls are unavailable. |

## References

- src/team/invitations.ts
- src/auth/accept-invitation.ts
- /join

## Flows

- invite-member
- accept-invitation
- verify-role

The accepted membership has the same workspace, email address and role as the invitation.

## Still to explore

Expired invitations still need a separate journey.
business-rules / checkout.mdMarkdown

Checkout totals

A customer buys two Field notebooks with a ten-percent discount. Checkout, payment and the confirmation email must agree on the amount paid.

Expected behavior

Charge the total the customer approved at checkout.

Apply the discount to merchandise before adding shipping. Store monetary amounts in cents and round the discount once, for the whole order.

Worked example · USD

Line itemAmount
2 × Field notebook$40.00
WELCOME10 · 10% off merchandise−$4.00
Standard shipping$5.00
Total charged$41.00

References

src/orders/checkout.tssrc/orders/totals.ts/checkout

Flows that check this rule

  • seed-cart
  • place-order
  • verify-total

Checkout total = payment amount = saved order total = email receipt total.

Read Markdown original
# Checkout totals

A customer buys two Field notebooks with a ten-percent discount. Checkout, payment and the confirmation email must agree on the amount paid.

## Expected behavior

Charge the total the customer approved at checkout.

Apply the discount to merchandise before adding shipping. Store monetary amounts in cents and round the discount once, for the whole order.

## Worked example · USD

| Line item | Amount |
| --- | --- |
| 2 × Field notebook | $40.00 |
| WELCOME10 · 10% off merchandise | −$4.00 |
| Standard shipping | $5.00 |
| Total charged | $41.00 |

## References

- src/orders/checkout.ts
- src/orders/totals.ts
- /checkout

## Flows

- seed-cart
- place-order
- verify-total

Checkout total = payment amount = saved order total = email receipt total.

## Still to explore

Combining discount codes is not documented.
business-rules / refunds.mdMarkdown

Refunds & returned stock

An owner, admin or editor can fully refund a paid order before dispatch. The customer gets back the amount paid, including standard shipping.

Expected behavior

A full refund reverses the payment and returns the items to stock.

For the notebook order, return $41.00 and restore two notebooks. Repeating the request must not refund or restock the order twice.

Expected changes

RecordBeforeAfter
OrderPaidRefunded
Refunded amount$0.00$41.00
Available notebooks1820

References

src/orders/refunds.tssrc/inventory/adjust-stock.ts/orders/order-1042

Flows that check this rule

  • place-order
  • refund-order
  • verify-refund

The payment, order status and inventory agree after the refund. A second request changes none of them.

Read Markdown original
# Refunds & returned stock

An owner, admin or editor can fully refund a paid order before dispatch. The customer gets back the amount paid, including standard shipping.

## Expected behavior

A full refund reverses the payment and returns the items to stock.

For the notebook order, return $41.00 and restore two notebooks. Repeating the request must not refund or restock the order twice.

## Expected changes

| Record | Before | After |
| --- | --- | --- |
| Order | Paid | Refunded |
| Refunded amount | $0.00 | $41.00 |
| Available notebooks | 18 | 20 |

## References

- src/orders/refunds.ts
- src/inventory/adjust-stock.ts
- /orders/order-1042

## Flows

- place-order
- refund-order
- verify-refund

The payment, order status and inventory agree after the refund. A second request changes none of them.

## Still to explore

Partial refunds and returns after dispatch are not covered by this rule.
application / glossary.mdMarkdown

The language of Northstar

Use these terms when describing business rules and writing flows. A workspace is the team’s shared store, not an individual’s account.

Expected behavior

A membership connects one person to one workspace and one role.

The same person may belong to several workspaces. Permissions are evaluated within the workspace they are using.

Terms used in this application

TermMeaning
WorkspaceA store, its orders and its team.
MembershipA person’s role in one workspace.
InvitationA pending offer of membership to an email address.
Available stockUnits that can be sold; excludes units in paid orders.

References

src/team/membership.tssrc/inventory/stock.ts/settings/team

Flows that check this rule

  • switch-workspace
  • verify-role

Switching workspace uses the membership for the destination, not the previous workspace.

Read Markdown original
# The language of Northstar

Use these terms when describing business rules and writing flows. A workspace is the team’s shared store, not an individual’s account.

## Expected behavior

A membership connects one person to one workspace and one role.

The same person may belong to several workspaces. Permissions are evaluated within the workspace they are using.

## Terms used in this application

| Term | Meaning |
| --- | --- |
| Workspace | A store, its orders and its team. |
| Membership | A person’s role in one workspace. |
| Invitation | A pending offer of membership to an email address. |
| Available stock | Units that can be sold; excludes units in paid orders. |

## References

- src/team/membership.ts
- src/inventory/stock.ts
- /settings/team

## Flows

- switch-workspace
- verify-role

Switching workspace uses the membership for the destination, not the previous workspace.

## Still to explore

Guest access is not defined in the current application model.
generated / routes.mdGenerated

Application routes

A generated route index provides starting points for exploration. A route’s presence does not establish its expected behavior or test coverage.

Expected behavior

Read the business rules alongside the route index.

The agent records observations in authored documents after inspecting the source and exploring the application.

Discovered routes

PathPurpose
/settings/teamMembers and pending invitations
/joinAccept an invitation
/checkoutReview and pay for a cart
/orders/:idOrder details and refunds

References

src/routes.ts/

Coverage

    The route index itself is not a test.

    Read Markdown original
    # Application routes
    
    A generated route index provides starting points for exploration. A route’s presence does not establish its expected behavior or test coverage.
    
    ## Expected behavior
    
    Read the business rules alongside the route index.
    
    The agent records observations in authored documents after inspecting the source and exploring the application.
    
    ## Discovered routes
    
    | Path | Purpose |
    | --- | --- |
    | /settings/team | Members and pending invitations |
    | /join | Accept an invitation |
    | /checkout | Review and pay for a cart |
    | /orders/:id | Order details and refunds |
    
    ## References
    
    - src/routes.ts
    - /
    
    ## Coverage
    
    
    
    The route index itself is not a test.
    
    ## Still to explore
    
    Unlinked and permission-restricted screens may require further exploration.
    Fictional application · sample content

    Have your agent update the rules
    when behavior changes.

    A permissions change lets administrators invite teammates. The old knowledge page still says only owners can do it.

    Your agent compares the source change with the application knowledge and proposes an update. Review the revised rule and the checks it affects alongside the code.

    How agents maintain knowledge
    reflow / Knowledge changeIllustrative example
    Changed sourcesrc/team/permissions.ts
    canInviteRemoved: role === "owner"Added: ["owner", "admin"].includes(role)
    team-access.md3f2a → candidate

    Who can invite a teammate?

    Removed: Only owners can invite teammates.

    Added: Owners and administrators can invite teammates.

    The invitation must preserve the selected role.

    Affected checks
    invite-as-adminNew flow needed
    verify-roleKeep existing assertion

    Start by having your agent
    learn the application.

    Connect Reflow to your coding agent and ask it to explore. Review the rules it records, add your team’s context, then ask it to write the flows that check them.

    Knowledge pages keep references to the behavior they describe and call out gaps that still need investigation.

    Set up application learning
    Ask your coding agent
    Learn this app with Reflow. Load the application-onboarding and knowledge-corpus skills. Read the source and explore the running app. Map our terminology, business rules and important user journeys into the knowledge base. Show me what you learned and which areas you haven't explored.

    Then ask: “Write a flow that checks the invitation preserves the selected role. Use flow-authoring and plugin-execution, and show me the plan.”

    Turn an application rule
    into a repeatable check.

    Define your test graph