Skip to content

Commit 8798806

Browse files
committed
style: apply canonical poly formatting
rustfmt (max_width=120) reflows across jni/kotlin emitters, plus taplo/oxc formatting of deny.toml, renovate.json, .mcp.json, the e2e fixture schema, and the ai-rulez poly context doc. No behavior change.
1 parent 6bc344f commit 8798806

12 files changed

Lines changed: 359 additions & 331 deletions

File tree

.ai-rulez/context/poly.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ priority: high
77
poly (polylint) is a single-binary, multi-language linter and formatter. It bundles engines (ruff for Python, oxc for JS/TS/JSON, taplo for TOML, rumdl for Markdown) and delegates to native tools (cargo fmt/clippy, golangci-lint, actionlint, shellcheck, shfmt) when present, so most repos need no extra toolchains.
88

99
## Commands
10+
1011
- Lint: `poly lint .`
1112
- Check formatting (dry-run): `poly fmt --check .`
1213
- Apply formatting: `poly fmt --fix .`
1314
- Apply lint autofixes: `poly lint --fix .`
1415

1516
## Configuration
17+
1618
Per-repo `poly.toml``[discovery]` excludes, `[lint.<lang>.<tool>]` rules, `[per-file-ignores]`, `[fmt.<lang>.<tool>]` options. Cache dir `.polylint/` (gitignored).
1719

1820
## Severity
21+
1922
`poly lint` exits non-zero only on error-severity findings; warnings are reported but don't fail CI.
2023

2124
## CI
25+
2226
Validation runs via the shared reusable workflow: `uses: xberg-io/actions/.github/workflows/reusable-validate.yml@v1` (runs `poly fmt --check .` then `poly lint .`).
2327

2428
Run `poly fmt --check .` and `poly lint .` after changes to verify compliance.

.mcp.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"mcpServers": {
3-
"ai-rulez": {
4-
"args": ["mcp"],
5-
"command": "ai-rulez",
6-
"disabled": false,
7-
"transport": "stdio"
8-
},
9-
"playwright": {
10-
"args": ["-y", "@playwright/mcp"],
11-
"command": "npx",
12-
"disabled": false,
13-
"transport": "stdio"
14-
}
15-
}
2+
"mcpServers": {
3+
"ai-rulez": {
4+
"args": ["mcp"],
5+
"command": "ai-rulez",
6+
"disabled": false,
7+
"transport": "stdio"
8+
},
9+
"playwright": {
10+
"args": ["-y", "@playwright/mcp"],
11+
"command": "npx",
12+
"disabled": false,
13+
"transport": "stdio"
14+
}
15+
}
1616
}

deny.toml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ ignore = []
1111

1212
[licenses]
1313
allow = [
14-
"Apache-2.0",
15-
"Apache-2.0 WITH LLVM-exception",
16-
"MIT",
17-
"MIT-0",
18-
"BSD-2-Clause",
19-
"BSD-3-Clause",
20-
"ISC",
21-
"CDLA-Permissive-2.0",
22-
"Zlib",
23-
"Unlicense",
24-
"CC0-1.0",
25-
"Unicode-3.0",
26-
"BSL-1.0",
14+
"Apache-2.0",
15+
"Apache-2.0 WITH LLVM-exception",
16+
"MIT",
17+
"MIT-0",
18+
"BSD-2-Clause",
19+
"BSD-3-Clause",
20+
"ISC",
21+
"CDLA-Permissive-2.0",
22+
"Zlib",
23+
"Unlicense",
24+
"CC0-1.0",
25+
"Unicode-3.0",
26+
"BSL-1.0",
2727
]
2828
confidence-threshold = 0.8
2929

