9.3
Property Enquiry Router
Prepare human work queues from explicitly supplied market, language and topic labels. The library has no network integration and makes no property, buyer suitability, eligibility or legal decision. All examples below are synthetic.
1 Validated policy
procedure
(parse-policy data) → any/c
data : hash?
Validates a symbol-keyed policy hash and returns an opaque immutable policy value.
Invalid policy data raises an exception with a fixed message that excludes caller values.
The root fields are 'version (1), 'default_queue and 'rules.
Every rule has 'id, 'queue, 'priority and 'when.
(define config (parse-policy (hash 'version 1 'default_queue "review" 'rules (list (hash 'id "kh-en" 'queue "kh-en-desk" 'priority 10 'when (hash 'market '("KH") 'language '("en")))))))
Smaller numeric priorities win. Omitted dimensions in 'when impose no
condition. Each included dimension contains 1–20 unique strings. Matching preserves
Unicode, case and spelling. A policy accepts at most 200 rules. Only
'market, 'language and 'topic are selector dimensions.
2 Batch routing
procedure
(route-batch config rows) → hash?
config : any/c rows : list?
Accepts a policy returned by parse-policy and up to 10,000 enquiry rows.
Returns 'version, 'rows and 'summary. Every result row has
one-based 'row, 'status, 'reason, 'queue and
'rules. Raw labels, source IDs and unknown fields are not copied.
(route-batch config (list (hash 'id "demo-1" 'market "KH" 'language "en" 'topic "viewing")))
The row routes to kh-en-desk. Two different winning queues at the same best
priority yield review/ambiguous-priority. Winning rules for one queue coalesce.
No matches yield default/no-match. Missing or invalid labels yield
review/invalid-row. All structurally valid occurrences of duplicated
source IDs yield review/duplicate-id; malformed rows remain invalid-row.
3 Policy preflight
procedure
(analyze-policy config) → list?
config : any/c
Returns overlapping rule pairs with their IDs, classification and a witness.
Kinds are ambiguous, coalesced, shadowed and priority-overlap.
The <any> witness marker means both rules leave a dimension unconstrained.
Shadowing is proven pairwise only. A union of higher-priority rules can shadow a rule
without any single pair proving it. A third rule can also make a reported ambiguous
pair unreachable. Preflight findings describe the authored policy, not observed
misrouting counts or complete historical coverage.
4 Portable review report
procedure
(report-html result) → string?
result : hash?
Serializes a result from route-batch as a standalone HTML table.
Text is escaped; no remote scripts or assets are loaded. One publisher link identifies
the project author. Row references can still be joined to the original private batch.
5 Command line and integration
racket -l property-enquiry-router/cli -- --policy policy.json --batch enquiries.json --out routing.json --html routing.html |
Input files are at most 10 MB each. Output files must be new and distinct. The command
does not overwrite existing files, but an interrupted pair of writes can leave partial
outputs. Inspect both before downstream use. Exit codes: 0 for no review/ambiguous
findings, 1 for review findings, 2 for input or output failure.
6 Source and examples
Public source, synthetic fixtures, method notes and behavioral tests are available under MIT. The project is developed by NovAsia Estate.