modus
Menu
On this page

The entry plans

The exports of the plans service that act for the principal of the caller . The root service writes the principal of each connection, so a caller names no principal: it can see and change only its own plans.

See: Declarations: Apply, the difference and the rollback in the repository

plans module with an entry

Hash
5cf6713b2eb4f9e3631ddec3972bcb5e0e2efaeba81d3725f9d614be9f6c3c67
Size
376832 bytes
Exports
11
Imports
0
Imported by
0
License
MIT

The exports of the plans service that act for the principal of the caller

FactValue
KindModules with an entry
Sourcesrc/modules/system/plans
Boot imageyes: in the boot image, 376832 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
difference(rows: Table(Plan_Entry_Row, Read), summary: Table(Plan_Difference_Summary, Append)) -> Table(Plan_Diff_Row)computes the difference between the current plan of the principal of the caller and the plan of rows, and applies nothing
apply(plan_name: Text, rows: Table(Plan_Entry_Row, Read), expected: Plan_Expected) -> Integershows the difference between the plan of rows and the current plan of the principal of the caller on the trusted display, and keeps the plan until the principal decides
apply_poll(ticket: Integer) -> Table(Plan_Generation_Row)reads the decision of the principal on the apply of a ticket
rollback() -> Integershows on the trusted display the difference between the current plan of the principal of the caller and the generation before it, and keeps the rollback until the principal decides
rollback_poll(ticket: Integer) -> Table(Plan_Generation_Row)reads the decision of the principal on the rollback of a ticket
generations() -> Table(Plan_Generation_Row)gives the applied generations of the principal of the caller, oldest first, each with where it stands against the current one
status(out: Plans_Status) -> Integerwrites aggregate plans service counters into out
current_generation() -> Integerreturns the active applied plan generation of the principal of the caller, or 0 when none
diff_count() -> Integerreturns the plan differences that the service computed
apply_generation() -> Integerreturns the newest generation that an apply committed for the principal of the caller, or 0 when none: the next apply commits the generation after it, even after a rollback
rollback_generation() -> Integerreturns the generation that a rollback of the principal of the caller selects, and rolls nothing back
entry()binds the private store, the way to the trusted display and the roles page of the core, then serves the exports until stopped

difference

difference(rows: (, Read), summary: (, Append)) -> ()

difference computes the difference between the current plan of the principal of the caller and the plan of rows, and applies nothing.

  • rows: the entries of the proposed plan, 1 to 32.
  • summary: one row: the counts, whether an apply needs the consent of the principal, and the hash of the current plan that apply expects.
  • result: one row for each change, in the order of the difference.

The result is the count of changes, or a negative number with an error record: ERROR_NO_CALLER, ERROR_ACTS_FOR_PRINCIPAL, ERROR_NOT_READY, or ERROR_PLAN with the refusal as the value found.

Parameters
  • rows: (, Read)
  • summary: (, Append)
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/plans/exports.odin:131

apply

apply(plan_name: , rows: (, Read), expected: ) -> 

apply shows the difference between the plan of rows and the current plan of the principal of the caller on the trusted display, and keeps the plan until the principal decides. It commits nothing: apply_poll reads the decision and commits an accepted plan.

  • plan_name: the name that the dialog shows, 1 to 48 bytes.
  • rows: the entries of the plan, 1 to 32.
  • expected: the hash of the current plan that a difference gave; zero when the principal has no applied plan. An apply whose current plan changed since is refused, so a principal never accepts a difference that it did not see.

The result is the ticket of the apply, the serial of the dialog, or a negative number with an error record: ERROR_NO_CALLER, ERROR_ACTS_FOR_PRINCIPAL, ERROR_NOT_READY, or ERROR_PLAN with the refusal as the value found: No_Change, Apply_Pending (the dialog of an earlier apply still shows), Display_Refused (the dialog cannot show the whole difference), Consent_Required (the service has no trusted display).

Parameters
  • plan_name:
  • rows: (, Read)
  • expected:
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/exports.odin:174

apply_poll

apply_poll(ticket: ) -> ()

apply_poll reads the decision of the principal on the apply of a ticket. While the dialog shows, it gives 0 and changes nothing. When the principal accepted, it writes the plan as the generation after the highest one in the private store of the service, then makes it current, and gives the generation, with its row in result. A refused difference changes nothing.

The result is 0, the new generation, or a negative number with an error record: ERROR_NO_CALLER, ERROR_ACTS_FOR_PRINCIPAL, ERROR_NOT_READY, or ERROR_PLAN with the refusal as the value found: Refused_By_Principal, No_Pending_Apply, Display_Refused, Stale_Current_Plan (another apply or a rollback came first), Store_Failed (nothing committed).

Parameters
  • ticket:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/plans/exports.odin:216

rollback

rollback() -> 

rollback shows on the trusted display the difference between the current plan of the principal of the caller and the generation before it, and keeps the rollback until the principal decides. It commits nothing and changes no role holder: a rollback restores grants and role holders, so rollback_poll commits it only when the principal accepted.

The result is the ticket of the rollback, the serial of the dialog, or a negative number with an error record: ERROR_NO_CALLER, ERROR_ACTS_FOR_PRINCIPAL, ERROR_NOT_READY, or ERROR_HISTORY with the refusal as the value found: the kind Absent and the unit Versions when no generation comes before the current one, No_Change, Apply_Pending (the dialog of an earlier apply or rollback still shows), Display_Refused, Consent_Required (the service has no trusted display), Store_Failed and Store_Damaged for the private store.

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/exports.odin:256