@@ -41,11 +41,11 @@ external-default-features = "allow"
4141
# hashbrown 0.16 (via referencing/jsonschema) and 0.17 (via indexmap/serde_yaml)
4242
# coexist as transitive deps — can't resolve without upstream changes.
4343
skip = [
44-
{ crate = "hashbrown@0.16", reason = "transitive via referencing/jsonschema" },
45-
{ crate = "getrandom@0.2", reason = "transitive via ring/rustls; getrandom 0.3 comes from ahash" },
46-
{ crate = "getrandom@0.4", reason = "transitive via tempfile; getrandom 0.3 comes from ahash" },
47-
{ crate = "r-efi@5.3", reason = "transitive via getrandom 0.3; r-efi 6 comes from getrandom 0.4" },
48-
{ crate = "windows-sys@0.52", reason = "transitive via ring; current tooling uses windows-sys 0.61" },
44+
{ crate = "hashbrown@0.16", reason = "transitive via referencing/jsonschema" },
45+
{ crate = "getrandom@0.2", reason = "transitive via ring/rustls; getrandom 0.3 comes from ahash" },
46+
{ crate = "getrandom@0.4", reason = "transitive via tempfile; getrandom 0.3 comes from ahash" },
47+
{ crate = "r-efi@5.3", reason = "transitive via getrandom 0.3; r-efi 6 comes from getrandom 0.4" },
48+
{ crate = "windows-sys@0.52", reason = "transitive via ring; current tooling uses windows-sys 0.61" },
4949
]
5050
allow = []
5151
deny = []