rollback_poll

rollback_poll(ticket: ) -> ()

rollback_poll reads the decision of the principal on the rollback of a ticket. While the dialog shows, it gives 0 and changes nothing. When the principal accepted, it makes the generation that the dialog showed the current one: the roles of principal 0 go to the root service first, then the current object of the private store is written, which is the commit. It writes no plan: the next apply still writes the generation after the highest one. A refused difference changes nothing.

The result is 0, the new current generation, or a negative number with an error record: ERROR_NO_CALLER, ERROR_ACTS_FOR_PRINCIPAL, ERROR_NOT_READY, or ERROR_HISTORY with the refusal as the value found: Refused_By_Principal, No_Pending_Apply, Display_Refused, Stale_Current_Plan (an apply or a rollback came first), Roles_Refused, Store_Failed (nothing committed).

Parameters
  • ticket:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/plans/exports.odin:285

generations

generations() -> ()

generations gives the applied generations of the principal of the caller, oldest first, each with where it stands against the current one.

The result is the count of generations, or a negative number with an error record: ERROR_NO_CALLER, ERROR_ACTS_FOR_PRINCIPAL, ERROR_NOT_READY, or ERROR_HISTORY when the private store cannot be read.

Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/plans/exports.odin:317

status

status(out: ) -> 

status writes aggregate plans service counters into out.

Parameters
  • out:
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/main.odin:41

current_generation

current_generation() -> 

current_generation returns the active applied plan generation of the principal of the caller, or 0 when none. A caller names no principal: it reads only its own plans (exports.odin, caller_principal).

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/main.odin:61

diff_count

diff_count() -> 

diff_count returns the plan differences that the service computed.

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/main.odin:75

apply_generation

apply_generation() -> 

apply_generation returns the newest generation that an apply committed for the principal of the caller, or 0 when none: the next apply commits the generation after it, even after a rollback.

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/main.odin:86

rollback_generation

rollback_generation() -> 

rollback_generation returns the generation that a rollback of the principal of the caller selects, and rolls nothing back. With no earlier generation, it fails with the kind Absent and the unit Versions; found is the refusal.

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/system/plans/main.odin:99

entry

entry()

entry binds the private store, the way to the trusted display and the roles page of the core, then serves the exports until stopped.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/plans/main.odin:114

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsThe holder of the role Plans: the generations of the plan of each principal in its private store, the boot image and a connection to the trusted display for the difference that the principal sees, and the roles page of this service, which takes the roles of an accepted plan of principal 0 whole or refuses them whole (Root_Command.Plan_Roles; Declarations: Apply, the difference and the rollback in the repository). Its callers act for their principal; it acts for nobody.
Other terms of its start grant setcallable = {0 = "display"}, on_demand = true
Budget that it asks for
  • working memory pages 512
  • pages of its threads 72
  • pages of the pictures of its window 0
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 1
Working memory budget for the freestanding plans service process and its fixed-capacity per-principal applied_plans tables.

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Plan_Entry_Row record of a module

A record of the module plans: 192 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kind_wordi6408 bytes
  • role_wordi6488 bytes
  • start_grants_maski64168 bytes
  • store_rights_wordi64248 bytes
  • module_hashHash(32)3232 bytes
  • interposed_over_hashHash(32)6432 bytes
  • recipe_hashHash(32)9632 bytes
  • nameText(64)12864 bytes

Plan_Difference_Summary record of a module

A record of the module plans: 168 bytes, aligned on 8 bytes, 0 bytes of padding.

  • change_counti6408 bytes
  • added_rolesi6488 bytes
  • removed_rolesi64168 bytes
  • changed_rolesi64248 bytes
  • added_modulesi64328 bytes
  • removed_modulesi64408 bytes
  • changed_modulesi64488 bytes
  • added_storesi64568 bytes

and 7 more

Plan_Diff_Row record of a module

A record of the module plans: 184 bytes, aligned on 8 bytes, 0 bytes of padding.

  • change_wordi6408 bytes
  • entry_kind_wordi6488 bytes
  • role_wordi64168 bytes
  • added_grants_maski64248 bytes
  • removed_grants_maski64328 bytes
  • old_store_rights_wordi64408 bytes
  • new_store_rights_wordi64488 bytes
  • old_module_hashHash(32)5632 bytes

and 2 more

Error_Record record of a module

A record of the module plans: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Text wire form

A wire form of the module contract: one word of a call. The address of a slice record {address, count} of UTF-8 bytes.

Plan_Expected record of a module

A record of the module plans: 32 bytes, aligned on 1 bytes, 0 bytes of padding.

  • current_plan_hashHash(32)032 bytes

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Plan_Generation_Row record of a module

A record of the module plans: 88 bytes, aligned on 8 bytes, 0 bytes of padding.

  • generationi6408 bytes
  • timestamp_msi6488 bytes
  • standing_wordi64168 bytes
  • plan_hashHash(32)2432 bytes
  • previous_plan_hashHash(32)5632 bytes

Plans_Status record of a module

A record of the module plans: 32 bytes, aligned on 8 bytes, 0 bytes of padding.

  • total_diffsi6408 bytes
  • total_appliesi6488 bytes
  • total_rollbacksi64168 bytes
  • total_refusalsi64248 bytes