renovate.json

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
11
{
2-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": ["config:recommended", ":semanticCommits", ":dependencyDashboard"],
4-
"rebaseWhen": "behind-base-branch",
5-
"labels": ["dependencies"],
6-
"lockFileMaintenance": {
7-
"enabled": true,
8-
"schedule": ["before 6am on monday"]
9-
},
10-
"customManagers": [
11-
{
12-
"customType": "regex",
13-
"managerFilePatterns": ["/^crates/alef-core/src/template_versions\\.rs$/"],
14-
"matchStrings": [
15-
"// renovate:\\s*datasource=(?<datasource>\\S+)(?:\\s+depName=(?<depName>\\S+))?(?:\\s+packageName=(?<packageName>\\S+))?(?:\\s+versioning=(?<versioning>\\S+))?(?:\\s+extractVersion=(?<extractVersion>\\S+))?\\s*\\n\\s*pub const [A-Z_]+: &str = \"(?<currentValue>[^\"]+)\";"
16-
],
17-
"depNameTemplate": "{{#if depName}}{{{depName}}}{{else}}{{{packageName}}}{{/if}}",
18-
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else}}{{{depName}}}{{/if}}"
19-
}
20-
],
21-
"packageRules": [
22-
{
23-
"description": "Group Rust crate version pins emitted into generated bindings",
24-
"matchManagers": ["custom.regex"],
25-
"matchDatasources": ["crate"],
26-
"groupName": "generated rust crate pins"
27-
},
28-
{
29-
"description": "Group Python tooling pins",
30-
"matchManagers": ["custom.regex"],
31-
"matchDatasources": ["pypi"],
32-
"groupName": "python tooling pins"
33-
},
34-
{
35-
"description": "Group npm tooling pins",
36-
"matchManagers": ["custom.regex"],
37-
"matchDatasources": ["npm"],
38-
"groupName": "npm tooling pins"
39-
},
40-
{
41-
"description": "Group RubyGems tooling pins",
42-
"matchManagers": ["custom.regex"],
43-
"matchDatasources": ["rubygems"],
44-
"groupName": "rubygems tooling pins"
45-
},
46-
{
47-
"description": "Group Packagist (PHP) tooling pins",
48-
"matchManagers": ["custom.regex"],
49-
"matchDatasources": ["packagist"],
50-
"groupName": "php tooling pins"
51-
},
52-
{
53-
"description": "Group Maven (Java/Kotlin) tooling pins",
54-
"matchManagers": ["custom.regex"],
55-
"matchDatasources": ["maven"],
56-
"groupName": "jvm tooling pins"
57-
},
58-
{
59-
"description": "Group NuGet (C#) tooling pins",
60-
"matchManagers": ["custom.regex"],
61-
"matchDatasources": ["nuget"],
62-
"groupName": "csharp tooling pins"
63-
},
64-
{
65-
"description": "Group Hex (Elixir/Gleam) tooling pins",
66-
"matchManagers": ["custom.regex"],
67-
"matchDatasources": ["hex"],
68-
"groupName": "beam tooling pins"
69-
},
70-
{
71-
"description": "Group pub.dev (Dart) tooling pins",
72-
"matchManagers": ["custom.regex"],
73-
"matchDatasources": ["pub"],
74-
"groupName": "dart tooling pins"
75-
},
76-
{
77-
"description": "Group CRAN (R) tooling pins",
78-
"matchManagers": ["custom.regex"],
79-
"matchDatasources": ["cran"],
80-
"groupName": "r tooling pins"
81-
},
82-
{
83-
"description": "Group pre-commit hook revisions tracked via github-tags",
84-
"matchManagers": ["custom.regex"],
85-
"matchDatasources": ["github-tags"],
86-
"groupName": "pre-commit hook revisions"
87-
},
88-
{
89-
"description": "Group GitHub Actions",
90-
"matchManagers": ["github-actions"],
91-
"groupName": "github actions"
92-
}
93-
]
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:recommended", ":semanticCommits", ":dependencyDashboard"],
4+
"rebaseWhen": "behind-base-branch",
5+
"labels": ["dependencies"],
6+
"lockFileMaintenance": {
7+
"enabled": true,
8+
"schedule": ["before 6am on monday"]
9+
},
10+
"customManagers": [
11+
{
12+
"customType": "regex",
13+
"managerFilePatterns": ["/^crates/alef-core/src/template_versions\\.rs$/"],
14+
"matchStrings": [
15+
"// renovate:\\s*datasource=(?<datasource>\\S+)(?:\\s+depName=(?<depName>\\S+))?(?:\\s+packageName=(?<packageName>\\S+))?(?:\\s+versioning=(?<versioning>\\S+))?(?:\\s+extractVersion=(?<extractVersion>\\S+))?\\s*\\n\\s*pub const [A-Z_]+: &str = \"(?<currentValue>[^\"]+)\";"
16+
],
17+
"depNameTemplate": "{{#if depName}}{{{depName}}}{{else}}{{{packageName}}}{{/if}}",
18+
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else}}{{{depName}}}{{/if}}"
19+
}
20+
],
21+
"packageRules": [
22+
{
23+
"description": "Group Rust crate version pins emitted into generated bindings",
24+
"matchManagers": ["custom.regex"],
25+
"matchDatasources": ["crate"],
26+
"groupName": "generated rust crate pins"
27+
},
28+
{
29+
"description": "Group Python tooling pins",
30+
"matchManagers": ["custom.regex"],
31+
"matchDatasources": ["pypi"],
32+
"groupName": "python tooling pins"
33+
},
34+
{
35+
"description": "Group npm tooling pins",
36+
"matchManagers": ["custom.regex"],
37+
"matchDatasources": ["npm"],
38+
"groupName": "npm tooling pins"
39+
},
40+
{
41+
"description": "Group RubyGems tooling pins",
42+
"matchManagers": ["custom.regex"],
43+
"matchDatasources": ["rubygems"],
44+
"groupName": "rubygems tooling pins"
45+
},
46+
{
47+
"description": "Group Packagist (PHP) tooling pins",
48+
"matchManagers": ["custom.regex"],
49+
"matchDatasources": ["packagist"],
50+
"groupName": "php tooling pins"
51+
},
52+
{
53+
"description": "Group Maven (Java/Kotlin) tooling pins",
54+
"matchManagers": ["custom.regex"],
55+
"matchDatasources": ["maven"],
56+
"groupName": "jvm tooling pins"
57+
},
58+
{
59+
"description": "Group NuGet (C#) tooling pins",
60+
"matchManagers": ["custom.regex"],
61+
"matchDatasources": ["nuget"],
62+
"groupName": "csharp tooling pins"
63+
},
64+
{
65+
"description": "Group Hex (Elixir/Gleam) tooling pins",
66+
"matchManagers": ["custom.regex"],
67+
"matchDatasources": ["hex"],
68+
"groupName": "beam tooling pins"
69+
},
70+
{
71+
"description": "Group pub.dev (Dart) tooling pins",
72+
"matchManagers": ["custom.regex"],
73+
"matchDatasources": ["pub"],
74+
"groupName": "dart tooling pins"
75+
},
76+
{
77+
"description": "Group CRAN (R) tooling pins",
78+
"matchManagers": ["custom.regex"],
79+
"matchDatasources": ["cran"],
80+
"groupName": "r tooling pins"
81+
},
82+
{
83+
"description": "Group pre-commit hook revisions tracked via github-tags",
84+
"matchManagers": ["custom.regex"],
85+
"matchDatasources": ["github-tags"],
86+
"groupName": "pre-commit hook revisions"
87+
},
88+
{
89+
"description": "Group GitHub Actions",
90+
"matchManagers": ["github-actions"],
91+
"groupName": "github actions"
92+
}
93+
]
9494
}

src/backends/jni/gen_shims/marshalling.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ fn emit_return_marshal_with_indent(out: &mut String, return_type: &TypeRef, inde
252252
out.push_str(&format!("{indent}match v {{\n"));
253253
out.push_str(&format!("{indent} None => std::ptr::null_mut(),\n"));
254254
out.push_str(&format!("{indent} Some(inner) => {{\n"));
255-
out.push_str(&format!("{indent} let s = match serde_json::to_string(&inner) {{\n"));
255+
out.push_str(&format!(
256+
"{indent} let s = match serde_json::to_string(&inner) {{\n"
257+
));
256258
out.push_str(&format!("{indent} Ok(s) => s,\n"));
257259
out.push_str(&format!(
258260
"{indent} Err(e) => {{ throw_jni_error(env, &format!(\"serialize: {{e}}\")); return {ret_null}; }}\n"

src/backends/jni/gen_shims/method_shims.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ fn emit_method_shim(
101101
&& (matches!(base_ty, TypeRef::Bytes)
102102
|| matches!(base_ty, TypeRef::Vec(inner) if matches!(inner.as_ref(), TypeRef::Primitive(PrimitiveType::U8)))
103103
|| !matches!(base_ty, TypeRef::Vec(_) | TypeRef::Path | TypeRef::String));
104-
emit_single_param_unmarshal(out, &rust_name, base_ty, ret_null, unmarshal_produces_option, p.map_is_btree);
104+
emit_single_param_unmarshal(
105+
out,
106+
&rust_name,
107+
base_ty,
108+
ret_null,
109+
unmarshal_produces_option,
110+
p.map_is_btree,
111+
);
105112
// `&Vec<String>` coerces to `&[String]` so plain `&<name>` covers every
106113
// Vec<String> method call we currently emit. The previous special-case
107114
// that converted to `Vec<&str>` produced `&[&str]` which is incompatible
@@ -170,7 +177,9 @@ fn emit_method_shim(
170177
// Re-bind the `String` extracted from the request map as a `PathBuf`.
171178
// (The `path_unmarshal` template targets the single-param path, where the
172179
// raw string lives in `req_str`; here the value is already bound to `name`.)
173-
out.push_str(&format!(" let {rust_name} = std::path::PathBuf::from({rust_name});\n"));
180+
out.push_str(&format!(
181+
" let {rust_name} = std::path::PathBuf::from({rust_name});\n"
182+
));
174183
}
175184
// `&Vec<String>` coerces to `&[String]`; the previous Vec<&str>
176185
// special-case produced `&[&str]` incompatible with `&[String]` core

src/backends/jni/gen_shims/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ mod tests {
4141
#[test]
4242
fn bytes_call_arg_optional_ref_uses_as_deref() {
4343
// Option<&[u8]>: Option<Vec<u8>> does not coerce, must deref.
44-
assert_eq!(bytes_call_arg("document_bytes", true, true), "document_bytes.as_deref()");
44+
assert_eq!(
45+
bytes_call_arg("document_bytes", true, true),
46+
"document_bytes.as_deref()"
47+
);
4548
// Option<Vec<u8>>: owned, pass through.
4649
assert_eq!(bytes_call_arg("document_bytes", true, false), "document_bytes");
4750
// &[u8]: &Vec<u8> coerces.

src/backends/jni/gen_shims/type_helpers.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,16 @@ fn type_ref_to_core_path_with_btree(ty: &TypeRef, core_prefix: &str, map_is_btre
143143
TypeRef::Primitive(p) => primitive_rust_type(p).to_string(),
144144
TypeRef::Named(n) => format!("{core_prefix}::{n}"),
145145
TypeRef::Optional(inner) => {
146-
format!("Option<{}>", type_ref_to_core_path_with_btree(inner, core_prefix, map_is_btree))
146+
format!(
147+
"Option<{}>",
148+
type_ref_to_core_path_with_btree(inner, core_prefix, map_is_btree)
149+
)
147150
}
148151
TypeRef::Vec(inner) => {
149-
format!("Vec<{}>", type_ref_to_core_path_with_btree(inner, core_prefix, map_is_btree))
152+
format!(
153+
"Vec<{}>",
154+
type_ref_to_core_path_with_btree(inner, core_prefix, map_is_btree)
155+
)
150156
}
151157
TypeRef::Map(k, v) => {
152158
let container = if map_is_btree {

src/backends/kotlin/gen_bindings/jni_emitter/binary_json.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ fn needs_json_deserialize(ty: &TypeRef) -> bool {
4343
///
4444
/// Opaque types that are known handles do NOT need JSON deserialization — they return Long.
4545
/// Data types (structs, enums, maps, etc.) return JSON String and need deserialization.
46-
fn needs_json_deserialize_for_method(
47-
ty: &TypeRef,
48-
opaque_type_names: &std::collections::HashSet<&str>,
49-
) -> bool {
46+
fn needs_json_deserialize_for_method(ty: &TypeRef, opaque_type_names: &std::collections::HashSet<&str>) -> bool {
5047
// If it's an opaque type name, it's a handle that returns Long (not JSON)
5148
if let TypeRef::Named(n) = ty {
5249
if opaque_type_names.contains(n.as_str()) {

src/backends/kotlin/gen_bindings/jni_emitter/bridge_object.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ pub fn emit_jni_bridge_object(api: &ApiSurface, config: &ResolvedCrateConfig) ->
3232
.functions
3333
.iter()
3434
.filter(|f| {
35-
!exclude_functions.contains(f.name.as_str())
36-
&& !trait_bridge_manages_jni_function(f.name.as_str(), config)
35+
!exclude_functions.contains(f.name.as_str()) && !trait_bridge_manages_jni_function(f.name.as_str(), config)
3736
})
3837
.collect();
3938

@@ -46,11 +45,12 @@ pub fn emit_jni_bridge_object(api: &ApiSurface, config: &ResolvedCrateConfig) ->
4645
.collect();
4746

4847
// Host-native capsule (Language) passthrough configuration from kotlin_android.capsule_types.
49-
let kotlin_android_capsule_types: std::collections::HashMap<String, crate::core::config::HostCapsuleTypeConfig> = config
50-
.kotlin_android
51-
.as_ref()
52-
.map(|c| c.capsule_types.clone())
53-
.unwrap_or_default();
48+
let kotlin_android_capsule_types: std::collections::HashMap<String, crate::core::config::HostCapsuleTypeConfig> =
49+
config
50+
.kotlin_android
51+
.as_ref()
52+
.map(|c| c.capsule_types.clone())
53+
.unwrap_or_default();
5454

5555
let mut body = String::new();
5656
// Suppress detekt TooManyFunctions: the bridge object has one external fun

0 commit comments

Comments
 (0)